Overview
Make a microwave oven timer, for which the time can be set with a Joystick and displayed through rotating the servo arm to the specified position. Press the Joystick for starting to time, and then the servo will rotate to position 0 according to the set time.
Suitable kits: mCookie202, mCookie302
Module Bill
Module
Other Equipment
- USB cable*1
- Sensor cable*2
- Sensor shell
- Lego or other fixation structure
Module Setup
Assembly
- Install the modules and sensors together:
- Connect the Servo Connector to pin 6/7 of Hub;
- Connect the servo to pin 1 (the below three pins) of servo connector;
- Connect the Joystick to pin A0/A1 of Hub;
- Plug one end of USB cable into the battery base, and connect the other to computer.
Programming
Required Program Blocks
Programming Thought
Before the Joystick is pressed, execute the time setting program repeatedly, and detect the left and right direction to set the time, and rotate the servo arm to the corresponding time. After the time is set, press the Joystick to exit the repeated execution, and the servo arm will rotate to the position where the time is 0 at the speed of 10°/s.
Start to Program
1. Before the Joystick is pressed, adjust the time of the timer.
Variable time is for saving the set time.
If the Joystick is rotated to left, and time is larger than 1, then time will reduce 1, and wait for the Joystick to be released.
If the Joystick is rotated to right, and time is less than 18, then time adds 1, and wait for the Joystick to be released.
Map time from 0-18 to 180-0 (because the anticlockwise end of servo is 180°); set the servo angle to time (when adjust time, the servo arm is the hand of the timer, of which each 10° represents 1s).
2. After the Joystick is pressed, start to time.
Servo rotates to 180°( point 0 of the timer dial plate).
The rotation speed is 10 degrees/s (keeping pace with the timed time).
After timing, clear time.
Test the result
After the program is uploaded, the right and left movement of the Joystick can control the servo to rotate between 0-180° and each 10° represents 1s. After setting, press the Joystick, and the servo will rotate back to 180°at the speed of 10°per second.
Make the time dial plate, and the time between 0~18 corresponds to the rotation range of servo 180°~0°.
Q: Now the timer can show the process of countdown of servo hand, however, after then end of countdown, there is no indication sound, do you know how to improve?
A: We can add a buzzer to it, which can emit “ding” sound at the end of countdown.
Keep other programs unchanged, and just add the program of making the buzzer buzz once at the end of the whole program.
Technical Specification
Related Cases
Q&A
|