Include

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

1. #include <Servo.

h> //includes the servo library


2. #include <Wire.h>
3. #include <LiquidCrystal_I2C.h>
4. LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
5.
6. Servo myservo;
7.
8. #define ir_enter 2
9. #define ir_back 4
10.
11. #define ir_car1 5
12. #define ir_car2 6
13. #define ir car3 7
14. #define ir car4 8
15. #define ir car5 9
16. #define ir_car6 10
17.
18. int s1=0, s2=0, 53=0, S4=0, S5=0, S6=0;
19. int flag1=0, flag2=0;
20. int slot =6;
21.
22. Void setup(){
23. Serial.begin(9600);
24.
25. pinMode(ir_car1, INPUT);
26. pinMode(ir_car2, INPUT);
27. pinMode(ir_car3, INPUT);
28. pinMode(ir_car4, INPUT);
29. pinMode(ir_car5, INPUT);
30. pinMode(ir_car6, INPUT);
31.
32. pinMode(ir_enter, INPUT);
33. pinMode(ir_back, INPUT);
34.
35. myservo.attach(3);
36. myservo.write(90);
37.
38. lcd.begin(20, 4);
39. lcd.setCursor(0,1);
40. lcd.print (" Car parking ");
41. lcd.setCursor (0,2);
42. lcd.print (" System ");
43. delay (2000);
44. lcd.clear();
45.
46. Read Sensor ();
47.
48. int total = S1+S2+S3+S4+S5+S6;
49. slot = slot-total;
50. }
51.
52. void loop() {
53.
54. Read Sensor();
55.
56. lcd.setCursor(0,0);
57. lcd.print (" Have Slot: ");
58. lcd.print (slot);
59. lcd.print (" ");
60.
61. lcd.setCursor (0,1);
62. if(S1==1){lcd.print ("S1:Fill ");}
63. else(lcd.print ("S1:Empty");}
64.
65. lcd.setCursor (10,1);
66. if(S2==1){lcd.print("S2:Fill ");}
67. else(lcd.print("S2:Empty");}
68.
69. lcd.setCursor (0,2);
70. if(S3==1){lcd.print("S3:Fill ");}
71. else{lcd.prin("S3:Empty");}
72.
73. lcd.setCursor (10,2);
74. if(S4==1){lcd.print("S4:Fill ");}
75. else{lcd.print("S4:Empty");}
76.
77. lcd.setCursor(0,3);
78. if(S5==1){lcd.print("S5:Fill ");}
79. else{lcd.print("S5:Empty");}
80.
81. lcd.setCursor(10,3);
82. if(S6==1){lcd.print("S6:Fill ");}
83. else{lcd.print("S6:Empty");}

You might also like