CODE:
int ledPin = 9; | // LED connected to digital pin 9 |
| void setup() | |
| { | |
| pinMode(ledPin, OUTPUT); | / // sets the digital pin as output |
| } | |
| void loop() | |
| { | |
| digitalWrite(ledPin, HIGH); | // sets the LED off |
| delay(1000); | // waits for a second |
| digitalWrite(ledPin, LOW); | // sets the LED on |
| delay(1000); | // waits for a second |
| } | |
SCHEMATIC:
in this set up the led turns on when digital pin 9 is set "low" and off when digital pin 9 is set "high."
(current flows from +V to Gnd)