close
Attachments you submit will be routed for moderation. If you have an account, please log in first.

Ticket #1949: Pippy Activity serial.py

File Pippy Activity serial.py, 337 bytes (added by tonyforster, 6 years ago)

python block code, serial

Line 
1def myblock(tw, x): # x is the string to transmit   
2   import serial    # you may need to install this library
3   ser=serial.Serial('/dev/ttyUSB0',9600,timeout=1)
4   # serial device on USB, 9600 baud
5   ser.write(str(x)) #send string x
6   st=ser.read(1000) #read up to 1000 bytes
7   tw.lc.heap.append(st) #append to heap
8   ser.close()