To make an LED blink faster or slower when we twist the potentiometer
Equipment:
Potentiometer
330 Ohm resistor
3 Led's (Any Color)
4 Wire's (Any Color)
Program Details:
Arduino
Time to Program and Complete:
10 mins
Results:
We just had to change some wires that we misplaced.
Photo/Video Proof:
None right now
Program:
int sensorPin = A0;
//assigns sensorPin to analog pin 0
int ledPin = 13;
//sets ledPin to pin 13
int sensorValue = 0;
//sets a value for sensorValue
void setup()
//declares a setup
{
//start of function
pinMode(ledPin, OUTPUT);
//sets ledPin as an output
}
//end of function
void loop()
//declares a loop
{
// start of loop
sensorValue = analogRead(sensorPin);
//gives sensorValue a value of what sensorPin is currently at
digitalWrite(ledPin, HIGH);
//sets the LED to maximum power
delay(sensorValue);
//delays the code for the value of sensorValue
digitalWrite(ledPin, LOW);
//sets the LED to minimum power
delay(sensorValue);
//delays the code for the value of sensorPin
}
//end of loop
None
Helpful Tips:
Try to have each wire a different color, it could help.
References:
Kyle Chan
Aron Graca
No comments:
Post a Comment