Saturday, April 2, 2011

Project 1 – LED Flasher – Code Overview

Posted by rinson

Open up your Arduino IDE and type in the code from Listing 2-1.
Listing 2-1. Code for Project 1
// Project 1 - LED Flasher
int ledPin = 10;
void setup() {
pinMode(ledPin, OUTPUT);
void loop() {
digitalWrite(ledPin, HIGH);
digitalWrite(ledPin, LOW);
Press the Verify/Compile button at the top of the IDE to make sure there are no errors in your code.
If this is successful, click the Upload button to upload the code to your Arduino. If you have done
everything right, you should now see the red LED on the breadboard flashing on and off every second.
Let’s take a look at the code and the hardware to find out how they both work.