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