giovedì 24 settembre 2015

Semplici effetti sonori con arduino

//================================================================================//
// Noise                                                                          //
// This code generates random tones for DURATION between +300 and -300 of the     //
// FREQency specified.                                                            //
//================================================================================//
void noise(int freq, int duration)  {
int low = freq - 300;
int high = freq + 300;
unsigned long time = millis();
while(millis() - time <= duration)  {
tone(7, random(low, high));
}
noTone(7);
}
//================================================================================//

Nessun commento:

Posta un commento