This assigment will give you the chance to practice using conditional flow control (if statements) and comparison expressions.
The slides that Ms Hogan, the lab instructor, delivered in the lab are visible in the frame to the right. If they are difficult to see, however, you can also download the slides.
In the lab, you will explore the use of conditional flow control via
While doing this, you will:
Answer the following questions together with your partner before coming to the lab.
In this lab, you will make your robot wait for a button to be pressed
(button identified by a number corresponding to one of the constants
It will then turn left if button A was pressed, drive straight if button B
was pressed or turn right if button C was pressed.
Draw a flow chart for the logic required in this program.
Design a simple experiment for measuring how fast your robot turns (in degrees/s) when power (controlled by the same duty cycle values as last week) is applied to its wheels in opposite directions.
Add stub (incomplete) implementations of the
Ensure that the code compiles and can be downloaded to your 3$\pi$ robot, even though it doesn’t yet make the robot move.
As with last week’s driving speed experiment, you must determine how fast your robot turns if you are to complete accurate left and right turns. Use the experiment that you designed in the prelab.
Varying the power applied to the 3$\pi$ robot’s wheels (via duty cycle), measure the turning angle and record it in a table of values together with the duty cycle and time and then plot the angular speed versus duty cycle. Use any convenient units.
Using the data gathered in the experiment above (and last week), write a
complete implementation for the
main function, use conditional flow control (an
to make the robot:
Describe what you observed in this lab. Are there any interesting aspects of the robot’s behaviour that do not fit the code as you wrote it?
Once you have finished writing up your lab activity, submit your log book to the TAs in the lab. If you need extra time to finish the lab, you can submit your log book in the Engineering One Help Centre.