0% found this document useful (0 votes)
64 views

Flash An LED: Parts List

To flash an LED using an Arduino: 1. Connect an LED, resistor, and breadboard to an Arduino according to the provided schematic. The cathode of the LED connects to ground and the anode connects through a resistor to a digital pin on the Arduino. 2. Write code that sets the digital pin as an output. The code then toggles the pin high and low with delays, turning the LED on and off. 3. Upload the code to the Arduino to flash the LED on and off repeatedly.

Uploaded by

realaffiliate
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
64 views

Flash An LED: Parts List

To flash an LED using an Arduino: 1. Connect an LED, resistor, and breadboard to an Arduino according to the provided schematic. The cathode of the LED connects to ground and the anode connects through a resistor to a digital pin on the Arduino. 2. Write code that sets the digital pin as an output. The code then toggles the pin high and low with delays, turning the LED on and off. 3. Upload the code to the Arduino to flash the LED on and off repeatedly.

Uploaded by

realaffiliate
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Flash an LED

The ability to flash an LED is the most basic hello world type of program you can write and run on your
arduino.
Most Arduinos have an LED attached to D13, rather than take the easy option we will attach an LED
externally to the Arduino, if you wish to flash the LED on the board skip to the code and then change the led
value as explained at the end of the article
Parts List
Here are the parts you will require
1 Arduino UNO or equivalent
1 LED
1 470 ohm resistor
1 Breadboard to build the circuit
Wires to connect the LED resistor to the Arduino
Here is what you will build, watch the polarity of the LED, the image below shows how to tell the positive
(anode) and negative (cathode) apart.

LED polarity
As you can see the cathode is connected to the GND on the Arduino.

LED breadboard layout


Schematic
Here is the schematic, fairly straightforward

LED and arduino schematic


We will toggle the appropriate Arduino output pin high to switch the LED on, to switch it off we will toggle the
output low.
Code
Here is the code, we have over commented so you can see what is going on here
int ledPin = 2; // we will use this variable later
// The setup() method runs once at startup
void setup()
{
pinMode(ledPin, OUTPUT); // Set pin as OUTPUT
}
// the loop() method repeats indefinitely
void loop()
{
digitalWrite(ledPin, HIGH); //switch LED on high
delay(1000); //delay for 100 ms
digitalWrite(ledPin, LOW); //switch LED off low
delay(1000); //delay for 100 ms
}

Incidentally if you wish to switch the LED on the board on and off change int ledPin value to 13

You might also like