Skip to content

Instantly share code, notes, and snippets.

@abhijithanilkumar
Last active October 15, 2016 11:56
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 abhijithanilkumar/12721fb81fbbc3e7d8b3aad4039d0c71 to your computer and use it in GitHub Desktop.
Save abhijithanilkumar/12721fb81fbbc3e7d8b3aad4039d0c71 to your computer and use it in GitHub Desktop.
#import pyserial package
import serial
#open the serial port
s = serial.Serial("/dev/ttyACM0") #change port after checking the port in which device is connected
#send probe
s.write('S')
#read ack
s.read()
#create the bytearray
b = bytearray(5) #bytearray of 5 bytes
#manipulate bytes as required
b[1] = 255
b[2] = 0
#send the data to the port
s.write(b[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment