From 965c21e398159a242f8c8991b4e562e3e23ccbf6 Mon Sep 17 00:00:00 2001 From: Ben Nuttall Date: Sun, 28 Jun 2020 11:59:27 +0100 Subject: [PATCH] Correct ButtonBoard examples --- gpiozero/boards.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/gpiozero/boards.py b/gpiozero/boards.py index 5320ad3a..2ca5ebb2 100644 --- a/gpiozero/boards.py +++ b/gpiozero/boards.py @@ -163,18 +163,21 @@ class ButtonBoard(HoldMixin, CompositeDevice): leds = LEDBoard(2, 3, 4, 5) btns = ButtonBoard(6, 7, 8, 9) - leds.source = btns.values + leds.source = btns + pause() Alternatively you could represent the number of pressed buttons with an :class:`LEDBarGraph`:: from gpiozero import LEDBarGraph, ButtonBoard + from statistics import mean from signal import pause graph = LEDBarGraph(2, 3, 4, 5) - btns = ButtonBoard(6, 7, 8, 9) - graph.source = (sum(value) for value in btn.values) + bb = ButtonBoard(6, 7, 8, 9) + graph.source = (mean(values) for values in bb.values) + pause() :type pins: int or str