Blinking Arduino LED With Potentiometer to Adjust Delay
by Lawrence Luckey in Circuits > Arduino
132 Views, 0 Favorites, 0 Comments
Blinking Arduino LED With Potentiometer to Adjust Delay
I made a blinking LED where you can adjust that the rate of blinking. My project is based off the Arduino uno blinking example and was made in my Mechatronics class taught by Mr. Sweet.
Supplies
6 wires, 1 potentiometer ,1 LED, 1 330 ohms resistor, breadboard, arduino uno
Wire Up the LED
Wire 1: First you need to place the led on the bread and then (It's not a wire but,) attach the 330 ohm resistor from the cathode to the negative end of the bread board to help complete the circuit for the led.
Wire 2: Next connect the anode to digital pin 8 so the code will effect the led
Wire 3: Connects the negative end of the bread board to ground on the arduino
Wire 4: Connects the positive end of the bread board to 5v pin on the Arduino. These two wires close the circuit and makes the Arduino able to power the circuit
Wire Up the Potentiometer
Wire 1: The first wire goes from the left most prong of the potentiometer to the positive end of the bread board, when we code the Arduino this will increase the speed of the flashing light.
Wire 2: The second wire goes from the middle prong of the potentiometer to a digital pin A1, A2, etc..
I choose A5 and this digital pin allows us to read the potentiometer and use it's inputs
Wire 3: The last wire goes from the right most prong and to the negative end of the bread board for a similar function as wire 1
Set Up Arduino
// Starts our setup code that we don't need to loop
void setup() {
// Initializes digital pin as an output for this project I used pin 8.
pinMode(8, OUTPUT);
}
// the loop function runs over and over again forever and will contain the blinking and potentiometer functions
void loop() {
// Sets up a variable that takes data from the potentiometer that's imputed into a "ANALOG IN" slot, I used A5; and uses the input when we type in sensorValue.
int sensorValue;
sensorValue = analogRead(A5);
// Code for the blinking function and uses our variable to delay the blinking
digitalWrite(8, HIGH); // turn the LED on (HIGH is the voltage level)
delay(sensorValue); // wait for a "sensorValue" amount second
digitalWrite(8, LOW); // turn the LED off by making the voltage LOW
delay(sensorValue); // wait for a "sensorValue" amount second
}
Check If Everything Is Wired Correctly
Make sure you check everything before turning it on so u don't ruin the components