mirror of
https://github.com/KevinMidboe/python-gpiozero.git
synced 2026-02-01 22:26:14 +00:00
Use second level headers on notes page
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
# Notes
|
# Notes
|
||||||
|
|
||||||
1. **BCM pin numbering**
|
## BCM pin numbering
|
||||||
|
|
||||||
This library uses Broadcom (BCM) pin numbering for the GPIO pins, as
|
This library uses Broadcom (BCM) pin numbering for the GPIO pins, as
|
||||||
opposed to BOARD. Unlike the `RPi.GPIO` library, this is not configurable.
|
opposed to BOARD. Unlike the `RPi.GPIO` library, this is not configurable.
|
||||||
@@ -37,18 +37,20 @@
|
|||||||
- *5V = 5 Volts*
|
- *5V = 5 Volts*
|
||||||
- *DNC = Do not connect (special use pins)*
|
- *DNC = Do not connect (special use pins)*
|
||||||
|
|
||||||
2. **Wiring**
|
## Wiring
|
||||||
|
|
||||||
All components must be wired up correctly before using with this library.
|
All components must be wired up correctly before using with this library.
|
||||||
|
|
||||||
3. **Keep your program alive with `signal.pause`**
|
## Keep your program alive with `signal.pause`
|
||||||
|
|
||||||
The following program looks like it should turn an LED on:
|
The following program looks like it should turn an LED on:
|
||||||
|
|
||||||
|
```python
|
||||||
from gpiozero import led
|
from gpiozero import led
|
||||||
|
|
||||||
led = LED(2)
|
led = LED(2)
|
||||||
led.on()
|
led.on()
|
||||||
|
```
|
||||||
|
|
||||||
And it does, if you're using the Python shell, IPython shell or IDLE shell,
|
And it does, if you're using the Python shell, IPython shell or IDLE shell,
|
||||||
but if you saved this program as a Python file and ran it, it would flash
|
but if you saved this program as a Python file and ran it, it would flash
|
||||||
@@ -57,12 +59,14 @@
|
|||||||
The following file includes an intentional `pause` to keep the program
|
The following file includes an intentional `pause` to keep the program
|
||||||
alive:
|
alive:
|
||||||
|
|
||||||
|
```python
|
||||||
from gpiozero import LED
|
from gpiozero import LED
|
||||||
from signal import pause
|
from signal import pause
|
||||||
|
|
||||||
led = LED(2)
|
led = LED(2)
|
||||||
led.on()
|
led.on()
|
||||||
pause()
|
pause()
|
||||||
|
```
|
||||||
|
|
||||||
Now running the program will stay running, leaving the LED on, until it is
|
Now running the program will stay running, leaving the LED on, until it is
|
||||||
forced to quit.
|
forced to quit.
|
||||||
@@ -70,9 +74,11 @@
|
|||||||
Similarly, when setting up callbacks on button presses or other input
|
Similarly, when setting up callbacks on button presses or other input
|
||||||
devices, the program needs to be running for the events to be detected:
|
devices, the program needs to be running for the events to be detected:
|
||||||
|
|
||||||
|
```python
|
||||||
from gpiozero import Button
|
from gpiozero import Button
|
||||||
from signal import pause
|
from signal import pause
|
||||||
|
|
||||||
button = Button(2)
|
button = Button(2)
|
||||||
button.when_pressed = lambda: print("Button was pressed!")
|
button.when_pressed = lambda: print("Button was pressed!")
|
||||||
pause()
|
pause()
|
||||||
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user