arduino. digi-sketch

i was making a presentation at work about some of the various things i've created, and i really wanted to show something using arduino. unfortunately i haven't had much time to flush out a project yet. so i whipped up this quick digital etch-a-sketch project.
it's definately not a new idea but i built this one from scratch and added a "shake to clear" feature.
one problem i was having was the jitter from the potentiometers. i just grabbed some pots i had lying around, they both have different impedence values 1M and 100k, so at some point i should probably get two with the same values and much smaller. using this piece of code, first in arduino (which worked ok), then in processing (which works much better) i smoothed out some of the jitter:
int average(int val, int readingsCount) {
int total;
int readings[readingsCount];
for(int i=0; i!=readingsCount; i++) {
total -= readings[i];
readings[i] = val;
total += readings[i];
}
int average = total / readingsCount;
return average;
}
int total;
int readings[readingsCount];
for(int i=0; i!=readingsCount; i++) {
total -= readings[i];
readings[i] = val;
total += readings[i];
}
int average = total / readingsCount;
return average;
}
c = clear screen
s = toggle shake to clear on/off
grab the source digiSketch_0_2 and digiSketchController_0_2.pde
Labels: arduino, processing