Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python3
- # Mostly from docs.beagleboard.org
- # //////////////////////////////////////
- # // ultrasonicRange.py
- # // Reads the analog value of the sensor.
- # //////////////////////////////////////
- from time import sleep
- import math
- ms = 550 # Time in milliseconds
- pin = "0" # sensor, A0, P9_39
- IIOPATH='/sys/bus/iio/devices/iio:device0/in_voltage'+pin+'_raw'
- f = open(IIOPATH, "r")
- data = ((pow(2, 12) / 3.3) * (1.45) * 0.001)
- volt = (1.45 * (1.8 / pow(2, 12)))
- try:
- while True:
- f.seek(0)
- data = f.read()[:-1]
- print('data = ' + data)
- sleep(ms / 1500)
- f.seek(1)
- volt = f.read()[:-1]
- print('More Data = ' + volt)
- sleep(ms / 1500)
- except KeyboardInterrupt:
- pass
- print("The end...")
Advertisement
Add Comment
Please, Sign In to add comment