Summer Sale: 5% OFF Over $49, Code: Elephant5; 10% OFF Over $99, Code:Elephant10



Arduino UNO R3/MEGA 2560 R3 Project 2: LED Blinking

Posted by Fiona Su on

Introduction

Blinking LED experiment is quite simple. In the "Hello World!" program, we have come across LED. This time, we are going to connect an LED to one of the digital pins rather than using LED13 which is soldered to the board.

Video Tutorial

Apart from an Arduino and a USB cable, you will need extra parts as below:

Hardware Required

  • Red M5 LED *1
  • 220Ω resistor *1
  • Breadboard * 1
  • Breadboard jumper wire * 2

Connection

We follow below diagram from the experimental schematic link. Here we use digital pin 10.
Connect an LED to a 220 ohm resistor to avoid high current damaging the LED.
Connection for arduino uno REV4:

thumb

Connection for arduino 2560 R3:

thumb

Sample Code

int ledPin = 10; // define digital pin 10.
void setup()
{
pinMode(ledPin, OUTPUT);// define pin with LED connected as output.
}
void loop()
{
digitalWrite(ledPin, HIGH); // set the LED on.
delay(1000); // wait for a second.
digitalWrite(ledPin, LOW); // set the LED off.
delay(1000); // wait for a second
}

Result

After downloading this program, in the experiment, you will see the LED connected to pin 10 turning on and off, with an interval approximately one second. The blinking LED experiment is now completed. Thank you!

All Tutorial

Buy 

0 comments

Leave a comment

Please note, comments must be approved before they are published