1 Arduino + 1 9Volt battery + 2 Red LED's
code:
#define LED2 9 // the pin for the LED
#define LED3 11 // the pin for the LED
int i = 0; // We'll use this to count up and down
void setup() {
pinMode(LED2, OUTPUT); // tell Arduino LED is an output
pinMode(LED3, OUTPUT); // tell Arduino LED is an output
}
void loop(){
for (i = 0; i < 255; i++) { // loop from 0 to 254 (fade in)
analogWrite(LED2, i); // set the LED brightness
analogWrite(LED3, i); // set the LED brightness
delay(8); // Wait 10ms because analogWrite
// is instantaneous and we would
// not see any change
}
for (i = 255; i > 0; i--) { // loop from 255 to 1 (fade out)
analogWrite(LED2, i); // set the LED brightness
analogWrite(LED3, i); // set the LED brightness
delay(8); // Wait 8ms
}
analogWrite(LED2, 0); // turn off led
analogWrite(LED3, 0); // turn off led
delay(400);
}