forked from lurein/Seats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SeatsSystem.ino
69 lines (59 loc) · 1.38 KB
/
SeatsSystem.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
58
59
60
61
62
63
64
65
66
67
68
69
#include <Wire.h>
#include "rgb_lcd.h"
rgb_lcd lcd;
const int colorR = 255;
const int colorG = 0;
const int colorB = 0;
const int TouchPin=8;
int idNumber = 1;
int sensorValue = 0;
bool seatInUse = false;
void setup()
{
Serial.begin(9600);
pinMode(TouchPin, INPUT);
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
lcd.setRGB(colorR, colorG, colorB);
// Print a message to the LCD.
delay(1000);
}
void sendSerialData(){
Serial.print("sensorID:");
Serial.print(idNumber);
Serial.print(";");
Serial.print("status:");
Serial.print(seatInUse);
}
void updateUI(){
lcd.setCursor(0, 0);
lcd.print("SensorID: ");
lcd.print(idNumber);
lcd.setCursor(0, 1);
lcd.print("Status: ");
if (seatInUse == true){
lcd.print("Taken");
} else {
lcd.print("Open ");
}
}
void loop()
{
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
sensorValue = digitalRead(TouchPin);
if(sensorValue==1)
{
seatInUse = true;
}
else
{
seatInUse = false;
}
updateUI();
sendSerialData();
delay(100);
}
/*********************************************************************************************************
END FILE
*********************************************************************************************************/