Arduino Project

Arduino Automatic Barrier Gate Project with Ultrasonic Sensor V3

Course Introduction

In this lesson, you’ll use a button, a traffic light LED module, and a servo motor with the Arduino to simulate a manual barrier gate system.

When the button is pressed, the red light turns off, the green light turns on, and the gate opens briefly to let a car pass.

Note

If this is your first time working with an Arduino project, we recommend downloading and reviewing the basic materials first.

1.1 Install Arduino IDE(Important)
1.2 Introduction of Arduino IDE

Required Components

In this project, we need the following components:

SN

COMPONENT INTRODUCTION

QUANTITY

PURCHASE LINK

1

Arduino UNO R4 Minima/Arduino UNO R4 WIFI

1

2

USB Type-C cable

1

×

3

Breadboard

1

BUY

4

Wires

Several

5

Button

1

6

LED

4

7

1kΩ resistor

4

8

Digital Servo Motor

1

Wiring

17.webp__PID:67f8317b-5e8f-4977-bb0d-32db888ec8a5

Common Connections:

LED
Connect the LEDs cathode to the negative power bus on the breadboard, and the LEDs anode to a 1kΩ resistor then to 3, 4 on the Arduino.

Digital Servo Motor
Connect to breadboard’s positive power bus.
Connect to breadboard’s negative power bus.
Connect to 11 on the Arduino.

Button
Connect to breadboard’s negative power bus.
Connect to 2 on the Arduino.

Writing the Code

Note
You can copy this code into Arduino IDE.
Don’t forget to select the board(Arduino UNO R4 WIFI) and the correct port before clicking the Upload button.