Project 04:An Automatic Door
1. Introduction
I find that there are many interesting inventions in our life. Last time I went to a library with my classmates to borrow a book about learning robots. When we came to the door, it opened automatically.
How magical it is! Today, let’s make a device that can open the door automatically.
Let’s look at the tools first.
2. Components
Kidsuno Mainboard×1 |
PIR Motion Sensor×1 |
270°Servo×1 |
Connection Wire×1 |
USB Cable×1 |
Automatic Door×1 |
3. Function: Rotate the Servo
4. Wiring Diagram
Connect the kidsuno mainboard and computer via a USB cable, and connect the servo to the G, V and D13 interface of the mainboard. The brown wire is connected to G, the red wire is connected to V and the orange wire is connected to D13.
5. Add the Servo Instruction Module
Diagram of the Extension Instruction Block
Add Servo
6. Description of the the Building Blocks
Set the rotation angle of the servo and the delayed time for a specified pin
7. Write the Program
① Drag the instruction block in the Events module to the script area.
② Drag the instruction block in the Pins module to the script area. Since the servo is connected to port G, V and D13 on the mainboard, then change the number 0 to 13 and the input to output.
③Drag the instruction block in the servo module to the script area, then change the number 3 to 13 and the angle number 90 to 93, the delay of 200 remains unchanged.
④ Drag the instruction block in the Control module to the script area.
⑤ Drag the instruction block in the servo module to the script area, then change the number 3 to 13, the angle number 90 to 93 and the delay of 200 to 500.
⑥ Copy the instruction block 3 times in the block and place them into it, then change the angle number 93 to 62, 31 and 0.
⑦ Complete Program
8. Test Result
Click to upload the complete program to the kidsuno mainboard and power up, then the servo will rotate from 93°to 62° to 31° to 0° and rotate from 0° to 31° to 62° to 93°.
9. Assembly Steps
Download the PDF follow the link:Automatic Door Assembly
Or you can Watch the assemble video :
10. Wiring Diagram
Connect the kidsuno mainboard and computer via a USB cable, and connect the servo to the G, V and D13 interface of the mainboard and the PIR motion sensor to the No.1 interface of the mainboard.
The brown wire is connected to G, the red wire is connected to V and the orange wire is connected to D13.
11. Function: Read the PIR Motion Sensor
12. Description of the the Building Blocks
This is the digital signal (0 or 1) for a specified pin.
13. Write the Program
① Drag the instruction block in the Events module to the script area.
② Drag the instruction block in the Serial module to the script area and take the baud rate 9600 as an example.
③ Drag the instruction block in the Pins module to the script area. Since the PIR motion sensor is connected to pin D5 of port 1 on the mainboard, then change the number 0 to 5.
④ Drag the instruction block in the Control module to the script area.
⑤ Drag the instruction block in the Serial module to the script area.
⑥ Drag the instruction block in the Pins module to the script area and put it into the block , then change number 0 to 5.
⑦ Drag the instruction block in the Control module to the script area and change the number 1 to 0.3.
⑧ Complete Program
14. Test Result
Click to upload the complete program to the kidsuno mainboard and power up, then click in the serial monitor area to set the baud rate to 9600. When the PIR motion sensor detects a person or animal moving, the serial monitor prints a digital signal 1, otherwise it prints 0.
15. Function: PIR Motion Sensor Controls the Servo
16. Flow Chart
First, set the angle of the servo to 93°. When the PIR motion sensor detects a person or animal passing by, it will rotate to 0° and it will not rotate if no man or animal is passing by.
17. Write the Program
① Find the instruction blocks
(1)
(2)
(3)
(4)
(5)
(6)
② Complete Program
18. Test Result
Click to upload the complete program to the kidsuno mainboard and power up. When the PIR motion sensor detects a person or animal passing by, it will rotate to 0° and the door will be opened automatically , and it will not rotate if no man or animal is passing by and the door will not be opened.
19. Extended Project
The sample code is below: