# # dvm.py # get dvm data # copied by stacy deruiter from Neil Gershenfeld's hello4.mic.py, with small changes # 11/3/05 # import serial ser = serial.Serial('/dev/ttyS0',9600) ser.setDTR() while 1: lo = ord(ser.read()) hi = ord(ser.read()) print '%f'%((lo+256*hi)*4.98/1024.0*3) #lo+256*hi is the raw adc output. #we multiply by Vcc (4.98) and divide by 1024 to get #voltage input to the tiny13. #we multiply by 3 to account for the effect #of the resistors in our circuit, #which reduce input voltage to 1/3 its original value.