diff options
| author | Edvin <[email protected]> | 2025-04-04 11:21:49 +0200 |
|---|---|---|
| committer | Edvin <[email protected]> | 2025-04-04 11:21:49 +0200 |
| commit | 71520eab9c30b4bc666d79b145a0d11d2501131e (patch) | |
| tree | c25fdf7262572c92260c78d6da1d1a48846328c8 | |
| parent | 20b837dab99f9385b04b8c5b581001c8c0b9ea12 (diff) | |
Added control file
| -rw-r--r-- | control.py | 49 | ||||
| -rw-r--r-- | main.py | 8 |
2 files changed, 52 insertions, 5 deletions
diff --git a/control.py b/control.py new file mode 100644 index 0000000..9c10693 --- /dev/null +++ b/control.py @@ -0,0 +1,49 @@ +import bluetooth +import time + +import termios +import tty +import sys + +def get_input() -> str: + + filedescriptors = termios.tcgetattr(sys.stdin) + tty.setcbreak(sys.stdin) + key = sys.stdin.read(1)[0] + termios.tcsetattr(sys.stdin, termios.TCSADRAIN,filedescriptors) + + return key + +pi = "B8:27:EB:D1:A5:A9" + +sock = bluetooth.BluetoothSocket(bluetooth.RFCOMM) +# sock.bind(("", bluetooth.PORT_ANY)) + +# port = sock.getsockname()[1] + +print("Attempting to connect to %s..." % pi) + +sock.connect((pi, 1)) + +print("Connected") + +input = "0" + +while input != "a": + input = get_input() + + if input == "i": + sock.send("11") + elif input == "j": + sock.send("44") + elif input == "l": + sock.send("33") + elif input == "k": + sock.send("22") + else: + sock.send("0") + print(input) + + time.sleep(0.1) + +sock.close() @@ -2,15 +2,15 @@ import RPi.GPIO as GPIO from time import sleep import os +import sys import glob import bluetooth - import re # 3 Pins to communicate with Arduino P1 = 17 P2 = 27 -P3 = 22 +P3 = 23 GPIO.setmode(GPIO.BCM) GPIO.setup(P1, GPIO.OUT) @@ -20,9 +20,7 @@ GPIO.output(P1, False) GPIO.output(P2, False) GPIO.output(P3, False) -target = "D4:D2:52:ED:14:89" - -server_sock = bluetooth.BluetoothSocket( bluetooth.RFCOMM ) +server_sock = bluetooth.BluetoothSocket(bluetooth.RFCOMM) server_sock.bind(("", bluetooth.PORT_ANY)) server_sock.listen(1) |
