Change power of the light with potentiometer.
This commit is contained in:
+8
-15
@@ -1,25 +1,18 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
#define LED1 3
|
#define LED 6
|
||||||
#define LED2 4
|
#define ANALOG_A0 A0
|
||||||
#define LED3 5
|
|
||||||
#define BUTTON 2
|
int Voltage = 0;
|
||||||
|
|
||||||
// Setup Section
|
// Setup Section
|
||||||
void setup() {
|
void setup() {
|
||||||
pinMode(BUTTON, INPUT);
|
pinMode(LED, OUTPUT);
|
||||||
pinMode(LED1, OUTPUT);
|
|
||||||
pinMode(LED2, OUTPUT);
|
|
||||||
pinMode(LED3, OUTPUT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loop Section
|
// Loop Section
|
||||||
void loop() {
|
void loop() {
|
||||||
while (digitalRead(BUTTON) == LOW) {
|
Voltage = analogRead(ANALOG_A0);
|
||||||
for (unsigned short int i = 3; i < 6; i++) {
|
Voltage = Voltage / 4;
|
||||||
digitalWrite(i, HIGH);
|
analogWrite(LED, Voltage);
|
||||||
delay(250);
|
|
||||||
digitalWrite(i, LOW);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user