import serial
ser = serial.Serial('COM4', 57600) # open serial port 4
print( '%s is in use.' %(ser.portstr) ) # check to see if port is open
#start Roomba commands
ser.write(b'/x80') # 128: start command
ser.write(b'/x82') # 130: control command
ser.write(b'/x87') # 135: clean command
##ser.write( bytes('/x80', encoding='ascii') ) # 128: start command
##ser.write( bytes('/x82', encoding='ascii') ) # 130: control command
##ser.write( bytes('/x87', encoding='ascii') ) # 135: clean command
ser.close() # close port
import serial
import time
ser = serial.Serial('COM4', 57600)
ser.setRTS(0)
time.sleep(0.1)
ser.setRTS(1)
time.sleep(0.75)
ser.write(b"\x80") # 128: start command
ser.write(b"\x84") # 130: control command
ser.write(b"\x87") # 135: clean command
ser.close()ser.setRTS(0)
time.sleep(0.1)
ser.setRTS(1)
time.sleep(0.75)
Users browsing this forum: No registered users and 127 guests