// ,passive buzzer play around with d and s buzzer on d2
void setup() {
// put your setup code here, to run once:
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, INPUT_PULLUP);
}
int tog = 0;
void loop() {
// put your main code here, to run repeatedly:
int d = 10;
int s = 5;
if(digitalRead(4)==LOW){
if(tog == 0){
tog = 1;
digitalWrite(3, HIGH);
}else{
tog = 0;
digitalWrite(3, LOW);
}
delay(d*50);
}
if(tog == 1){
for(int f = 600; f < 1200; f+=s){
tone(2,f);
delay(d);
}
for(int f = 1200; f > 600; f-=s){
tone(2,f);
delay(d);
}
noTone(2);
}
}