How to control led brightness with only one pushbutton and arduino

preview_player
Показать описание
In this video i explain how to control brightness of leds with one single pushbutton aka momentary switch using arduino as follows:
1st time when i press the button the led will light up to 25%
2nd time it will light up to 50%
3rd time it will light up to 75%
4th time it will light up to 100%
5th time the led will turn off

If you want to support my channel click the following link:
Рекомендации по теме
Комментарии
Автор

I tried this code in tinkerCAD it worked. Thank You.

#define front_led_sw 2
#define front_led 3

int front_led_sw_state = 0;
int front_brightness = 0;

void setup() {
Serial.begin(9600);
pinMode (front_led_sw, INPUT);
pinMode (front_led, OUTPUT);
}

void loop() {
analogWrite(front_led, front_brightness);
front_led_sw_state = digitalRead (front_led_sw);
if (front_led_sw_state == HIGH) {
front_brightness = front_brightness + 63;
}
if (front_brightness > 255) {
front_brightness = 0;
analogWrite(front_led, front_brightness);
}
delay (100);
}

markanthonynilo
Автор

Hi, are there any schematics for this project, and if so where can I find them?

poxzy_
Автор

the video is on qiality and i cant see the code can u put it

plamaka
visit shbcf.ru