Homework
In this homework, the setup consists of a development board (which has 2 buttons and 4 LEDs), a servo, and a tiny 3D-printed "paddle" attached to the servo. You need to use PWM to control the servo to achieve the desired functionality described below.
Details
There are three types of movements:
Single Move
Double Move (Chargeable)
Special Move (Designed by you)
When there is nothing to do, the servo stays at the Resting Angle on either side. All movements start at one side's Resting Angle and end at the other side's Resting Angle.
Button Arrangement
[Single Move] [Double Move] [Special Move]
A move request is made when the corresponding button is pressed. Notice that there are only 2 buttons on the board, so you guys can decide how to use 2 button to do 3 buttons task.
Single Move
A Single Move needs to move slower than a Double Move.
It starts at 0deg, moves towards the target and ends at 180deg (of the opposite side).
Double Move
It consists of 2 stages. First, it starts at 0 deg and pauses at 40 deg (charging for 2 seconds) until the player releases the Double Move button. (If it is at 180 deg, then it will pause at 140 deg).
While performing the Double Move, you should also use LEDs to indicate the charging status as shown:
1
[0][0][0][0]
0.0~0.499s
2
[1][0][0][0]
0.5~0.999s
3
[1][1][0][0]
1~1.499s
4
[1][1][1][0]
1.5~1.999s
5
[1][1][1][1]
>=2.0s
Note: [0] = LED off, [1]: LED on.
Non-fully-charged Double Move If the player had already released the button while the Double Move was not charged enough, then there wouldn't be any charging or pausing. It will only move for one time. Notice that the Double Move needs to move faster than the Single Move.
A fully-charged Double Move is a Double Move that has been charged for at least 2 seconds. After the button is released. It then moves for 2 times. Notice that the Double Move needs to move faster than the Single Move.
Display
Count and list the number of single, double (list out fully-charged and non-fully-chared), and special moves triggered.
Rules to obey
Single Move can be used at any time.
Every 2 Single Move can unlock a chance to use Double Move.
When 2 Fully-charged Double Move is used, it will auto-triggered Special Move.
Marking scheme [Point(s)]
The task is split into several checkpoints. To get the points of a checkpoint, you need to satisfy the requirements of both that checkpoint and all checkpoints above it.
Display
Having the number of moves count correctly. [0.5*4]
Single Move
Having the servo oscillate from side to side based on button clicks [3]
Double Move
Having two stages at Double Move mode. [3]
Having the correct LED blinking action when holding the button.[4]
Having correct Non-fully-charged Double Move [2]
Having a correct fully-charged Double Move [3]
Bonus
You can design your own Special Move: A Special Move is a custom Move that must be designed by yourself. The only requirements are:
Use the servo. At least not similar to Single and Double Move. [3]
Use some LEDs. [2]
Display a message when the special move is triggered twice. [1]
Last updated