It’s far from exciting, but I wrote my very first test program for the Arduino. Definitely easy! All it does is watch for finger-presses on the OLED, and then writes the location in text to the screen, and also places a pulsing (the central dot changes color rapidly and randomly) target wherever you touch (I haven’t calibrated the screen yet as you may have noticed), only redrawing when it needs to. I still have a lot to figure out, but it works!
Anyway, I’ll write something more substantial later, but this just shows how easy it is to get the Arduino up and running by someone who’s got no recent experience with microcontrollers.
Code for this is really easy:
void setup()
{
;
}
int oldmouseX;
int oldmouseY;
int tmouseX;
int tmouseY;
int r;
int g;
int b;
void loop()
{
gettouch();
tmouseX = mouseX;
tmouseY = mouseY;
if (tmouseX != oldmouseX || tmouseY != oldmouseY)
{
oldmouseX = mouseX;
oldmouseY = mouseY;
background(0);
fill(255, 0, 0);
ellipse(mouseX, mouseY, 20,20);
fill(225);
ellipse(mouseX, mouseY, 15,15);
fill(195);
ellipse(mouseX, mouseY, 10,10);
fill(165);
ellipse(mouseX, mouseY, 5,5);
fill(0);
text(oldmouseX, 10, 10);
text(oldmouseY, 10, 30);
delay(100);
}
else
{
r = random(128, 255);
g = random(128, 255);
b = random(128, 255);
fill(r, g, b);
ellipse(mouseX, mouseY, 5,5);
delay(50);
}
}
2 Comments
I did a fair amount of RobotC programming for a recent Engineer Science/LEGO class, and I can attest to the ease in which you can make these types of toys do very fun things!
I haven’t written c code in years and it was never good to begin with. Writing programs in Basic for the stamps and picaxes leaves a lot to be desired. It’s really nice to include libraries where all the hard stuff is being done. Thanks for the post.
Post a Comment