Code: Select all
def real_program(self):
GPIO.setup(24, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
GPIO.add_event_detect(24, GPIO.RISING, callback= break, bouncetime=200)
adc = Adafruit_ADS1x15.ADS1015()
GAIN = 1
t = []
values = []
str_time = time.time()
try:
while true:
val = adc.read_adc(0, gain=GAIN)
t.append(time.time() - str_time)
values.append(val)
except KeyboardInterrupt:
GPIO.cleanup() # clean up GPIO on CTRL+C exit
GPIO.cleanup()
x = [round (float(b*1000.0) ,2) for b in t]
y = [float (c*0.002) for c in values]
z = [round(float(d*48.484) ,2) for d in y]
return x,y,z