Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import time #, signal, sys
- import traceback
- from Adafruit_ADS1x15 import ADS1x15
- #def signal_handler(signal, frame):
- # print 'You pressed Ctrl+C!'
- # sys.exit(0)
- #signal.signal(signal.SIGINT, signal_handler)
- try:
- ADS1015 = 0x00 # 12-bit ADC
- ADS1115 = 0x01 # 16-bit ADC
- adc = ADS1x15(ic=ADS1115)
- # read channel 0 in single-ended mode, +/- 4.096V, 250 sps:
- volts = adc.readADCSingleEnded(0, 4096, 250) / 1000
- print "%.6f" % (volts)
- except:
- print "*** ERROR ***"
- print repr(traceback.format_exception(exc_type, exc_value,
- exc_traceback))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement