apuntes_Arduino/leds/dimmer_led/dimmer_led.ino

34 lines
573 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() {
2022-04-04 17:41:38 -04:00
pinMode(LEDtop, OUTPUT);
pinMode(LEDmid, OUTPUT);
pinMode(LEDbot, OUTPUT);
pot=0;
2021-01-05 00:15:16 -03:00
}
void loop() {
2022-04-04 17:41:38 -04:00
dimmer(LEDtop);
2021-01-05 00:15:16 -03:00
}
void dimmer(byte LED) {
2022-04-04 17:41:38 -04:00
pot = analogRead(POT);
pot = map(pot, 0, 1023, 0, 255);
analogWrite(LED, pot);
2021-01-05 00:15:16 -03:00
}
void fxRes(byte LED) {
for (byte i=20; i<255; i++) {
analogWrite(LED, i);
delay(5);
2022-04-04 17:41:38 -04:00
}
for (byte i=255; i>20; i--) {
analogWrite(LED, i);
delay(5);
}
2021-01-05 00:15:16 -03:00
}