diff --git a/docs/boards.md b/docs/boards.md index 8cab639..251ba00 100644 --- a/docs/boards.md +++ b/docs/boards.md @@ -1,8 +1,13 @@ # Add-on boards and accessories -These additional interfaces have been provided to group collections of components together for ease of use, and as examples. They are made up of components from the various [input devices](inputs.md) and [output devices](outputs.md) provided by `gpiozero`. See those pages for more information on using components individually. +These additional interfaces have been provided to group collections of +components together for ease of use, and as examples. They are made up of +components from the various [input devices](inputs.md) and +[output devices](outputs.md) provided by `gpiozero`. See those pages for more +information on using components individually. -*Note all GPIO pin numbers use BCM numbering. See the [notes](notes.md) page for more information.* +*Note all GPIO pin numbers use BCM numbering. See the [notes](notes.md) page +for more information.* ## LED Board @@ -137,30 +142,13 @@ Create a `PiTraffic` object: traffic = PiTraffic() ``` -`PiTraffic` provides an identical interface to the generic `TrafficLights` interface, without the need to specify the pin numbers to be used. +`PiTraffic` provides an identical interface to the generic `TrafficLights` +interface, without the need to specify the pin numbers to be used. -To use the PI-TRAFFIC board on another set of pins, just use the generic `TrafficLights` interface. +The interface is identical to the generic `TrafficLights` interface. -### Methods - -| Method | Description | Arguments | -| ------ | ----------- | --------- | -| `on()` | Turn all three LEDs on. | None | -| `off()` | Turn all three LEDs off. | None | -| `toggle()` | Toggle all three LEDs. For each LED, if it's on, turn it off; if it's off, turn it on. | None | -| `blink()` | Make the LEDs turn on and off repeatedly. | `on_time` - The amount of time (in seconds) for the LED to be on each iteration. Default: `1` | -| | | `off_time` - The amount of time (in seconds) for the LED to be off each iteration. Default: `1` | -| | | `n` - The number of iterations. `None` means infinite. Default: `None` | -| | | `background` - If True, start a background thread to continue blinking and return immediately. If False, only return when the blink is finished (warning: the default value of n will result in this method never returning). Default: `True` | - -### Properties - -| Property | Description | Type | -| -------- | ----------- | ---- | -| `red` | Direct access to the red light as a single `LED` object. | LED | -| `amber` | Direct access to the amber light as a single `LED` object. | LED | -| `green` | Direct access to the green light as a single `LED` object. | LED | -| `leds` | A collection of LEDs to access each one individually, or to iterate over them in sequence. | Tuple | +To use the PI-TRAFFIC board on another set of pins, just use the generic +`TrafficLights` interface. ## Fish Dish @@ -229,7 +217,7 @@ Create a `TrafficHat` object by passing in the LED pin numbers by name: traffic = TrafficHat() ``` -The interface is identical to the `FishDish` +The interface is identical to the `FishDish`. ## Robot @@ -243,7 +231,8 @@ Ensure the `Robot` class is imported at the top of the file: from gpiozero import Robot ``` -Create a `Robot` object by passing in the pin numbers of the forward and back pairs for each motor: +Create a `Robot` object by passing in the pin numbers of the forward and back +pairs for each motor: ```python robot = Robot(left=(4, 14), right=(17, 18)) @@ -263,10 +252,22 @@ robot = Robot(left=(4, 14), right=(17, 18)) Generic robot controller with pre-configured pin numbers. -Same interface as generic `Robot` class, without the need to configure pins: +Ensure the `RyanteckRobot` class is imported at the top of the file: ```python from gpiozero import RyanteckRobot +``` +Create a `RyanteckRobot` object: + +```python robot = RyanteckRobot() ``` + +There's no need to configure the pins if you're using the default pins +`(17, 18)` for the left motor and `(22, 23)` for the right motor. + +The interface is identical to the generic `Robot` interface. + +To use the Ryanteck MCB on another set of pins, just use the generic `Robot` +interface. diff --git a/docs/images/button.png b/docs/images/button.png new file mode 100644 index 0000000..0e41466 Binary files /dev/null and b/docs/images/button.png differ diff --git a/docs/images/led.png b/docs/images/led.png new file mode 100644 index 0000000..f59a500 Binary files /dev/null and b/docs/images/led.png differ diff --git a/docs/images/motion-sensor.png b/docs/images/motion-sensor.png new file mode 100644 index 0000000..4ea22e0 Binary files /dev/null and b/docs/images/motion-sensor.png differ diff --git a/docs/inputs.md b/docs/inputs.md index d70c5a5..4938c0d 100644 --- a/docs/inputs.md +++ b/docs/inputs.md @@ -14,7 +14,12 @@ A physical push button or switch. ### Wiring -... +Connect one side of the button to a ground pin, and the other to any GPIO pin: + +![GPIO Button wiring](images/button.png) + +*Alternatively, connect to 3V3 and to a GPIO, and set `pull_up` to `False` when +you create your `Button` object.* ### Code @@ -62,7 +67,10 @@ A PIR (Passive Infra-Red) motion sensor. ### Wiring -... +Connect the pin labelled `VCC` to a 5V pin; connect the one labelled `GND` to +a ground pin; and connect the one labelled `OUT` to any GPIO pin: + +![Motion Sensor wiring](images/motion-sensor.png) ### Code @@ -76,7 +84,7 @@ Create a `MotionSensor` object by passing in the pin number the sensor is connected to: ```python -pir = MotionSensor(3) +pir = MotionSensor(4) ``` ### Methods diff --git a/docs/outputs.md b/docs/outputs.md index 2e66fb3..c412c5c 100644 --- a/docs/outputs.md +++ b/docs/outputs.md @@ -14,7 +14,13 @@ An LED (Light emitting diode) component. ### Wiring -... +Connect the cathode (the short leg) of the LED to a ground pin, and connect the +anode (the longer leg) to any GPIO pin, with a current limiting resistor in +between: + +![LED wiring](images/led.png) + +*Altenatively, use a breadboard to wire up the LED in the same way* ### Code @@ -27,7 +33,7 @@ from gpiozero import LED Create an `LED` object by passing in the pin number the LED is connected to: ```python -led = LED(2) +led = LED(17) ``` ### Methods @@ -55,6 +61,9 @@ A digital Buzzer component. ### Wiring +Connect the negative pin of the buzzer to a ground pin, and connect the +positive side to any GPIO pin: + ... ### Code @@ -65,7 +74,8 @@ Ensure the `Buzzer` class is imported at the top of the file: from gpiozero import Buzzer ``` -Create a `Buzzer` object by passing in the pin number the buzzer is connected to: +Create a `Buzzer` object by passing in the pin number the buzzer is connected +to: ```python buzzer = Buzzer(3) @@ -96,6 +106,10 @@ A full colour LED component (made up of Red, Green and Blue LEDs). ### Wiring +Connect the common cathode (the longest leg) to a ground pin; connect each of +the other legs (representing the red, green and blue components of the LED) to +any GPIO pins, each with a current limiting resistor in between: + ... ### Code @@ -141,6 +155,9 @@ Generic bi-directional motor. ### Wiring +Attach a Motor Controller Board to your Pi, connect a battery pack to the Motor +Controller Board, and connect each side of the motor to any GPIO pin: + ... ### Code diff --git a/docs/recipes.md b/docs/recipes.md index 4f5a798..9449104 100644 --- a/docs/recipes.md +++ b/docs/recipes.md @@ -1,6 +1,8 @@ # Recipes -*Note that reaching the end of a Python file will terminate the process and GPIOs may be reset. Keep your program alive with `signal.pause` - see the [notes](notes.md) page for more information.* +*Note that reaching the end of a Python file will terminate the process and +GPIOs may be reset. Keep your program alive with `signal.pause` - see the +[notes](notes.md) page for more information.* ## LED @@ -174,7 +176,9 @@ while True: led.off() ``` -See [Quick Reaction Game](https://www.raspberrypi.org/learning/quick-reaction-game/) for a full resource. +See +[Quick Reaction Game](https://www.raspberrypi.org/learning/quick-reaction-game/) +for a full resource. ## GPIO Music Box @@ -203,7 +207,8 @@ for button in buttons: button.when_pressed = sound.play ``` -See [GPIO Music Box](https://www.raspberrypi.org/learning/gpio-music-box/) for a full resource. +See [GPIO Music Box](https://www.raspberrypi.org/learning/gpio-music-box/) +for a full resource. ## All on when pressed @@ -446,7 +451,8 @@ while True: ## Full Colour LED controlled by 3 Potentiometers -Wire up three potentiometers (for red, green and blue) and use each of their values to make up the colour of the LED: +Wire up three potentiometers (for red, green and blue) and use each of their +values to make up the colour of the LED: ```python from gpiozero import RGBLED, MCP3008