mirror of
https://github.com/KevinMidboe/python-gpiozero.git
synced 2026-04-25 08:23:53 +00:00
Add more advanced and remote recipes
This commit is contained in:
@@ -22,11 +22,66 @@ travispy``.
|
||||
Button controlled robot
|
||||
=======================
|
||||
|
||||
Alternatively, use four buttons to program the directions and add a fifth
|
||||
button to process them in turn, like a Bee-Bot or Turtle robot.
|
||||
Alternatively to the examples in the simple recipes, you can use four buttons
|
||||
to program the directions and add a fifth button to process them in turn, like
|
||||
a Bee-Bot or Turtle robot.
|
||||
|
||||
.. literalinclude:: examples/robot_buttons_2.py
|
||||
|
||||
Who's home indicator
|
||||
====================
|
||||
|
||||
Using a number of green-red LED pairs, you can show the status of who's home,
|
||||
according to which IP addresses you can ping successfully. Note that this
|
||||
assumes each person's mobile phone has a reserved IP address on the home router.
|
||||
|
||||
.. literalinclude:: examples/whos_home_leds.py
|
||||
|
||||
Alternatively, using the `STATUS Zero`_ board:
|
||||
|
||||
.. literalinclude:: examples/whos_home_status.py
|
||||
|
||||
Robot controlled by 2 potentiometers
|
||||
====================================
|
||||
|
||||
Use two potentiometers to control the left and right motor speed of a robot:
|
||||
|
||||
.. literalinclude:: examples/robot_pots_1.py
|
||||
|
||||
.. note::
|
||||
|
||||
Please note the example above requires Python 3. In Python 2, :func:`zip`
|
||||
doesn't support lazy evaluation so the script will simply hang.
|
||||
|
||||
To include reverse direction, scale the potentiometer values from 0-1 to -1-1:
|
||||
|
||||
.. literalinclude:: examples/robot_pots_2.py
|
||||
|
||||
BlueDot
|
||||
=======
|
||||
|
||||
BlueDot is a Python library an Android app which allows you to easily add
|
||||
Bluetooth control to your Raspberry Pi project. A simple example to control a
|
||||
LED using the BlueDot app:
|
||||
|
||||
.. literalinclude:: examples/bluedot_led.py
|
||||
|
||||
Note this recipe requires ``bluedot`` and the associated Android app. See the
|
||||
`BlueDot documentation`_ for installation instructions.
|
||||
|
||||
BlueDot robot
|
||||
=============
|
||||
|
||||
You can create a Bluetooth controlled robot which moves forward when the dot is
|
||||
pressed and stops when it is released:
|
||||
|
||||
.. literalinclude:: examples/bluedot_robot_1.py
|
||||
|
||||
Or a more advanced example including controlling the robot's speed and precise
|
||||
direction:
|
||||
|
||||
.. literalinclude:: examples/bluedot_robot_2.py
|
||||
|
||||
Controlling the Pi's own LEDs
|
||||
=============================
|
||||
|
||||
@@ -71,3 +126,5 @@ run the following commands:
|
||||
|
||||
|
||||
.. _travispy: https://travispy.readthedocs.io/
|
||||
.. _STATUS Zero: https://thepihut.com/status
|
||||
.. _BlueDot documentation: http://bluedot.readthedocs.io/en/latest/index.html
|
||||
|
||||
Reference in New Issue
Block a user