Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Help slove TODOS by using thonny def get_user_heart_rate() > int: get_user_heart_rate() asks the console user to enter the heart rate of their heart beat.

Help slove " TODOS" by using thonny
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
def get_user_heart_rate() > int: get_user_heart_rate() asks the console user to enter the heart rate of their heart beat. example: get_user_heart rate() -> 60 # (this is assuming the user enters 60 at the prompt and hits enter) example: get_user heart rate() -> 40 (this is assuming the user enters 40 at the prompt and hits enter) :returns: integer of the time in seconds that the user wishes the LED to be on for user heart rate * TODO: Finish this line return user heart_rate def convert_heart_rate_to_ms_period (heart rate: int) > int: convert_heart_rate_tom period (heart rate) converts the heart rate to period between beats in milliseconds. Since heart rates are given in beats per minute, the beats per second can be calculated by dividing by 60. Then, the period can be found in seconds by flipping the value and multiplying by 1000: hr_bps = heart rate / 60 periods - 1/ hr_bps period ms = 1000 periods param: heart rate: heart rate in beats per minute (integer) example: get_user heart rate() -> 40 # (this is assuming the user enters 40 at the prompt and hits enter) sreturns: integer of the time in seconds that the user wishes the LED to be on for user_heart_rate = TODO: Finish this line return user heart rate def convert_heart_rate_to_ms_period(heart_rate: int) -> int: convert_heart rate to ms_period heart rate) converts the heart rate to period between beats in milliseconds. Since heart rates are given in beats per minute, the beats per second can be calculated by dividing by 60. Then, the period can be found in seconds by flipping the value and multiplying by 1000: hr_bps heart_rate / 60 periods - 1/hr_bps period_ms = 1000 periods param; heart rate: heart rate in beats per minute (integer) returns: period between heart beats in millseconds return 60000 / heart_rate implied ton of the operations above TODO: write the function signature above (what should the parameter data type be?) single_heartbeat(pin_to_led) is the function that will run one cycle of the heartbeat on pin to_led. This single heartbeat will go "lub-DUB" (dim flash followed by a bright flash). This is supposed to mimic the action of the heart, where the smaller atrium contracts first, followed by contraction of the larger ventricle. For an example of this, see https://en.wikipedia.org/wiki/File:Flow_through_the_Heart.webm Assume that the dim flash should be on for 100 ms, and the bright flash should be on for 200 ms. HINT: You will need to write two functions above this function, one for each flash type, that use PWM. Side note: Don't worry about the fact if you happen to be an EMT) that the lub is not actually tied to the atrium with heart sounds, as this is more just a fun kind of visual effect. lub-DUB is actually heart sounds one can hear a result of the ventricle contracting and filling. TODO: make sure to call this in main(), otherwise you will not see anything! return def main() -> None: *** main() is the main function that will call other functions to implement your program. For the C-task of this program, you will implement a program where: 1. a user, upon board reset, will be prompted to input a "heart rate" in beats per minute (60-80 bpm is the standard resting heart rate for more adults). 2. the microcontroller will make a "heartbeat" (lub-DUB, or a dim flash followed by a bright flash) at the heart rate that the user put in. 3. this heartbeat will continue until the user resets the board by hitting the stop sign icon. the above steps will generally be implemented by functions defined before the main() function

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

The Database Relational Model A Retrospective Review And Analysis

Authors: C. J. Date

1st Edition

0201612941, 978-0201612943

More Books

Students also viewed these Databases questions

Question

State the reasons for entity clustering.

Answered: 1 week ago

Question

Describe your ideal working day.

Answered: 1 week ago