Created
August 4, 2018 16:16
-
-
Save lol97/5f4028439091be898c0014cca8b5ff1a to your computer and use it in GitHub Desktop.
Simple read serial from (Arduino) at COM4 with baudrate 9600
This file contains 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 | |
arduino = serial.Serial('com4',9600) #contohnya ada di COM4 dan baudrate 9600 | |
def doSomething(): | |
data = int(arduino.readline()) | |
print(data) | |
try: | |
while (True): | |
doSomething() | |
except KeyboardInterrupt: | |
arduino.close() | |
print('has disconnected') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment