Kaptain.
Telegram /
LinkedIn /
Email /
GIT /
RSS /
GPG /
Заказ печатных плат

№ 11244 В разделах:
Electronics
ESP8266
Programming
от March 8th, 2021,
В подшивках: Arduino, ESP8266
Human eye can’t see led switching because its too fast, same effect used in old TV and displays with CRT, most of 7-segment indicators and other things. Change timings between on and off state to change brightness and effect duration.
int sv_max=20;
int sv_min=0;
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
int pause_on=sv_min;
int pause_off=sv_max;
// Smooth turn on
while(pause_on < sv_max) {
pause_on++;
pause_off--;
digitalWrite(LED_BUILTIN, HIGH);
delay(pause_on);
digitalWrite(LED_BUILTIN, LOW);
delay(pause_off);
}
pause_on=sv_max;
pause_off=sv_min;
// Smooth turn off
while(pause_on > sv_min) {
pause_on--;
pause_off++;
digitalWrite(LED_BUILTIN, HIGH);
delay(pause_on);
digitalWrite(LED_BUILTIN, LOW);
delay(pause_off);
}
}
Fortune cookie: If Helen Keller is alone in a forest and falls, does she make a sound?
Leave a Reply