Introduction: Simple Parking Mechanism With Nodemcu

Picture of Simple Parking Mechanism With Nodemcu

Hi, I'm Sridhar Janardhan back with another tutorial.This is a tutorial in NodeMCU series.In today's Instructables I am going to teach you about a simple mechanism of Parking assistance using NodeMCU and ultrasonic sensor.

To get started about NodeMCU please click the link below

Get started with NodeMCU

Let's start collecting the components required for the tutorials.

Step 1: Components Required :

Picture of Components Required :

The components required for this projects are:

  • NodeMCU
  • Breadboard
  • Jumper wires
  • Piezo buzzer
  • LED

Let's get started with the NodeMCU.

Step 2: Connecting Piezo Buzzer to the NodeMCU

Picture of Connecting Piezo Buzzer to the NodeMCU

The piezo buzzer is an alarm use by the electronics hobbyist.It usually got two wire coming out of its enclosure.The Red wire is called as the anode or positive terminal.The black wire is called as negative or cathode terminal.

The piezo buzzer connection is as follows:

  • The red wire is connected to the Digital pin D4 of the NodeMCU.
  • The black wire is connected to the negative railing of the breadboard.

Step 3: Connecting the Ultrasonicsensor

Picture of Connecting the Ultrasonicsensor

The ultrasonic sensor is the specially designed sensor for calculating any obstacles placed in front of the sensor using trig and echo pin.This works on the principle of radar and sonar.

The pin explanation of the ultrasonic sensor are:

  • TRIG pin: This is called as the trigger pin.This pin sends a controls signal to the arduino as soon as it gets trigger by the wave it emitted.
  • ECHO pin: This is a pin that emits the sound wave to the medium to travel.
  • VCC pin: the positive power supply of the sensor
  • GND pin: the ground supply of the sensor

The connection of the Ultrasonic sensor is:

  • TRIG pin: This is connected to the digital pin D1
  • ECHO pin: This pin is connected to the digital pin D2.
  • VCC pin: This is connected to the Positive railing of the Breadboard
  • GND pin: This is connected to the Negative railing of the breadbaord

Step 4: Coding

const int trigPin = 5;

const int echoPin = 4;

const int buzzer = 2;

long duration;

int distance;

int safetyDistance;

void setup() {

pinMode(trigPin, OUTPUT);

pinMode(echoPin, INPUT);

pinMode(buzzer, OUTPUT); Serial.begin(9600);

} void loop() {

digitalWrite(trigPin, LOW);

delayMicroseconds(2);

digitalWrite(trigPin, HIGH);

delayMicroseconds(10);

digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);

distance= duration*0.034/2;

safetyDistance = distance; if (safetyDistance <= 5){

digitalWrite(buzzer, HIGH);

}

else{

digitalWrite(buzzer, LOW);

;}

Serial.print("Distance: ");

Serial.println(distance);

}

Step 5: Output

Comments

About This Instructable

688views

18favorites

License:

Bio: I am an electronic hobbyist on Arduino, Photon, Raspberry Pi and common electronics.A passionate cook.Any assistance in electronics and web development feel free ... More »
More by callmeappytechie:PIR Controlled Buzzer Using ArduinoDIY LampshadeTasty Egg Bonda
Add instructable to: