but we still need to return a value, so return 0. Return(0) // We looked through everything and didn't find it, Return(frequencies) // Yes! Return the frequency for (i = 0 i < numNotes i++) // Step through the notes we find it, we'll return the frequency for that note. int beats = // Now we'll search through the letters in the array, and if Don't forget that the rests (spaces) need a length as well. A "1" represents a quarter-note, 2 a half-note, etc. A space represents a rest (no tone) char notes = "cdfda ag cdfdg gf " // a space represents a rest // Beats is an array of values for each note and rest. change these values to make different songs! // Length must equal the total number of notes and spaces const int songLength = 18 // Notes is an array of text characters corresponding to the notes You are free to do what you want with this code and schematic.Const int buzzerPin = 9 // We'll set up an array with the notes we want to play If(LEADTK!=0) tone(SPEAKER,FREQUENCIES],LEADLN*INTERVAL-NOTE_SPACING) ĭownload project for Arduino IDE and Fritzing The 5V pin can output more current and the digital pin is used as ground (power consumption is a bit higher, but it won't break your board)Ĭonst uint16_t FREQUENCIES= This was done because the digital pin cannot output quite enough current to drive the relay reliably and the Arduino would freeze quite often while playing the song.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |