Answered step by step
Verified Expert Solution
Link Copied!

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 D1, a button, connected to D0, and an HC-SR04 connected to D2
Create a Particle project, Lab 5.
Add the HC-SR04 library and study its capabilities intently (look in lib/ HC_SR04/examples and lib/HC_SR04/src).
The source code is just 51 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 24 inches of your loT device (as detected by the HC_SR04 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 dash-delimited triplets. Each triplet has 3 characters:
note (C,D,E,F,G,A or B)
octave (0-8 inclusive) and
duration (E, Q, H, W, short for Eighth, Quarter, Half, and Whole).
For example, C4Q-E5H would play C, on octave 4, for a quarter note, followed by E, on octave 5, 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 built-in 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 = D4; and int buzzer = A5; can make a difference). Use functions where possible to clean up your code.
loop() and setup() should be no longer than about 25-30 lines
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beyond Big Data Using Social MDM To Drive Deep Customer Insight

Authors: Martin Oberhofer, Eberhard Hechler

1st Edition

0133509796, 9780133509793

More Books

Students also viewed these Databases questions