float sinVal;
int toneVal;
int button = 3;
int buzzer = 8;
void setup() {
pinMode(button, INPUT_PULLUP);
pinMode(buzzer, OUTPUT);
// put your setup code here, to run once:
}
void loop() {
int button1 = digitalRead(button);
if(button1 == HIGH){
for(int x = 0; x<180; x++){
sinVal= (sin(x*(3.1412/180)));
toneVal= 2000+(int(sinVal*1000));
tone(8, toneVal);
delay(2);
}
}
// put your main code here, to run repeatedly:
else
if(button1 == LOW){
digitalWrite(buzzer, HIGH);
sinVal = 0;
toneVal = 0;
tone(8, toneVal);
}
}