int pwm_led_pin=5;
int btn1_pin=2;
int btn2_pin=3;
int num1_val;
int num2_val;
int num;
void setup()
{
pinMode(btn1_pin,INPUT);
pinMode(btn2_pin,INPUT);
}
void loop()
{
num1_val=digitalRead(btn1_pin);
num2_val=digitalRead(btn2_pin);
if(num1_val==LOW)
{
delay(50);
while(digitalRead(btn1_pin)==LOW);
analogWrite(pwm_led_pin,num=num+5);
}
if(num2_val==LOW)
{
delay(50);
while(digitalRead(btn2_pin)==LOW);
analogWrite(pwm_led_pin,num=num-5);
}
}
沒有留言:
張貼留言