Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Script By Shane B.
- #Website: PIPBOY3000.com -- Contribute to the OpenSource PipBoy 3000 project
- #MIT LICENSE
- #Power Supply of 1.8v is on Header: P9 and PIN Number: 32
- #Hook the negative to Ground pins 1(or 2) on Header: P9
- #Hook signal to PIN Number: 37 on Header: P9
- #RESOURCE TUTORIAL: http://www.gigamegablog.com/2012/01/22/beaglebone-coding-101-using-the-serial-and-analog-pins/
- #Import libraries#
- ##################
- #No Libaries yet
- #Define Functions#
- ##################
- def average(seq, total=0.0):
- num = 0
- for item in seq:
- total += item
- num += 1
- return total / num
- #Define variables#
- ##################
- avg = 0
- inputData = []
- sendOutputcounter = 0
- #Begin Script
- #########################################################################
- while(True):
- #Analog 2
- inputData.append(int(open("/sys/devices/platform/tsc/ain2","rb").read()))
- #Once inputData reaches the length of 100 -- delete the most out of date input value
- if len(inputData) >= 20:
- inputData.pop(0);
- avg = average(inputData)
- avg = avg/1000
- avg = avg*10
- avg = round(avg)
- #Slow down read out
- sendOutputcounter = sendOutputcounter + 1
- if sendOutputcounter > 100:
- sendOutputcounter = 0
- print avg
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement