Description
For this homework assignment I followed the basical description and made one potentiometer control the blinking and one control the brightness of a single LED. I wired my two potentiometers into the breadboard along with the 3 LEDs from the lab. For the homework, I only used the green LED.
In the future I would like to incorporate this with the lamp we built for the last homework so that the outstretching of the lamp pulses the LED in the spring with the diffuser.
Materials
- Arduino Uno
- Jumpers
- Breadboard
- Green LED
- 220 Ohm Resistors
- 2 - potentiometers
Code
int brightPin = A0; // select the input pin for the brightness potentiometer
int blinkPin = A1; // select the input pin for the brightness potentiometer
int ledPin = 10; // select the pin for the LED
int bright = 0; // variable to store the value coming from the sensor
int blinkTime = 0;
void setup() {
pinMode(ledPin, OUTPUT); // declare the ledPin as an OUTPUT
Serial.begin(9600);
}
void loop() {
bright = analogRead(brightPin); // read the value from the sensor
blinkTime = analogRead(blinkPin);
Serial.println(blinkTime);
analogWrite(ledPin, bright/4); // turn the ledPin to
delay(blinkTime); // stop the program for some time
analogWrite(ledPin, 0); // turn the ledPin off
delay(blinkTime); // stop the program for some time
}
- Login to post comments