Robotics 8 | AY '22-'23
Lights &
Week 4
SOUND
Programming Piezo to play a note with Integration of LEDs
Re cap
last week
Playing musical note with piezo
- Physics of sound
- tone() function's 3rd parameter
- sound [note] = frequency
- note types to duration
- Identifying letter note in the music sheet
- programming piezo to play specific note
Activity
Let’s try to convert these note into a program - let’s recall the process that we did:
- Identify the letter notes in the music sheet
- Identify its equivalent frequencies
- Identify the note type
- Identify its equivalent duration
- Multiply the duration to 1.3 to come up with the value for the delay
- Input the values in the tone() function and delay() function
Do this!
warm up
+ link
activity
Next once we have completed the circuit [take note of your pin connections for programming] – we will now program the 4 notes with the details that we have - frequencies, durations and delay values.
.We will write the code for tone() functions inside the void setup() instead as we want the Arduino to play the melody once
LED + Piezo
Circuit
+ CODE
do this!
Modify the code | Add LED
Modify the program and let the RED led blink when a note is playing - note that LED should not light up when the piezo is not playing any sound.
modify
Analyze
With the modified code - how did LED blink? Discuss the sequence in which the codes flow and work.
Continue...
Lights and Sounds
Continue to complete the melody by converting the notes to frequencies, and duration [dont forget to compute the delay value] and add different light sequence in the program
PT#1
+ table
+ melody
Lights and Sound
Morris Bana
Created on May 2, 2023
Start designing with a free template
Discover more than 1500 professional designs like these:
View
Higher Education Presentation
View
Psychedelic Presentation
View
Vaporwave presentation
View
Geniaflix Presentation
View
Vintage Mosaic Presentation
View
Modern Zen Presentation
View
Newspaper Presentation
Explore all templates
Transcript
Robotics 8 | AY '22-'23
Lights &
Week 4
SOUND
Programming Piezo to play a note with Integration of LEDs
Re cap
last week
Playing musical note with piezo
Activity
Let’s try to convert these note into a program - let’s recall the process that we did:
Do this!
warm up
+ link
activity
Next once we have completed the circuit [take note of your pin connections for programming] – we will now program the 4 notes with the details that we have - frequencies, durations and delay values.
.We will write the code for tone() functions inside the void setup() instead as we want the Arduino to play the melody once
LED + Piezo
Circuit
+ CODE
do this!
Modify the code | Add LED
Modify the program and let the RED led blink when a note is playing - note that LED should not light up when the piezo is not playing any sound.
modify
Analyze
With the modified code - how did LED blink? Discuss the sequence in which the codes flow and work.
Continue...
Lights and Sounds
Continue to complete the melody by converting the notes to frequencies, and duration [dont forget to compute the delay value] and add different light sequence in the program
PT#1
+ table
+ melody