Arduino Blinking LED Circuit

by GrayCode in Circuits > Arduino

293 Views, 0 Favorites, 0 Comments

Arduino Blinking LED Circuit

LEDBlink.PNG

Let’s start from the beginning, you’ve just bought your first Arduino board, you don’t know where to start… The blinking LED has been the first project for many young engineers, and for good reason. This circuit is simple enough for beginners to understand but still allows us to learn the basic functions of the Arduino IDE and microprocessors.

View this project and more at my website Gray Code!

Supplies

  • 1x Breadboard
  • 1x Arduino Uno
  • 1x 330R Resistor
  • 1x LED (Any colour)
  • 2x Jumper Wires
  • 1x USB-A Cable

Lets Construct the Circuit!

20200212_093434.jpg

The first thing to do is to take a look at our photos above to see how the circuit is constructed, and then have a go building it yourself! Hint: Use the circuit diagram when building it, it’s there for a reason.

The LED is connected to Digital Pin 8 of the Arduino via a resistor. A quick summary of the circuit can be seen below:

Pin 8 > 330 Ohm resistor > LED > Ground

Now the Code:

20200212_093426.jpg

Let’s run through what the code is doing, now that we've got the hardware sorted!

The following code is used to activate an LED using the Arduino Microcontroller. This part of the circuit is inside ‘void loop()’ therefore the steps mentioned above repeat forever or until told not to. The pin 8 is set to ‘HIGH’ which allows the LED to be activated, ‘delay(2000)’ ensures the LED stays on for 2 seconds.After 2 seconds the LED pin goes ‘LOW’, ‘delay(1000)’ ensures the LED is kept off for 1 second.Keep in mind the delay function, will stop all operations for the length of time specified in milliseconds. delay(2000) is halting all processes for 2000 milliseconds or 2 seconds.

// This code will blink an LED, on for 2 seconds and off for 1 second, attached to pin 8 on the arduino.
int LED = 8; // Sets the pin the LED is attached to, this can be any of the digital outputs
void setup() {
pinMode(LED, OUTPUT); // Sets the LED to an output
}
void loop() {
digitalWrite(LED,HIGH); // Turns the LED to High
delay(2000); // 2 second delay
digitalWrite(LED,LOW); // Turns the LED to low
delay(1000); // 1 second delay
}

Upload the Code and Watch the Magic!

Upload the code from the Arduino IDE and enjoy the flashing LED!

Take some time and play around, add extra LEDs or change the timing and have fun!

View this project and more at my website Gray Code!