Adjustable Blinking LED

by allysonp in Circuits > Arduino

27 Views, 0 Favorites, 0 Comments

Adjustable Blinking LED

IMG_4635.JPG
IMG_4637.JPG

This project is a blinking LED that moves faster or slower when the potentiometer is rotated.

(*This is a school project for my Mechatronics Class)

Downloads

Supplies

(1) LED

(6) Wires

(1) Resistor

(1) Potentiometer

(1) ARDUINO

(1) Breadboard

LED and Resistor

Screenshot 2024-08-30 11.22.21 AM.png
  1. Place the LED in the breadboard towards the center row.
  2. Attach the Resistor from the negative leg (shortest leg) of the LED, to the negative row of the breadboard.

Potentiometer

Screenshot 2024-08-30 11.23.18 AM.png
  1. Place the potentiometer on the breadboard (a good distance from the LED)

Wire Attached to LED

Screenshot 2024-09-03 11.34.15 AM.png
  1. Place a wire at the positive leg of the LED
  2. Connect the other side to PIN 13 of the Arduino.

Potentiometer Wires

Screenshot 2024-09-03 11.35.57 AM.png
  1. Attatch one wire for each leg of the potentiometer (3 total)
  2. Attatch the wire #1 (Labeled in picture) to the negative row of the breadboard.
  3. Attach wire #2 to PIN A0 of the Arduino.
  4. Attach wire #3 the positive row of the breadboard.


Other Wires

Screenshot 2024-09-03 11.37.43 AM.png
  1. Attach one wire at the end of the negative row of the breadboard.
  2. Attach the other side of the wire to the GND PIN of the Arduino.
  3. Attach another wire to the positive row of the breadboard.
  4. Attach the other side of the wire to 5V PIN of the Arduino.

Coding

Screenshot 2024-08-30 10.57.03 AM.png
  1. Connect the Arduino to your computer.
  2. Type in the following sample code (By ARDUINO) into the Arduino app (also in picture above):


int sensorPin = A0; // select the input pin for the potentiometer

int ledPin = 13; // select the pin for the LED

int sensorValue = 0; // variable to store the value coming from the sensor


void setup() {

// declare the ledPin as an OUTPUT:

pinMode(ledPin, OUTPUT);

}


void loop() {

// read the value from the sensor:

sensorValue = analogRead(sensorPin);

// turn the ledPin on

digitalWrite(ledPin, HIGH);

// stop the program for <sensorValue> milliseconds:

delay(sensorValue);

// turn the ledPin off:

digitalWrite(ledPin, LOW);

// stop the program for <sensorValue> milliseconds:

delay(sensorValue);

}


  1. Verify the code
  2. Test by turning the potentiometer (The LED should blink faster or slower depending on which way you turn it)