arduino-fridge-powercontrol/main.py

31 lines
642 B
Python
Raw Normal View History

2023-08-01 23:38:12 +02:00
#!/bin/python3
import serial
import time
ser = serial.Serial('/dev/ttyACM0', baudrate = 9600, timeout = 1)
2023-08-02 01:04:39 +02:00
#time.sleep(3)
2023-08-01 23:38:12 +02:00
2023-08-02 01:04:39 +02:00
while 1:
# { "command": "switch", "arg": "one", "state": "off"}
userInput = input('> ')
ser.write(str(userInput).encode('ascii'))
2023-08-01 23:38:12 +02:00
arduinoData = ser.readline().decode('ascii')
2023-08-02 01:04:39 +02:00
print(arduinoData)
2023-08-01 23:38:12 +02:00
2023-08-02 01:04:39 +02:00
##def getValues():
## #ser.write(b'g')
## lol = "g"
## ser.write(str(lol).encode('ascii'))
## arduinoData = ser.readline().decode('ascii')
## return arduinoData
##
##while 1:
## userInput = input('Get data point?')
##
## if userInput == 'y':
## print(getValues())
2023-08-01 23:38:12 +02:00