April 2018
Beginner
552 pages
13h 58m
English
In the next section, we shall write a script to allow us to gather data that we will then use later on in this chapter.
Create the following script, data_adc.py, as follows:
#!/usr/bin/env python3
#data_adc.py
import wiringpi2
import time
DEBUG=False
LIGHT=0;TEMP=1;EXT=2;POT=3
ADC_CH=[LIGHT,TEMP,EXT,POT]
ADC_ADR=0x48
ADC_CYCLE=0x04
BUS_GAP=0.25
DATANAME=["0:Light","1:Temperature",
"2:External","3:Potentiometer"]
class device: # Constructor: def __init__(self,addr=ADC_ADR): self.NAME = DATANAME self.i2c = wiringpi2.I2C() self.devADC=self.i2c.setup(addr) pwrup = self.i2c.read(self.devADC) ...