Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Instructions: Build a circuit that contains a buzzer, connected to D 1 , a button, connected to D 0 , and an HC - SR
Instructions:
Build a circuit that contains a buzzer, connected to D a button, connected to D and an HCSR connected to D
Create a Particle project, Lab
Add the HCSR library and study its capabilities intently look in lib HCSRexamples and libHCSRsrc
The source code is just lines long, read it over
In that project, define a function, playlt that will accept a String, and play that String representing a melody deets below unless someone is within inches of your loT device as detected by the HCSR library
Define a variable, beatsPerMinute, and corresponding getter and setter functions. A beat is usually a quarter note, so the value of beatsPerMinute will determine the number of quarter notes per minute.
Create a web page with two forms the first will include a text field for beatsPerMinute, the second will play the indicated melody.
Melody Format:
A melody consists of one or more dashdelimited triplets. Each triplet has characters:
note CDEFGA or B
octave inclusive and
duration E Q H W short for Eighth, Quarter, Half, and Whole
For example, CQEH would play C on octave for a quarter note, followed by E on octave for a half note. In between notes, include a brief pause during which no sound is heard.
Requirements: Obviously, the project needs to function properly in order to get credit, but you will also be graded on the quality of your code.
Do not use builtin libraries to play the notes, only analogWrite
Use functions as appropriate
Avoid hardcoding, to make your code as comprehensible as possible even something simple like int coldLED D; and int buzzer A; can make a difference Use functions where possible to clean up your code.
loop and setup should be no longer than about lines
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started