LED Brightness Control With Two Button || Arduino Program

preview_player
Показать описание
Comment For More Videos
also suggest me for Videos

Program Code:

#define Button1 1
#define Button2 5
#define LED 9
int ledbrightness = 0;

void setup(){
pinMode(Button1,INPUT);
pinMode(Button1,INPUT);
pinMode(LED,OUTPUT);
digitalWrite(Button1,HIGH);
digitalWrite(Button2,HIGH);
}

void loop(){
if(digitalRead(Button1) == LOW)
{
ledbrightness--;
}
else if(digitalRead(Button2) == LOW)
{
ledbrightness++;
}
ledbrightness = constrain(ledbrightness,0,255);

analogWrite(LED,ledbrightness);
delay(20);
}

--------------------------------------------------------------------------------------
0:00 - Intro

1:00 - Practical

--------------------------------------------------------------------------------------
Рекомендации по теме
Комментарии
Автор

works great. I used the pwm out to a LED driver (dim pin). just an idea if anyone wishes to drive higher power leds.

ryancl
Автор

ye s/w konsa hai sir jo is video me use kr rhe ho?

herryverma
Автор

Pin 1 & 5 should have a 10K pull up resister, Your circuit when the button is push will short Gnd and 5V of Arduino, will blow the Arduino.

roshnivalder
visit shbcf.ru