int speaker=8;
void setup()
{
pinMode(13,OUTPUT);
pinMode(A3,OUTPUT);
pinMode(A4,INPUT);
pinMode(A5,OUTPUT);
digitalWrite(A3,HIGH);
digitalWrite(A5,LOW);
digitalWrite(8,LOW);
digitalWrite(A4,LOW);
delay(5000);
}
void loop()
{
digitalWrite(A4,LOW);
if(digitalRead(A4)==HIGH)
{
digitalWrite(13,HIGH);
}
if(digitalRead(13)==HIGH)
{
for(int sound = 440; sound < 1000; sound+=25)
{
tone(speaker, sound, 50);
delay(5);
}
for(int sound = 1000; sound > 440; sound-=25)
{
tone(speaker, sound, 50);
delay(5);
}
delay(10);
}
else
{
digitalWrite(8,LOW);
}
}
1 Comments
To extend the battery life, it should be well maintained. Schedule the maintenance of battery every month. lithium battery
ReplyDelete