Arduino - car parking lot using arduino- program logical doubt

Status
Not open for further replies.

geo_18

Newbie level 5
Joined
Sep 22, 2013
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
59
This program is just to control a car parking lot using ping sensors and servo motor.
Servo motor acts as the gate. Here when the first ping sensor detects the car the gate opens and when the car crosses the second ping sensor the gate closes and correspondingly the number of parking lots left are shown on a lcd screen. That is how the program is programmed. But now i have encountered a situation where the car cuts the first ping sensor and the gate opens, but the car decides not to enter the parking lot and goes back. So I want my gate to close. Could anyone suggest me the correct logical modification to this program to handle such a situation.

This is the program :

 

It sounds like you need to have 4 sensor conditions:Condtion 0: Neither sensor active. Condition 1: in front of gate(sensor 1 active). Condition 2: past gate(sensor 1 and sensor 2 both active). Wait. Condition 3: Moved forward(sensor 2 only active).

The states would be something like:

State 1: (Idle state)
Close Gate
If Condition 1==> State 2
State 2:
Open gate
If Condition 2 ==> State 3
Elsif Condition 1==> State 4
State 3:
Close Gate
If Condition 4==> State 1
State 4:
If Condition 0 ==> State 1


Something like that...
 
Last edited:

Actually I did not get the solution properly. Could you be more specific.
Anyway I am really thankful for your reply.
 

I thought I was pretty specific.

Ok, you've got 4 possible states of the car's position
1: Not there (no sensor activated)
2: In front of the gate (Only sensor 1 active)
3: Past the gate, but not past the 2nd sensor (both sensors active)
4: Passing the 2nd sensor. (only the 2nd sensor active)

In state 1 you can move to state 2 if sensor 1 is detected. Gate is closed.
In state 2 you can move to either state 3 (both sensors active) or state 1 (no sensor active). Car is in front of gate. Gate is opened.
In state 3 you can move to state 4 if only sensor 2 is active; state 2 if only sensor 1 is active. Car has moved forward past gate.
In state 4 you can move to state 0 when no sensors are active. Car has moved farther beyond gate.

Hope that helps.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…