Adjustable Flashing LED Using a POT and an Arduino

by Evanlgks in Circuits > Arduino

38 Views, 0 Favorites, 0 Comments

Adjustable Flashing LED Using a POT and an Arduino

WIN_20240903_11_23_32_Pro.jpg

In my Mech 1 class, ran by Mr. Sweet, we used the Sparkfun SIK and used the diagram to build the structure, then used the built in code to test it out. Finally I remastered the code to fit my diameters, and got it to work.

Supplies

1 LED

1POT

1 Resistor

1 Arduino

6 Wires

Code I used

int sensorPin = A0;

int ledPin = 12;

int sensorValue = 0;


void setup() {

 

 pinMode(12, OUTPUT) ;


}


void loop() {


sensorValue = analogRead(sensorPin) ;


digitalWrite(12, HIGH) ;


delay(sensorValue);


digitalWrite(12, LOW);


delay(sensorValue);


}

The Steps

  1. put your led down, and attach a resistor to the positive end
  2. Set your POT away from the led, and attach a wire to the left side of the POT to your positive side on the breadboard and the right wire to the negative side.
  3. The middle wire that goes into the POT should go in A0 slot
  4. Connect a wire from the negative side of the breadboard to the ground on the Arduino, and connect a wire from the positive side of the breadboard to A5
  5. Connect the positive side of the led to pin 13