Part Required
- Breadboard
- 5 mm LED
- 100 ohm Resistor (this value may differ depending on what LED you use.)
- Jumper Wires
First, make sure your Arduino is powered off by unplugging it from the USB cable. Now, take your breadboard, LED, resistor, and wires and connet everything as shown in Figure below:
Image Source: Book Beggining Arduino. Page: 22 |
Enter the Code:
Open up yout Arduino IDE and type in the code below:
int ledPin = 10;
void setup() {
pinMode(ledPin, OUTPUT);
}
void loop() {
digitalWrite(ledPin, HIGH);
delay(1000);
digitalWrite(ledPin, LOW);
delay(1000);
}
Code Overview
In code we use digital pin 10 (int ledPin = 10;), the LED will be On for 1 sec and off for 1 sec. To set the speed of On and Off, we just change LED delay time in the code (delay(1000);)
The code can be downloaded HERE.
Source: Excerpted and adapted from the Book Beginning Arduino, page 21-23.
Image Saurce: http://www.amazon.co.uk/Beginning-Arduino-Michael-McRoberts/dp/1430232404 |
Hope it's useful....
Tidak ada komentar:
Posting Komentar