Merge pull request #126 from bennuttall/analogzero
Add GPIO Zero code example to Analog Zero
This commit is contained in:
commit
32141bb300
@ -38,7 +38,7 @@ install:
|
|||||||
-->
|
-->
|
||||||
#Analog Zero
|
#Analog Zero
|
||||||
|
|
||||||
The RasPiO Analog Zero offers a compact, inexpensive, easy way to add eight analog channels to your Raspberry Pi. RasPiO Analog Zero uses an MCP3008 analog to digital converter. It's an SPI driven, 10-bit, 8-channel ADC.
|
The RasPiO Analog Zero offers a compact, inexpensive, easy way to add eight analogue channels to your Raspberry Pi. RasPiO Analog Zero uses an MCP3008 analog to digital converter. It's an SPI driven, 10-bit, 8-channel ADC.
|
||||||
|
|
||||||
With RasPiO Analog Zero you can:
|
With RasPiO Analog Zero you can:
|
||||||
|
|
||||||
@ -49,3 +49,24 @@ With RasPiO Analog Zero you can:
|
|||||||
* use potentiometer dials for control and display
|
* use potentiometer dials for control and display
|
||||||
* read analog sensors or voltages
|
* read analog sensors or voltages
|
||||||
* make your own embedded device with minimal footprint
|
* make your own embedded device with minimal footprint
|
||||||
|
|
||||||
|
## Code
|
||||||
|
|
||||||
|
```python
|
||||||
|
from gpiozero import MCP3008
|
||||||
|
from time import sleep
|
||||||
|
|
||||||
|
left_pot = MCP3008(0)
|
||||||
|
light = MCP3008(1)
|
||||||
|
temperature = MCP3008(2)
|
||||||
|
right_pot = MCP3008(3)
|
||||||
|
|
||||||
|
while True:
|
||||||
|
print("Left pot value is {}".format(left_pot.value))
|
||||||
|
print("Light sensor value is {}".format(light.value))
|
||||||
|
print("Temperature sensor value is {}".format(temperature.value))
|
||||||
|
print("Right pot value is {}".format(right_pot.value))
|
||||||
|
sleep(1)
|
||||||
|
```
|
||||||
|
|
||||||
|
[GPIO Zero docs: MCP3008](http://gpiozero.readthedocs.io/en/v1.3.1/api_spi.html#gpiozero.MCP3008)
|
||||||
|
Loading…
Reference in New Issue
Block a user