From 3a7312db28a394053cc178dba7bf3b6fb61abed2 Mon Sep 17 00:00:00 2001 From: Hel Gibbons Date: Mon, 16 Sep 2024 17:29:01 +0100 Subject: [PATCH] Add Jumbo examples --- micropython/examples/pico_jumbo/big_blink.py | 12 ++++++++++ micropython/examples/pico_jumbo/big_button.py | 23 +++++++++++++++++++ micropython/examples/pico_jumbo/big_toggle.py | 22 ++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 micropython/examples/pico_jumbo/big_blink.py create mode 100644 micropython/examples/pico_jumbo/big_button.py create mode 100644 micropython/examples/pico_jumbo/big_toggle.py diff --git a/micropython/examples/pico_jumbo/big_blink.py b/micropython/examples/pico_jumbo/big_blink.py new file mode 100644 index 0000000..4f76f57 --- /dev/null +++ b/micropython/examples/pico_jumbo/big_blink.py @@ -0,0 +1,12 @@ +""" +Wire up a big LED to GP15 (with a resistor) and ground and make it blink! +""" + +import machine +import time + +led_external = machine.Pin(15, machine.Pin.OUT) + +while True: + led_external.toggle() + time.sleep(1) diff --git a/micropython/examples/pico_jumbo/big_button.py b/micropython/examples/pico_jumbo/big_button.py new file mode 100644 index 0000000..c06b135 --- /dev/null +++ b/micropython/examples/pico_jumbo/big_button.py @@ -0,0 +1,23 @@ +""" +Wire a big arcade button up to GP16 and ground and read the state. + +If you have an LED connected to GP15 (with a resistor) and ground the button will turn it on and off. +""" + +import machine +import time + +button = machine.Pin(16, machine.Pin.IN, machine.Pin.PULL_UP) +led_external = machine.Pin(15, machine.Pin.OUT) + +while True: + # as we're using a pull up, the logic state is reversed + if button.value() == 0: + print("Button pushed!") + led_external.on() + time.sleep(0.5) + else: + led_external.off() + print("Button not pushed!") + led_external.off() + time.sleep(0.5) diff --git a/micropython/examples/pico_jumbo/big_toggle.py b/micropython/examples/pico_jumbo/big_toggle.py new file mode 100644 index 0000000..83a00e2 --- /dev/null +++ b/micropython/examples/pico_jumbo/big_toggle.py @@ -0,0 +1,22 @@ +""" +Wire a big toggle switch up to GP16 and ground and read the on/off state. + +If you have an LED connected to GP15 (with a resistor) and ground the button will turn it on and off. +""" + +import machine +import time + +button = machine.Pin(16, machine.Pin.IN, machine.Pin.PULL_UP) +led_external = machine.Pin(15, machine.Pin.OUT) + +while True: + # as we're using a pull up, the logic state is reversed + if button.value() == 0: + print("Toggle on!") + led_external.on() + time.sleep(0.5) + else: + print("Toggle off!") + led_external.off() + time.sleep(0.5)