Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8374

Python • Re: MCP3008 responds only to channel 0/1

$
0
0
Setup your MCP3008 objects once, then read the values repeatedly.

This example sets up all 8 objects then repeatedly reads those 8 values:

Code:

from gpiozero import MCP3008import time,datetime# setup MCP3008 objectsadcs = []for channel in range(0,8):    adcs.append(MCP3008(channel))# display valueswhile True:    print(datetime.datetime.now())    for channel in range(0,8):        print(channel,adcs[channel].value)    print('')    time.sleep(1)

Statistics: Posted by rpiMike — Mon Feb 03, 2025 10:33 pm



Viewing all articles
Browse latest Browse all 8374

Trending Articles