mirror of
https://github.com/KevinMidboe/python-gpiozero.git
synced 2025-10-29 17:50:37 +00:00
Expand basic example in readme
This commit is contained in:
21
README.rst
21
README.rst
@@ -15,10 +15,25 @@ The latest release is 1.0 released on 16th November 2015.
|
|||||||
About
|
About
|
||||||
=====
|
=====
|
||||||
|
|
||||||
With very little code, you can quickly get going connecting your physical
|
Component interfaces are provided to allow a frictionless way to get started
|
||||||
components together::
|
with physical computing::
|
||||||
|
|
||||||
|
from gpiozero import LED
|
||||||
|
from time import sleep
|
||||||
|
|
||||||
|
led = LED(2)
|
||||||
|
|
||||||
|
while True:
|
||||||
|
led.on()
|
||||||
|
sleep(1)
|
||||||
|
led.off()
|
||||||
|
sleep(1)
|
||||||
|
|
||||||
|
With very little code, you can quickly get going connecting your components
|
||||||
|
together::
|
||||||
|
|
||||||
from gpiozero import LED, Button
|
from gpiozero import LED, Button
|
||||||
|
from signal import pause
|
||||||
|
|
||||||
led = LED(2)
|
led = LED(2)
|
||||||
button = Button(3)
|
button = Button(3)
|
||||||
@@ -26,6 +41,8 @@ components together::
|
|||||||
button.when_pressed = led.on
|
button.when_pressed = led.on
|
||||||
button.when_released = led.off
|
button.when_released = led.off
|
||||||
|
|
||||||
|
pause()
|
||||||
|
|
||||||
The library includes interfaces to many simple everyday components, as well as
|
The library includes interfaces to many simple everyday components, as well as
|
||||||
some more complex things like sensors, analogue-to-digital converters, full
|
some more complex things like sensors, analogue-to-digital converters, full
|
||||||
colour LEDs, robotics kits and more.
|
colour LEDs, robotics kits and more.
|
||||||
|
|||||||
Reference in New Issue
Block a user