int buzzerPin = 9;
float sinVal; // sine value
int toneVal; // sound frequency
void setup() {
// put your setup code here, to run once:
pinMode(buzzerPin, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
for(int x = 0; x < 360; x++){
sinVal = sin(x*(PI/180)); // get sine of x
toneVal = 2000 + sinVal * 500; // sound frequency according to sine value
tone(buzzerPin, toneVal); // output sound frequency
delay(1);
}
}