I’m playing with the Arduino board now. It’s fancy, it’s Italian, and it has a nice little map of Italy on the back with regions and everything. Forgot to photograph the back, but the front is where the action is anyway:
This is a board that you can connect to your computer and then program it to do fun stuff. Like make LED lights blink in interesting patterns. You probably wonder how one would make a LED light be on for 1 second, and then off for one second in an eternal loop. This is how:
// Example 01 : Blinking LED
#define LED 13 // LED connected to digital pin 13
void setup()
{
pinMode(LED, OUTPUT); // sets the digital pin as output
}void loop()
{
digitalWrite(LED, HIGH); // turns the LED on
delay(1000); // waits for a second
digitalWrite(LED, LOW); // turns the LED off
delay(1000); // waits for a second
}
In addition to actually hook up the Arduino board to the computer running the program, of course. And put a LED light in spot 13. However, by adding a breadboard, some wires, a resistor and a momentary switch to the equation, I can make the LED light turn on whenever I want – as long as I press down the switch button. This is how I set it all up:

Stupid me taking the photo when the LED light was off. But I can assure you, it was definitely on too.
And I also needed some more lines of code to make this work – like defining in the code that there’s now also a nice black button involved:
// Example 02: Turn on LED while the button is pressed
#define LED 13 // the pin for the LED
#define BUTTON 7 // the input pin where the pushbutton is connectedint val = 0; // val will be used to store the state of the input pin
void setup() {
pinMode(LED, OUTPUT); // tell Arduino LED is an output
pinMode(BUTTON, INPUT); // and BUTTON is an input
}void loop(){
val = digitalRead(BUTTON); // read input value and store it// check whether the input is HIGH (button pressed)
if (val == HIGH) {
digitalWrite(LED, HIGH); // turn LED ON
} else {
digitalWrite(LED, LOW);
}
}
But wouldn’t it be just perfect if I didn’t have to keep pressing the button down all the time when I want light? Oh yes:
// Example 03: Turn on LED when the button is pressed
#define LED 13 // the pin for the LED
#define BUTTON 7 // the input pin where the pushbutton is connected
int val = 0; // val will be used to store the state of the input pin
int old_val = 0; // this variabke stores the previous value of “val”
int state = 0; // 0 = LED off while 1 = LED onvoid setup() {
pinMode(LED, OUTPUT); // tell Arduino LED is an output
pinMode(BUTTON, INPUT); // and BUTTON is an input
}void loop(){
val = digitalRead(BUTTON); // read input value and store it// check if the input is HIGH (button pressed) and change the state
if ((val == HIGH) && (old_val == LOW)) {
state = 1 – state;
delay(10);
}old_val = val; //val is now old, let’s store it
if (state == 1) {
digitalWrite(LED, HIGH); // turn LED ON
}else {
digitalWrite(LED, LOW);
}
}
This way the switch works as I want it to – lighting up when I press one time, and then it’s turned off the next time I press the switch. By substituting the switch with other objects, I can make my very own switch. I made my switch by connecting one wire to the needle-nose pliers, and another to my key chain. When I let the pliers touch a key in my key chain, there was light. Arduino rules.
