Alat dan Bahan
- Sensor Infrared
- Arduino Nano
- Push Button
- LCD 12c
- Breadboard
- Servo
- kabel Jumper
#include
#include
#include
int button = 7;
int sensor = 4;
int ttup = 75;
byte count_p = 0;
bool count = false;
LiquidCrystal _12 lcd(0x27, 16, 2);
Servo myservo;
void setup() {
lcd.begin();
lcd.backlight();
pinMode(sensor, INPUT);
pinMode(button, INPUT_PULLUP);
lcd.setCursor(1, 0);
lcd.print(“Parkir System”);
lcd.setCursor(2, 1);
lcd.print(“Lab Robotika”);
delay(2000);
mvservo.attach(5);
lcd.clear();
}
void loop() {
lcd.setCursor(0, 0);
lcd.print(“Parkir Masuk”);
while(digitalRead(sensor) == LOW){
if(count_p == 5){
lcd.setCursor(1, 1);
lcd.print(“Parkiran Penuh”);
count_p = 5;
delay(1000);
lcd.setCursor(1, 1);
lcd.print(” “);
}
else{
mvservo.write(180);
count = true;
delay(2000);
}
}
myservo.write(tutup);
if(count == true){
count_p ++;
lcd.setCursor(15, 0);
lcd.print(count_p);
count = false
}
if(digitalRead(button) == LOW)(
if(count_p <= 0){
count_p = 0;
}
else
count_p = count_p – 1;
lcd.setCursor(15, 0);
lcd.print(count_p);
delay(650);
}
jika ada kendala bisa diskusi di : 085369237896 (mas fajar)