Advertisement
Guest User

Untitled

a guest
Oct 20th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1. import Adafruit_BBIO.ADC as ADC
  2. import time
  3.  
  4. sensor_pin = 'P9_39'
  5.  
  6. ADC.setup()
  7.  
  8. while True:
  9.     reading = ADC.read(sensor_pin)
  10.     millivolts = reading * 1800  # 1.8V reference = 1800 mV
  11.     temp_c = (millivolts - 500) / 10
  12.     temp_f = (temp_c * 9/5) + 32
  13.     print('mv=%d C=%d F=%d' % (millivolts, temp_c, temp_f))
  14.     time.sleep(1)
  15.    
  16. if True:
  17.     file = open('/home/debian/loveAndTemp.txt', 'w')
  18.     file.write('mv=%d C=%d F=%d ' % (millivolts, temp_c, temp_f)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement