Question: Exercise 1 Implement the ultrasonic sensor to read the distance between it and an object of your choosing. Pressing the left button changes the display

Exercise 1
Implement the ultrasonic sensor to read the distance between it and an object of your choosing. Pressing the left button changes the display between centimeters and inches.
Task 1: Sonar - Task Period: 1000ms
Use the ultrasonic sensor to measure the distance.Place an object of your choice in front of the sensor to measure its distance
Task 2: Display - Task Period: 1ms
Output the distance obtained from the ultrasonic sensor onto the 4D7S displayThe display should initially show the distance in centimeters.
Task 3: Left Button - Task Period: 200ms
When the left button is pressed, toggle the 4D7S display to show the distance between centimeters and inches
Hint: Declare a variable that holds the distance as a global variable so that different tasks can read its value.
Hint 2: If you encounter "ghosting" effect on your 4D7S, try swapping the order of setting the digit display and calling outNum(). For example, if you set the digit to be displayed first then call outNum(), change it so that you call outNum() first. And vice versa

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!