Reading Digital Inputs | Raspberry Pi Pico Workshop: Chapter 2.4

preview_player
Показать описание

In this video, we will learn how to use *digital inputs* on the *Pico* through 2 examples. In the first, we will be reading the state of a *button*, and in the second we will *control* an *LED* with a button. We will also look at the relationship between *voltage* and digital input state.

🔧🔨🧰 Hardware featured in this guide:
*Pico:*
*LED Pack:*
*Breadboard:*
*Jumper Wires:*
*Button Pack:*
*Potentiometer:*

0:00 Digital Inputs on the Pico
0:49 Digital Input Example Code
4:07 Exploring Pin Voltage and Digital Reading
5:16 Digital Inputs
6:56 Button and LED example
8:27 What can you do with this?
9:45 3 Key Takeaways

🌏🦘 *Core Electronics* is located in the heart of Newcastle, Australia. We're powered by makers, for makers. Drop by if you are looking for:

The following trademarks are owned by *Core Electronics Pty Ltd:*

"Core Electronics" and the Core Electronics logo
"Makerverse" and the Makerverse logo
"PiicoDev" and the PiicoDev logo
"GlowBit" and the GlowBit logo
Рекомендации по теме
Комментарии
Автор

Hey all, in the first part of the first demo we have the line button = pin(15, Pin.IN, Pin.PULL_DOWN). We goofed this but fixed it later in the video. Whenever we call the function Pin it should start with a capital letter (we have pin with a lowercase in the beginning).

Core-Electronics
Автор

please recommend books to learn micropython for raspberry pi pico.

AlexHerman-qjpi
Автор

Hey! you fixed that typo of the first pin to Pin off camera! I saw that! (kept getting an error and was waiting to see if yours got it too)

mimivrc
Автор

2:15 Just a minor note, a typo in a variable name doesn't yield a syntax error, since the code structure (syntax) itself is correct. In this case it's name error (as stated by the error class NameError). The interpreter understands what you're trying to do, but it doesn't understand what you're referring to.

In any case, thanks a lot for the great material, amazing course.

tryura
Автор

led.value(1) aka led.on(), led.value(0) aka led.off(), advanced demo :: x = 55
led.value( 1 if x > 0 else 0 ) # will light up, or even shorter led.value( x > 0 ) # True is 1, False is 0
no need for multiple lines like
if x: # any value that is not 0, not None or not an empty is True
led.on() # or led.value(1)
else:
led.off() # or led.value(0)

jyvben