-
Notifications
You must be signed in to change notification settings - Fork 0
/
pablo_air.ino
57 lines (48 loc) · 1.12 KB
/
pablo_air.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <NewPing.h>
#include <Wire.h>
#include <LiquidCrystal_I2C_Hangul.h>
#include <SoftwareSerial.h>
#define SOL_SENSOR 13
#define TRIGGER_PIN 12
#define ECHO_PIN 11
#define MAX_DISTANCE 200
#define BT_RXD 6
#define BT_TXD 5
SoftwareSerial bluetooth(BT_RXD, BT_TXD);
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);
LiquidCrystal_I2C_Hangul lcd(0x27,16,2);
void setup() {
pinMode(SOL_SENSOR, OUTPUT);
Serial.begin(9600);
bluetooth.begin(9600);
lcd.init();
lcd.backlight();
}
void loop() {
char value;
if (bluetooth.available()){
value = bluetooth.read();
Serial.write(value);
if (value == '1'){
digitalWrite(SOL_SENSOR, HIGH);
lcd.setCursor(3, 0);
lcd.print("Delivered!");
delay(3000);
lcd.clear();
lcd.setCursor(3, 0);
lcd.print("Waiting...");
delay(10000);
lcd.clear();
lcd.setCursor(1, 0);
lcd.print("Not Delivered");
digitalWrite(SOL_SENSOR, LOW);
}
}
if (Serial.available()){
bluetooth.write(Serial.read());
}
lcd.setCursor(1, 0);
lcd.print("Not Delivered");
delay(300);
lcd.clear();
}