ArduFix

Arduino Tutorial

Arduino, arduino unno

Control an LED

control LED blinking

To control an LED using an Arduino Uno, you will need the following components:

  1. Arduino Uno board
  2. LED (Light-Emitting Diode)
  3. Resistor (typically around 220 ohms)
  4. Breadboard
  5. Jumper wires

Here are the step-by-step instructions to control an LED using Arduino Uno:

  1. Place the LED on the breadboard.
  2. Connect the negative (shorter) leg of the LED to the GND of Arduino. This leg is known as the cathode.
  3. Place a resistor on the breadboard and connect one end of it to the positive (longer) leg of the LED. This is known as anode.
  4. Connect the other end of the resistor to the Arduino’s digital pin (i.e. pin 13).
  5. Connect the Arduino to your computer using a USB cable.

Moving forward, we will now tackle the programming part.

  1. Open the Arduino IDE  on your computer.
  2. Write the following code:
void setup() {
  pinMode(13, OUTPUT);  // Set digital pin 13 as an output pin
}

void loop() {
  digitalWrite(13, HIGH); // Turn on the LED
  delay(1000);            // Wait for 1 second
  digitalWrite(13, LOW);  // Turn off the LED
  delay(1000);            // Wait for 1 second
}
 
  1. In the Arduino IDE, select the correct board type and port from the “Tools” menu.
  2. Click on the “Upload” button to upload the code to the Arduino board.
  3. The LED connected to pin 13 will start blinking on and off with a 1-second delay between each state.

That’s it! You have successfully controlled an LED using Arduino Uno. You can modify the code to achieve different blinking patterns or control the LED based on different conditions.

Scroll to Top