Kamis, 26 Mei 2016

LED Flasher

For the first project, you are going to repeat the LED blink sketch that you used during your testing stage. This time, you are going to connect an LED to one of the digital pins rather than using LED13, which is soldered to the board. You software for this project work, learning a bit about  coding in the Arduino langue (which is a variant of C).

Part Required
  • Breadboard
  • 5 mm LED
  • 100 ohm Resistor (this value may differ depending on what LED you use.)
  • Jumper Wires
Connecting Everything

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

Related Posts Plugin for WordPress, Blogger...