-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLED_controller.py
More file actions
33 lines (28 loc) · 1010 Bytes
/
LED_controller.py
File metadata and controls
33 lines (28 loc) · 1010 Bytes
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
import socket#, time, threading
class Bluetooth:
def __init__(self) -> None:
self.arduino = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_STREAM, socket.BTPROTO_RFCOMM)
MAC = '98:D3:21:FC:94:10'
self.arduino.connect((MAC,1))
for i in range(6):
self.send(f'{i}1')
def send(self, msg):
while 1:
self.arduino.send(msg.encode())
if self.arduino.recv(1).decode()=='O':
break
def parking_state_determiner(self, parked_space, parking_state):
if parking_state==0: # Green
self.send(f'{parked_space}1')
elif parking_state>=1: # Red
self.send(f'{parked_space}2')
elif parking_state==0.5: # 깜빡이는 주황
self.send(f'{parked_space}3')
elif parking_state<0: # 깜빡이는 노랑
self.send(f'{parked_space}4')
def test(self):
while 1:
msg=input()
self.send(msg)
# bt=Bluetooth()
# bt.test()