n this Instructable we will simulate an Toll Booth Gate by using a manual Push Button to open and close the gate.
How Does It Work?
When the vehicle comes in front of the gate, the push button is pressed & the gate is opened, this is done by sending a command via microcontroller to the servo to open the gate 90 Degree.
So, we will let’s begin.
Step 1: Components Needed
All That You Need.
Hardware Required
- NodeMCU
- Servo Motor
- Push Button
- Bread Board
- Micro USB cable
- Connecting Wires
Software Required
- Arduino IDE (with ESP8266 Library installed)
Craft Items
- Chart ( any colour )
- Sketch Pen ( any color )
- Empty Box
Step 2: Building Process
The construction part of the craft is been displayed clearly in the images. You can choose any colour (optional). You add your creative ideas to make the Instructable look even more awesome.
Step 3: Circuit Connection
Follow each image for the circuit connections, connections are very simple.
This Instructable is part of a series of Instructables with the NodeMCU, my previous Instructables shows you how to Interfacing servo motor and push button with NodeMCU.
So make sure, you check those circuit connections first before trying out this.
Interfacing Servo Motor with NodeMCU
Control LED Using PushButton with NodeMCU
Step 4: Programming Stage
#include <Servo.h>
Servo servo;const int button = 16;int temp = 0;
void setup() { Serial.begin(9600);
pinMode(button, INPUT); servo.attach(2); //D4 servo.write(0); delay(1000); }
void loop() {temp = digitalRead(button);
if (temp == HIGH) { servo.write(90); Serial.println(" Toll Opened Proceed "); delay(2000); } else { servo.write(0); delay(1000); Serial.println(" Pay to Open Toll "); }}
Download the “Toll_Gate.ino” file and open it up in the Arduino IDE.
Then Create a new sketch and paste the code below in the Arduino IDE and hit Upload. You can tinker with it if you like based on the application, or just use it as it is.
Step 5: OUTPUT
That’s all makers!
I hope you liked this, Stay Tuned for more Projects!
Source: Manual Controlled Toll Gate Using Push Button