Last active
August 29, 2015 14:06
-
-
Save m4rk3r/5f0039941f152434f46f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "pitches.h" | |
int pitch = NOTE_C8; | |
float notes[] = { 18, 20, 25, 32 }; | |
int notecount = 4; | |
int couplet = 3; | |
int darkness = 50; | |
void setup(){ | |
Serial.begin(9600); | |
} | |
void loop(){ | |
int reading = analogRead(0); | |
Serial.println(reading); | |
if(reading <= darkness){ | |
for(int repeat=0; repeat < couplet; repeat++){ | |
for(int idx=0; idx < notecount; idx++){ | |
int noteDuration = notes[idx]; | |
tone(8, pitch); | |
delay(noteDuration); | |
// stop the tone playing: | |
noTone(8); | |
delay(noteDuration); | |
} | |
// delay after couplet | |
delay(random(350,600)); | |
} | |
// delay after repeating song | |
delay(random(200,300)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment