ArduinoArduino Projects

Car Parking Monitoring System using Arduino and vb.net programming

Description:

Car parking- this tutorial is about the monitoring system for car parking slot using software programming in visual basic.net, also known as vb.net. it’s an infrared sensor project based on Arduino and veb.net. this car parking project uses a minimum of six IR sensors. This parking space is split into two parking spaces, parking1 and parking2. Infrared sensors are used in each parking slot for car detection. The box next to the slot is tested or unchecked depending on the car’s detection. If the box is checked, a car will fill the slot.

This Tutorial covers

  1. Car Parking Sensors installation
  2. Car Parking Circuit diagram
  3. Interfacing
  4. Car parking Arduino programming
  5. Computer
  6. Car Parking application designing and programming finally
  7. Car Parking Testing



Amazon Purchase links:

Infrared sensor:
Arduino Uno:
Mega 2560:
lm7805 Voltage Regulator: 
330-ohm resistors pack: 
female DC power jack socket:
470uf capacitors:
5×7 cm Vero board:
female headers: 
connection wires: 
Super Starter kit:
Jumper Wires:
Bread Board:
12v Adaptor:
PCB plate:
Variable Supply: 
Digital Multimeter:
Vero Board / stripboard:
Soldering iron kit: 
Solder wire: 
Wire Stripper: 
wirecutter: 
PCB drill machine: 

DISCLAIMER:

Please Note: these are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!



Car parking Circuit Diagram:

car parking

This is the complete parking monitoring system circuit diagram. The circuit diagram is designed in version 9.1.0 of the cadsoft eagle. Those are the six sensors for infrared.That infrared sensor is a slot.The Vcc of all the infrared sensors is paired and wired to the 5v of the Arduino. Likewise, the ground pins of all the infrared sensors are linked together and attached to the base of the Arduino. While the infrared sensors are  connected to the out pins

 pin  4

pin  5

pin  6

pin 7

pin  8 and

pin 9


Car parking Arduino Programming:

First I began with the definition of pins for infrared sensors. Then I set up 6 String type variables with sensor1 names to sensor6. Finally,I defined a type String variable cdata to store the entire message.

int parking1_slot1_ir_s = 4; // parking slot1 infrared sensor connected with pin number 4 of arduino
int parking1_slot2_ir_s = 5;
int parking1_slot3_ir_s = 6;

int parking2_slot1_ir_s = 7;
int parking2_slot2_ir_s = 8;
int parking2_slot3_ir_s = 9;

String sensor1; 
String sensor2; 
String sensor3; 
String sensor4; 
String sensor5; 
String sensor6; 


String cdata =""; // complete data, consisting of sensors values

void setup()
{
Serial.begin(9600); 

Turns on serial communication, the buad rate is 9600. 

Set all infrared sensors as input using the pinmode function. Pinmode function is built-in function that requires two arguments such as the input, the pin number or pin name, and the status that can be input or output.


pinMode(parking1_slot1_ir_s, INPUT);
pinMode(parking1_slot2_ir_s, INPUT);
pinMode(parking1_slot3_ir_s, INPUT);

pinMode(parking2_slot1_ir_s, INPUT);
pinMode(parking2_slot2_ir_s, INPUT);
pinMode(parking2_slot3_ir_s, INPUT);


}

void loop()
{

created functions for individual monitoring of each infrared sensor. So these are the six functions calling.



p1slot1(); 
p1slot2();
p1slot3(); 

p2slot1();
p2slot2();
p2slot3();

  
  
   cdata = cdata + sensor1 +"," + sensor2 + ","+ sensor3 +","+ sensor4 + "," + sensor5 + "," + sensor6 +","; // comma will be used a delimeter
   Serial.println(cdata); 
   nodemcu.println(cdata);
   delay(2000); // 2 seconds
   cdata = ""; 
digitalWrite(parking1_slot1_ir_s, HIGH); 
digitalWrite(parking1_slot2_ir_s, HIGH); 
digitalWrite(parking1_slot3_ir_s, HIGH);

digitalWrite(parking2_slot1_ir_s, HIGH);
digitalWrite(parking2_slot2_ir_s, HIGH);
digitalWrite(parking2_slot3_ir_s, HIGH);
}

P1slot1 is a function defined by the user, it has no type of return and it takes no argument as the input.  If there’s a car in front of the sensor that gives digital logic 0, and if there’s no car that gives digital logic 1, then p1s1on or p1s1off is stored.  All other infrared sensors are using the same mechanism.


void p1slot1() // parkng 1 slot1
{
  if( digitalRead(parking1_slot1_ir_s) == LOW) 
  {
  sensor1 = "p1s1on"; // parking1 slot1 
 delay(200); 
  } 
if( digitalRead(parking1_slot1_ir_s) == HIGH)
{
  sensor1 = "p1s1off";  
 delay(200);  
}

}

void p1slot2() // parking 1 slot2
{
  if( digitalRead(parking1_slot2_ir_s) == LOW) 
  {
  sensor2 = "p1s2on"; 
  delay(200); 
  }
if( digitalRead(parking1_slot2_ir_s) == HIGH)  
  {
  sensor2 = "p1s2off";  
 delay(200);
  } 
}


void p1slot3() // parking 1 slot3
{
  if( digitalRead(parking1_slot3_ir_s) == LOW) 
  {
  sensor3 = "p1s3on"; 
  delay(200); 
  }
if( digitalRead(parking1_slot3_ir_s) == HIGH)  
  {
  sensor3 = "p1s3off";  
 delay(200);
  } 
}


// now for parking 2

