Blinking a LED with Arduino
Blinking a LED with Arduino – Edit content (add a revision)
The "Hello World!" code for Arduino : blinking a LED. You can see the electronic part in the link above. [code,c] ------ //the pin on which you connect the anode (+) of the LED byte ledPin = 13; //our on/off switch byte state = LOW; //this function runs only once (after reset) void setup(){ //set the pin we use to OUTPUT so we can power-up the LED pinMode(ledPin, OUTPUT); } //this function runs continuosly (after setup) void loop(){ //toggle our switch (if off make it on and vice-versa) if (state == LOW){ state = HIGH; } else { state = LOW; } //toggle the LED based on our switch above digitalWrite(ledPin, state); //sleep for 1000 ms = 1 second delay(1000); } ------ A picture of the electronic part : image:http://stuff.nekhbet.ro/wp-content/uploads/2009/08/DSCF4594.jpg[Blinking a LED with Arduino]
Save as new Revision
Syntax docs