Project 06:Barrier Gate
1. Introduction
Last time my dad drove me to eat seafood, however, when our car came to the barrier gate of the parking lot, the gate rose automatically, and when the car passed, it fell automatically.
Maybe you’re as curious about this device as I am, let’s make a barrier gate can automatically rise and fall together!
The following are the tools we need.
2. Components
Kidsuno Mainboard×1 |
Obstacle Avoidance Sensor×1 |
270°Servo×1 |
Connection Wire×1 |
USB Cable×1 |
Barrier Gate×1 |
3. Assembly Steps
Download the PDF follow the link:Barrier Gate Assembly
Or you can Watch the assemble video :
4. Function: Read the Obstacle Avoidance Sensor
5. 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 obstacle avoidance sensor to the No.1 interface of the mainboard.
Note: The brown wire is connected to G, the red wire is connected to V and the orange wire is connected to D13.
6. 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 obstacle avoidance 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 the 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
7. 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 obstacle avoidance sensor detects an obstacle, the serial monitor will print a digital signal 0, otherwise, it will print 1.
8. Function: Obstacle Avoidance Sensor Controls the Servo
9. Flow Chart
First, set the angle of the servo to 32°. When the obstacle avoidance sensor detects an obstacle, the servo will rotate to 100°, otherwise it will not rotate.
10. Add the Servo Instruction Module
11. Write the Program
① Find the instruction blocks
(1)
(2)
(3)
(4)
(5)
(6)
(7)
(8)
② Complete Program
12. Test Result
Click to upload the complete program to the kidsuno mainboard and power up. When the obstacle avoidance sensor detects an obstacle, the servo will rotate to 100° and the barrier gate will open, otherwise it will not rotate and the barrier gate will close.