Skip to content

Instantly share code, notes, and snippets.

@samilkorkmaz
Last active December 17, 2019 18:44
Show Gist options
  • Save samilkorkmaz/e365cf060832ad7fe81a5835b208166a to your computer and use it in GitHub Desktop.
Save samilkorkmaz/e365cf060832ad7fe81a5835b208166a to your computer and use it in GitHub Desktop.
rodeoSiren
//Reference: https://www.arduino.cc/en/Tutorial/ToneMelody?from=Tutorial.Tone
#define NOTE_C4 262
#define NOTE_F4 349
#define buzzerPin 3
void setup() {
pinMode(buzzerPin, OUTPUT);
pinMode(LED_BUILTIN, OUTPUT);
}
void play(unsigned int freq_Hz, unsigned long duration_ms) {
tone(buzzerPin, freq_Hz, duration_ms);
delay(duration_ms*1.10);
}
void loop() {
digitalWrite(LED_BUILTIN, HIGH);
play(NOTE_F4, 500);
digitalWrite(LED_BUILTIN, LOW);
play(NOTE_C4, 500);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment