Project 2 – Pentiometer with LED
| The blue knob in the back is the potentiometer |
We modified our first project to include a potentiometer,
which we used to control the blink rate of the LED instead of the program we wrote.
Hardware concepts we learned were:
- · How a pentiotiometer can control the voltage to the output.
- · The difference between an Analog and Digital output
Programming concepts we learned were:
- · What a variable is and how to declare and use them
- · Using different data types (Int)
- · How to read an analog input with analogRead
Our Program- The
delay function is linked to the value coming from the potentiometer, so the
more we turn the knob, the faster it blinks.
int sensorPin = 0
int ledPin = 13
void setup()
{ pinMode(ledPin, OUTPUT)}
void loop()
{ int sensorValue
sensorValue =
analogRead(sensorPin)
digitalWrite(ledPin,
HIGH
delay(sensorValue)
digitalWrite(ledPin, LOW)
delay(sensorValue)}
No comments:
Post a Comment