Adjustable Blinking LED
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
- Place the LED in the breadboard towards the center row.
- Attach the Resistor from the negative leg (shortest leg) of the LED, to the negative row of the breadboard.
Potentiometer
- Place the potentiometer on the breadboard (a good distance from the LED)
Wire Attached to LED
- Place a wire at the positive leg of the LED
- Connect the other side to PIN 13 of the Arduino.
Potentiometer Wires
- Attatch one wire for each leg of the potentiometer (3 total)
- Attatch the wire #1 (Labeled in picture) to the negative row of the breadboard.
- Attach wire #2 to PIN A0 of the Arduino.
- Attach wire #3 the positive row of the breadboard.
Other Wires
- Attach one wire at the end of the negative row of the breadboard.
- Attach the other side of the wire to the GND PIN of the Arduino.
- Attach another wire to the positive row of the breadboard.
- Attach the other side of the wire to 5V PIN of the Arduino.
Coding
- Connect the Arduino to your computer.
- 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);
}
- Verify the code
- Test by turning the potentiometer (The LED should blink faster or slower depending on which way you turn it)