I have a problem in my project. If there is an available parking lot, I want the servo to rotate 90 degrees. I used two sensors, one for the car's entry and one if cars want to leave.
This is my code:
for(int i=0;i<11;i++)
{
if (parks[i]!='0' && parks[i]!=' ')// if there is available park
{
aPark=1;
}
else
{
aPark=0;
}
}
if(analogRead(A0)>200 && aPark==1) // if there is available park and car want to enter
{
myservo.write(90);
delay1=millis()+5000;
}
if(analogRead(A1)>200) // for leaving cars.
{
myservo.write(90);
delay1=millis()+5000;
}
if(delay1<millis())
{
myservo.write(0);
}
When I connect everything and upload the code the servo is not rotating. Is there a problem in my code? Or is it because the sensor is not not detected?