#include <Bounce2.h>
int led=3;
int state=LOW;
int buzzer=9;
Bounce btn = Bounce(2,50);
void setup()
{
pinMode(2,INPUT);
pinMode(9,OUTPUT);
pinMode(3,OUTPUT);
}
void loop()
{
if(btn.update()==true && btn.read()==HIGH)
{
tone(buzzer,1480,200);
if(state==LOW)
{
state=HIGH;
}
else
{
state=LOW;
}
digitalWrite(led,state);
}
}
没有评论:
发表评论