apuntes_Arduino/leds/dimmer_led/dimmer_led.ino

34 lines
543 B
Arduino
Raw Normal View History

2021-01-05 00:15:16 -03:00
#define LEDtop 9
#define LEDmid 10
#define LEDbot 11
#define POT A1
int pot;
void setup() {
pinMode(LEDtop, OUTPUT);
pinMode(LEDmid, OUTPUT);
pinMode(LEDbot, OUTPUT);
pot=0;
}
void loop() {
dimmer(LEDtop);
}
void dimmer(byte LED) {
pot = analogRead(POT);
pot = map(pot, 0, 1023, 0, 255);
analogWrite(LED, pot);
}
void fxRes(byte LED) {
for (byte i=20; i<255; i++) {
analogWrite(LED, i);
delay(5);
}
for (byte i=255; i>20; i--) {
analogWrite(LED, i);
delay(5);
}
}