A collection of examples for using the gpiozero library for reading sensors and activating actuators
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

14 lines
425 B

4 years ago
from gpiozero import MCP3008
from time import sleep
#remember to enable SPI in raspi-config > interfaces before you run this the first time
#How to wire the MCP3008: https://learn.adafruit.com/raspberry-pi-analog-to-digital-converters/mcp3008
#gpiozero documentation about MCP3008: https://gpiozero.readthedocs.io/en/stable/api_spi.html
ldr = MCP3008(channel=0, device=0)
while True:
print(ldr.value)
sleep(0.01)