Project 06:Barrier Gate

Img

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

Img

Img

Img

Kidsuno Mainboard×1

Obstacle Avoidance Sensor×1

270°Servo×1

Img

Img

Img

Connection Wire×1

USB Cable×1

Barrier Gate×1

Img

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

Img

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.

Img

6. Write the Program

① Drag the instruction block Img in the Events module to the script area.

Img

② Drag the instruction block Img in the Serial module to the script area and take the baud rate 9600 as an example.

Img

③ Drag the instruction blockImg 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.

Img

④ Drag the instruction block Img in the Control module to the script area.

Img

⑤ Drag the instruction block Img in the Serial module to the script area.

Img

⑥ Drag the instruction block Img in the Pins module to the script area and put it into the blockImg, then change the number 0 to 5.

Img

⑦ Drag the instruction block Img in the Control module to the script area and change the number 1 to 0.3.

Img

⑧ Complete Program

Img

7. Test Result

ClickImg to upload the complete program to the kidsuno mainboard and power up, then click Img 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.

Img

Img

8. Function: Obstacle Avoidance Sensor Controls the Servo

Img

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.

Img

10. Add the Servo Instruction Module

Img

11. Write the Program

① Find the instruction blocks

(1)Img

(2)Img

(3)Img

(4)Img

(5)Img

(6)Img

(7)Img

(8) Img

② Complete Program

Img

12. Test Result

ClickImg 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.

Img