Hello,
I am running a python3 program that has to do w/ SPI on the BBBW and the Adafruit_BBIO library. I set up my pins, set up the source, and ran the code.
…
I got back some odd numbers that mean nothing. I was following some ideas from Rpi stuff and transferring data to the BBBW via the Adafruit_BBIO library to make things work.
So…
`
from LDRII import MCP3008 #I found this source online and I cannot figure out what site I found it at currently. Anyway…if this is your source, say so! I will give you credit.
adc = MCP3008()
print(adc.read(channel = 0))
`
is the source I run from this library…
`
from Adafruit_BBIO.SPI import SPI
SPI0_CS0 = “P9_17”
SPI0_D0 = “P9_21”
SPI0_D1 = “P9_18”
SPI0_SCLK = “P9_22”
spi = SPI(1, 0)
class MCP3008:
def init(self, bus = 0, device = 0):
self.bus, self.device = bus, device
self.spi = SPI()
self.open()
def open(self):
self.spi.open(self.bus, self.device)
def read(self, channel = 0):
adc = self.spi.xfer2([1, (8 + channel) << 4, 0])
data = ((adc[1] & 3) << 8) + adc[2]
return data
def close(self):
self.spi.close()
`
Now, what I figured would happen, happened and I cannot explain it (yet).
Do you see my error in computation here?
Seth
P.S. I have to use config-pin to set up the pins for use but I receive variable numerical values every time I run the source from above. Please send some advice if you have time.