Hali hazırda çalışan koduma bluetooth eklemem gerekti yardımcı olabilir misiniz ? Kodu buraya bırakıyorum: #include <Servo.h> //includes the servo library #include <Wire.h> #include <LiquidCrystal_I2C.h> LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); Servo myservo; #define ir_enter 2 #define ir_back 4 #define ir_car1 5 #define ir_car2 6 #define ir_car3 7 #define ir_car4 8 #define ir_car5 9 #define ir_car6 10 int Y1=0, Y2=0, Y3=0, Y4=0, Y5=0, Y6=0; int flag1=0, flag2=0; int yer = 6; void setup(){ Serial.begin(9600); pinMode(ir_car1, INPUT); pinMode(ir_car2, INPUT); pinMode(ir_car3, INPUT); pinMode(ir_car4, INPUT); pinMode(ir_car5, INPUT); pinMode(ir_car6, INPUT); pinMode(ir_enter, INPUT); pinMode(ir_back, INPUT);
myservo.attach(3); myservo.write(90); lcd.begin(20, 4); lcd.setCursor (0,1); lcd.print(" Akilli Otopark "); lcd.setCursor (0,2); lcd.print(" Sistemi "); delay (2000); lcd.clear(); Read_Sensor(); int total = Y1+Y2+Y3+Y4+Y5+Y6; yer = yer-total; } void loop(){ Read_Sensor(); lcd.setCursor (0,0); lcd.print(" Bos Yer: "); lcd.print(yer); lcd.print(" "); lcd.setCursor (0,1); if(Y1==1){lcd.print("Y1:Dolu ");} else{lcd.print("Y1:Bos ");} lcd.setCursor (10,1); if(Y2==1){lcd.print("Y2:Dolu ");} else{lcd.print("Y2:Bos ");} lcd.setCursor (0,2); if(Y3==1){lcd.print("Y3:Dolu ");} else{lcd.print("Y3:Bos ");} lcd.setCursor (10,2); if(Y4==1){lcd.print("Y4:Dolu ");} else{lcd.print("Y4:Bos ");} lcd.setCursor (0,3); if(Y5==1){lcd.print("Y5:Dolu ");} else{lcd.print("Y5:Bos ");} lcd.setCursor (10,3); if(Y6==1){lcd.print("Y6:Dolu ");} else{lcd.print("Y6:Bos ");} if(digitalRead (ir_enter) == 0 && flag1==0){ if(yer>0){flag1=1; if(flag2==0){myservo.write(180); yer = yer-1;} }else{ lcd.setCursor (0,0); lcd.print(" Park Dolu "); delay(1500); } } if(digitalRead (ir_back) == 0 && flag2==0){flag2=1; if(flag1==0){myservo.write(180); yer = yer+1;} } if(flag1==1 && flag2==1){ delay (1000); myservo.write(90); flag1=0, flag2=0; } delay(1); } void Read_Sensor(){ Y1=0, Y2=0, Y3=0, Y4=0, Y5=0, Y6=0; if(digitalRead(ir_car1) == 0){Y1=1;} if(digitalRead(ir_car2) == 0){Y2=1;} if(digitalRead(ir_car3) == 0){Y3=1;} if(digitalRead(ir_car4) == 0){Y4=1;} if(digitalRead(ir_car5) == 0){Y5=1;} if(digitalRead(ir_car6) == 0){Y6=1;} } |
Bildirim