Skip to content

Instantly share code, notes, and snippets.

@natendaben
Created October 4, 2018 15:19
Show Gist options
  • Save natendaben/b397239a372a5b8d992a03e053df8f15 to your computer and use it in GitHub Desktop.
Save natendaben/b397239a372a5b8d992a03e053df8f15 to your computer and use it in GitHub Desktop.
Harry Potter Jingle
int light = 0;
float frequency = 0;
void setup() {
// init serial comm
Serial.begin(9600);
pinMode(8, OUTPUT);
pinMode(A0, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
//set light to be the input from light sensor
light = analogRead(A0);
//print out light value
Serial.println(light);
//map the light sensor values to a frequency value between 100 and 1000
//frequency = map(light, 100, 600, 100, 1000);
if(light<200){
//harry potter riff
tone(8, 440, 300);
delay(500);
tone(8, 620, 300);
delay(800);
tone(8, 740, 300);
delay(300);
tone(8, 690, 300);
delay(500);
tone(8, 620, 300);
delay(1000);
tone(8, 920, 300);
delay(500);
tone(8, 810, 800);
delay(1000);
tone(8, 680, 300);
delay(1500);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment