Browse Source

Update 'analogSensor.py'

main
rra 4 years ago
parent
commit
4f896fab89
  1. 20
      analogSensor.py

20
analogSensor.py

@ -1,10 +1,24 @@
from gpiozero import MCP3008
from time import sleep
#remember to enable SPI in raspi-config > interfaces before you run this the first time
##################
# Before you start #
##################
# remember to enable SPI in raspi-config > interfaces before you run this the first time
# see method one here: https://www.raspberrypi-spy.co.uk/2014/08/enabling-the-spi-interface-on-the-raspberry-pi/
#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
#################
# Wiring 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
#################
# Wiring sensors #
#################
# This code assumes you have an LDR on channel 0 of the mcp3008
# You can wire one up like so: https://maker.pro/raspberry-pi/tutorial/how-to-read-an-ldr-sensor-with-raspberry-pi-using-mcp3008
# However, you could use any other analog sensor (up to eight)
ldr = MCP3008(channel=0, device=0)

Loading…
Cancel
Save