Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using programming language C++ and IF statements, can you help generate a code to make this work on a MBED? Thank you! For this assignment

image text in transcribed
Using programming language C++ and IF statements, can you help generate a code to make this work on a MBED? Thank you!
For this assignment you will use the mbed with its Digitalin and PwmOut objects to implement a simple musical instrument. Connect 4 pushbutton switches in active-high configuration to pins p5 through p8 of the mbed. Connect the piezo transducer between pin p21 and GND Pressing a switch should generate a particular musical note on the piezo transducer (at maximum volume) and light up a particular LED (at full brightness). When the switch is released, the note should fade out over a 0.1 second period with both the brightness of the LED and the volume of the piezo transducer perceptibly diminishing over time rather than immediately stopping. The following table shows the frequencies for the notes as well as the LED that should light up for each note Switch pin Frequency LED (Hz) 1046 1175 1319 1397 LED1 LED2 LED3 LED4 p6 p8 The piezo transducer will output a note at maximum value when the PWM duty cycle is set to 50% and at reduced volume as the duty cycle approaches either 0% or 100%. Note however that this extremely non- linear, so differences in volume will only be noticeable at the extremes (approximately 096-396 or 97% 100%)

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

More Books

Students also viewed these Databases questions