Skip to content

Instantly share code, notes, and snippets.

@lol97
Created August 4, 2018 16:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lol97/5f4028439091be898c0014cca8b5ff1a to your computer and use it in GitHub Desktop.
Save lol97/5f4028439091be898c0014cca8b5ff1a to your computer and use it in GitHub Desktop.
Simple read serial from (Arduino) at COM4 with baudrate 9600
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