Question
(30 pts) Write a code with helper functions that makes 4 sounds with 250 Hz, 500 Hz, 750 Hz, and 1000 Hz of PWM
(30 pts) Write a code with helper functions that makes 4 sounds with 250 Hz, 500 Hz, 750 Hz, and 1000 Hz of PWM frequency by the Cytron board's Buzzer (connected to GP18), respectively, every 1 sec (each sound lasts 0.25 sec) if you press and hold GP20 button. Also, the code should play the same 4 notes in a reverse sequence from highest to lowest frequencies every 1 sec (each sound lasts 0.25 sec) when the GP22 button is pressed. In addition to that, your code should turn on the LED of GP2 while making 250 Hz sound, the LED of GP3 while making 500 Hz sound, the LED of GP4 while making 750 Hz sound, and the LED of GP5 while making 1000 Hz sound. Moreover, nothing should happen if you press both GP20 and GP22 buttons at the same time. You SHOULD define helper functions to be called for making each sound and turning its corresponding LED on. You may need another function to be defined for turning the LEDs off when they are not needed. You can use either time.sleep() or time.ticks_ms(). Name your program playing_4notes.py. Add comments to explain how your code works.
Step by Step Solution
3.27 Rating (133 Votes )
There are 3 Steps involved in it
Step: 1
To achieve this functionality using a Cytron board you can write a Python program that utilizes the ...Get Instant Access with AI-Powered 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