Carlotta Berry
Published

Lily∞Bot with Raspberry Pico W: Using button to control LED

This video will describe how to use a button on the Lily∞Bot to illuminate a button by using MicroPython

BeginnerFull instructions provided1 hour45
Lily∞Bot with Raspberry Pico W: Using button to control LED

Things used in this project

Hardware components

LilyBot
×1
Resistor 220 ohm
Resistor 220 ohm
×1
Pushbutton Switch, On-On
Pushbutton Switch, On-On
×1
Raspberry Pi Pico W
Raspberry Pi Pico W
×1

Software apps and online services

MicroPython
MicroPython
PlatformIO IDE
PlatformIO IDE

Story

Read more

Schematics

Schematic for Pushbutton on LED with Raspberry PI PIco W

Code

MicroPython code to illuminate and LED using a pushbutton

MicroPython
#buzzer.py CAB 9.14.13
#use button co control LED on Lily∞Bot
#LED on pin 28, button on pin 26
#button connected between 3.3V and pin 26
#https://www.noiresteminist.com/shop


from machine import Pin
from time import sleep 

#define inputs and outputs
ledPin = 28
buttonPin = 26

led = Pin(ledPin, Pin.OUT)
button = Pin(buttonPin, Pin.IN, Pin.PULL_DOWN)
delay = 0.5

print("Button control of LED...")

while True:
    print(button.value())
    if button.value():
        led.toggle()
        sleep(delay)

MircoPython code to control an LED with pushbutton

MicroPython
#buzzer.py CAB 9.14.13
#use button co control LED on Lily∞Bot
#LED on pin 28, button on pin 26
#button connected between 3.3V and pin 26
#https://www.noiresteminist.com/shop


from machine import Pin
from time import sleep 

#define inputs and outputs
ledPin = 28
buttonPin = 26

led = Pin(ledPin, Pin.OUT)
button = Pin(buttonPin, Pin.IN, Pin.PULL_DOWN)
delay = 0.5

print("Button control of LED...")

while True:
    print(button.value())
    if button.value():
        led.toggle()
        sleep(delay)

Lily Bot GIT HUB Repository

All of the CAD files, 3d printer files and code are on the GITHUB

Credits

Carlotta Berry
14 projects • 22 followers
Carlotta Berry is a Professor and Dr. Lawrence J. Giacoletto Endowed Chair for Electrical and Computer Engineering at Rose-Hulman.
Contact

Comments

Please log in or sign up to comment.