A while back I wrote about the BusPirate. You can view that post here. In it, I mention an Arduino sketch called the “MiniPirate” which allows you to try some of the functions of the BusPirate on an Arduino.
Over time, I have found that sketch to be very useful. You can use it to test/debug and prototype different electronic components. Even more than that, it is fun and an easy way to engage students to interact with the world around them.
Always have an Arduino around with the sketch loaded in so it will be as handy as the BusPirate. Then just plug it into your PC USB port and you are ready to go. No need to load up the Arduino IDE as I have a handy Python script (shown below) to interact with the sketch.
A Linux Python script to run the Arduino MiniPirate Sketch:
#!/bin/env python # # Source code from earl@microcontrollerelectronics.com # import serial,sys,glob,select dev = '/dev/ttyACM*' scan = glob.glob(dev) if (len(scan) == 0): dev = '/dev/ttyUSB*' scan = glob.glob(dev) if (len(scan) == 0): print "Unable to find any ports scanning for " + dev sys.exit() serport = scan[0] if (len(sys.argv) > 1): rate = sys.argv[1] else: rate = "57600" ser = serial.Serial(port=serport,baudrate=rate,parity=serial.PARITY_NONE,stopbits=serial.STOPBITS_ONE,bytesize=serial.EIGHTBITS,timeout=1) print("connected to: " + ser.portstr) #ser.write("h\x0D") while True: line = ser.readline() if line: print (line), while sys.stdin in select.select([sys.stdin], [], [], 0)[0]: line = sys.stdin.readline() ser.write(line[:-1]) ser.close()
The Python script uses non-blocking console I/O to interact with the user. It needs the PySerial package which can be found here in case your Python install does not have it.
The MiniPirate sketch can be downloaded from here. Instructions on its use can be found here. Any questions? Leave a comment.
Recent Comments