mirror of
https://github.com/KevinMidboe/python-gpiozero.git
synced 2025-12-08 20:39:01 +00:00
Fix Notes
Notes now works with embedded code sections, but the spacing is still wrong as is the language selection. Oh well, come back to it later...
This commit is contained in:
@@ -15,13 +15,15 @@ The latest release is **v0.7.0 beta 2** released on 9th October 2015.
|
||||
With very little code, you can quickly get going connecting your physical
|
||||
components together:
|
||||
|
||||
from gpiozero import LED, Button
|
||||
```python
|
||||
from gpiozero import LED, Button
|
||||
|
||||
led = LED(2)
|
||||
button = Button(3)
|
||||
led = LED(2)
|
||||
button = Button(3)
|
||||
|
||||
button.when_pressed = led.on
|
||||
button.when_released = led.off
|
||||
button.when_pressed = led.on
|
||||
button.when_released = led.off
|
||||
```
|
||||
|
||||
The library includes interfaces to many simple everyday components, as well as
|
||||
some more complex things like sensors, analogue-to-digital converters, full
|
||||
|
||||
@@ -45,13 +45,10 @@
|
||||
|
||||
The following program looks like it should turn an LED on:
|
||||
|
||||
```python
|
||||
from gpiozero import led
|
||||
|
||||
led = LED(2)
|
||||
|
||||
led.on()
|
||||
```
|
||||
|
||||
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
|
||||
@@ -60,16 +57,12 @@
|
||||
The following file includes an intentional `pause` to keep the program
|
||||
alive:
|
||||
|
||||
```python
|
||||
from gpiozero import LED
|
||||
from signal import pause
|
||||
|
||||
led = LED(2)
|
||||
|
||||
led.on()
|
||||
|
||||
pause()
|
||||
```
|
||||
|
||||
Now running the program will stay running, leaving the LED on, until it is
|
||||
forced to quit.
|
||||
@@ -77,13 +70,9 @@
|
||||
Similarly, when setting up callbacks on button presses or other input
|
||||
devices, the program needs to be running for the events to be detected:
|
||||
|
||||
```python
|
||||
from gpiozero import Button
|
||||
from signal import pause
|
||||
|
||||
button = Button(2)
|
||||
|
||||
button.when_pressed = lambda: print("Button was pressed!")
|
||||
|
||||
pause()
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user