void p2slot1() // parking 1 slot3
{
  if( digitalRead(parking2_slot1_ir_s) == LOW) 
  {
  sensor4 = "p2s1on"; 
  delay(200); 
  }
if( digitalRead(parking2_slot1_ir_s) == HIGH)  
  {
  sensor4 = "p2s1off";  
 delay(200);
  } 
}


void p2slot2() // parking 1 slot3
{
  if( digitalRead(parking2_slot2_ir_s) == LOW) 
  {
  sensor5 = "p2s2on"; 
  delay(200); 
  }
if( digitalRead(parking2_slot2_ir_s) == HIGH)  
  {
  sensor5 = "p2s2off";  
 delay(200);
  } 
}


void p2slot3() // parking 1 slot3
{
  if( digitalRead(parking2_slot3_ir_s) == LOW) 
  {
  sensor6 = "p2s3on"; 
  delay(200); 
  }
if( digitalRead(parking2_slot3_ir_s) == HIGH)  
  {
  sensor6 = "p2s3off";  
 delay(200);
  } 
}



Car parking Computer application Designing and Programming:

car parking

That’s how it feels like the software program. We use only one serial port and only one-timer in this program. You will have access to the programming when you double-click on the application form.

First I began by importing the.io system and the.io.ports framework.

Then I defined a type integer variable that is value1.


Imports System.IO
Imports System.IO.Ports

Public Class Form1

    Dim value1 As Integer

Double-click the form and add the Serial port code. Currently, the name of the port is com19, the same as that of my laptop. You can check from the device manager the port number of your Arduino. Change  com19  to your laptop or computer’s number.



    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        SerialPort1.Close()
        SerialPort1.PortName = "com19"
        SerialPort1.BaudRate = "9600"
        SerialPort1.DataBits = 8
        SerialPort1.Parity = Parity.None
        SerialPort1.StopBits = StopBits.One
        SerialPort1.Handshake = Handshake.None
        SerialPort1.Encoding = System.Text.Encoding.Default
        SerialPort1.Open()
    End Sub



    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Dim s As String

Defines the form string variable s. This line of code is intended to store the entire message in variable s. This is the message that Arduino receives.


        s = TextBox1.Text + "," + "," + "," + "," + "," + "," + ""

        Dim somestring() As String
        ' Split string based on comma
        somestring = s.Split(New Char() {","c})

        TextBox2.Text = somestring(0)
        TextBox3.Text = somestring(1)
        TextBox4.Text = somestring(2)
        TextBox5.Text = somestring(3)
        TextBox6.Text = somestring(4)
        TextBox7.Text = somestring(5)
        TextBox1.Text = ""

    End Sub

Then these instructions are used to set the comma-like delimiter form in my case, the entire message will be split into six strings with the aid of a comma, then each string will be displayed in its corresponding text box, each text box represents an infrared sensor.

Data received function, I used this function in so many projects, and I explained this in detail already. This function is intended to read the serial port and store the data in the textbox1.



Private Sub DataReceived(ByVal sender As Object, ByVal e As SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
        Try
            Dim mydata As String = ""
            mydata = SerialPort1.ReadExisting()

            If TextBox1.InvokeRequired Then
                TextBox1.Invoke(DirectCast(Sub() TextBox1.Text &= mydata, MethodInvoker))
            Else
                TextBox1.Text &= mydata
            End If
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub



    Private Sub TextBox2_TextChanged(sender As System.Object, e As System.EventArgs) Handles TextBox2.TextChanged
        If InStr(TextBox2.Text, "p1s1on") Then
            chkp1slot1.Checked = True
        End If

        If InStr(TextBox2.Text, "p1s1off") Then
            chkp1slot1.Checked = False
        End If
    End Sub

    Private Sub TextBox3_TextChanged(sender As System.Object, e As System.EventArgs) Handles TextBox3.TextChanged
        If InStr(TextBox3.Text, "p1s2on") Then
            chkp1slot2.Checked = True
        End If

        If InStr(TextBox3.Text, "p1s2off") Then
            chkp1slot2.Checked = False
        End If
    End Sub

    Private Sub TextBox4_TextChanged(sender As System.Object, e As System.EventArgs) Handles TextBox4.TextChanged
        If InStr(TextBox4.Text, "p1s3on") Then
            chkp1slot3.Checked = True
        End If

        If InStr(TextBox4.Text, "p1s3off") Then
            chkp1slot3.Checked = False
        End If
    End Sub

    Private Sub TextBox5_TextChanged(sender As System.Object, e As System.EventArgs) Handles TextBox5.TextChanged
        If InStr(TextBox5.Text, "p2s1on") Then
            chkp2slot1.Checked = True
        End If

        If InStr(TextBox5.Text, "p2s1off") Then
            chkp2slot1.Checked = False
        End If
    End Sub

    Private Sub TextBox6_TextChanged(sender As System.Object, e As System.EventArgs) Handles TextBox6.TextChanged
        If InStr(TextBox6.Text, "p2s2on") Then
            chkp2slot2.Checked = True
        End If

        If InStr(TextBox6.Text, "p2s2off") Then
            chkp2slot2.Checked = False
        End If
    End Sub

    Private Sub TextBox7_TextChanged(sender As System.Object, e As System.EventArgs) Handles TextBox7.TextChanged
        If InStr(TextBox7.Text, "p2s3on") Then
            chkp2slot3.Checked = True
        End If

        If InStr(TextBox7.Text, "p2s3off") Then
            chkp2slot3.Checked = False
        End If
    End Sub
End Class

Watch Video Tutorial

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button