const int SoundPin = 9; // output pin bleeper – D9 port
int DelaySound = 16; // paus 16 ms
void setup()
{
pinMode(A1, INPUT);
pinMode(A2, INPUT);
}
void loop()
{
int val = analogRead(A1); // read data from pin A1
int val2 = analogRead(A2); // read data from pin A2
tone(SoundPin, val); // play signal val Hz
delay(DelaySound);
for (int i = 0; i < (val2 / 100); i++) {
tone(SoundPin, random(val+1));
delay(DelaySound);
}
noTone(9); // stop sound
}