Created
December 22, 2015 05:34
-
-
Save silageman/5c3d9d889dfda0e40900 to your computer and use it in GitHub Desktop.
Serial communication to arduino, requires pyserial.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import serial | |
import time | |
import msvcrt | |
from msvcrt import getch | |
byte1 = 50 | |
byte2 = 51 | |
print "***********************************" | |
print "********Opening Serial Port********" | |
print "***********************************" | |
arduino = serial.Serial(2, 9600) | |
time.sleep(3) | |
while(True): | |
key = ord(getch()) | |
if key == 49: | |
print "DEBUG: RELAY INI1 TOGGLED" | |
arduino.write(chr(byte1)) | |
elif key == 50: | |
arduino.write(chr(byte2)) | |
print "DEBUG: RELAY INI2 TOGGLED" | |
elif key == 113: | |
print "**************EXIT***************" | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment