Arduino Project 01

From ikev.in/w
Revision as of 01:50, 22 April 2023 by Ikevinax (talk | contribs)
Project diagram.
Video of the finished project. (Click to see animation.)

Arduino Uno LED Blinking Project

The Arduino Uno LED Blinking Project is a simple project that involves programming an Arduino Uno microcontroller board to control a set of LEDs. The goal is to make the LEDs blink randomly with a certain pattern. This project provides a simple introduction to microcontroller programming and the basics of controlling output devices like LEDs with an Arduino board.

Hardware Requirements

To complete this project, you will need the following hardware components:

  • Arduino Uno microcontroller board
  • Breadboard
  • 5 LEDs
  • 5 220 ohm resistors
  • Jumper wires

Wiring the LEDs

To wire the LEDs to the Arduino Uno board, follow these steps:

1. Connect the long leg of the first LED to digital pin 2 on the Arduino Uno board using a jumper wire. 2. Connect the short leg of the first LED to a 220 ohm resistor. 3. Connect the other end of the 220 ohm resistor to the negative rail of the breadboard. 4. Connect the long leg of the second LED to digital pin 3 on the Arduino Uno board using a jumper wire. 5. Connect the short leg of the second LED to a 220 ohm resistor. 6. Connect the other end of the 220 ohm resistor to the negative rail of the breadboard. 7. Repeat steps 4-6 for the remaining three LEDs, connecting them to digital pins 4, 5, and 6.

Programming the Arduino Uno

To program the Arduino Uno board to make the LEDs blink randomly, follow these steps:

1. Open the Arduino IDE software. 2. Connect the Arduino Uno board to your computer using a USB cable. 3. In the Arduino IDE, create a new sketch. 4. Copy and paste the following code into the sketch:

Code

// define the LED pins
int ledPins[] = {2, 3, 4, 5, 6};

void setup() {
  // initialize the LED pins as outputs
  for (int i = 0; i < 5; i++) {
    pinMode(ledPins[i], OUTPUT);
  }
}

void loop() {
  // turn a random LED on
  int randLed = random(0, 5);
  digitalWrite(ledPins[randLed], HIGH);

  // wait for a short amount of time
  delay(50);

  // turn the LED off
  digitalWrite(ledPins[randLed], LOW);

  // wait for a short amount of time
  delay(50);
}