Wish your loved one with this Happy Birthday Music with arduino Happy Birthday with arduino code
Not a member? You should Sign up.
Already have an account? Log in.
To make the experience fit your profile, pick a username and tell us what interests you.
RAR Archive - 775.00 bytes - 05/25/2020 at 15:16
int speakerPin = 7; // Buzzer pin int length = 28; // the number of notes char notes[] = "GGAGcB GGAGdc GGxecBA yyecdc"; int beats[] = {2,2,8,8,8,16,1,2,2,8,8,8,16,1,2,2,8,8,8,8,16,1,2,2,8,8,8,16}; int tempo = 200;// time delay between notes void playTone(int tone, int duration) { for (long i = 0; i < duration * 1000L; i += tone * 2) { digitalWrite(speakerPin, HIGH); delayMicroseconds(tone); digitalWrite(speakerPin, LOW); delayMicroseconds(tone); } } void playNote(char note, int duration) { char names[] = {'C', 'D', 'E', 'F', 'G', 'A', 'B', 'c', 'd', 'e', 'f', 'g', 'a', 'b', 'x', 'y' }; int tones[] = { 1915, 1700, 1519, 1432, 1275, 1136, 1014, 956, 834, 765, 593, 468, 346, 224, 655 , 715 }; int SPEE = 5; // play the tone corresponding to the note name for (int i = 0; i < 17; i++) { if (names[i] == note) { int newduration = duration/SPEE; playTone(tones[i], newduration); } } } void setup() { pinMode(speakerPin, OUTPUT); } void loop() { for (int i = 0; i < length; i++) { if (notes[i] == ' ') { delay(beats[i] * tempo); // delay between notes } else { playNote(notes[i], beats[i] * tempo); } // time delay between notes delay(tempo); } }
View project log
Connect positive of speaker to 5v
Connect emitter pin to GND
Connect base pin to 7th pin
Connect collector pin to speaker
View all instructions
Create an account to leave a comment. Already have an account? Log In.
Schupp
Naman Chauhan
Clay Shippy
Fluxly
Become a member to follow this project and never miss any updates
Yes, delete it Cancel
You are about to report the project "Happy Birthday Music Song Using Arduino Uno", please tell us the reason.
Your application has been submitted.
Are you sure you want to remove yourself as a member for this project?
Project owner will be notified upon removal.