Raspberry Pi Pico¶
Key Links¶
MicroPython examples¶
Flash a LED¶
Connect an LED (ground) to pin 3 (GND), and via a 220 ohm resistor to pin 5 (GP3)
from machine import Pin
import utime
LED = Pin(3,Pin.OUT) # The Pin function takes the GP value
while True:
LED.toggle()
utime.sleep(.1)
Flash the onboard LED¶
Note the Pico and the Pico W are different.
from machine import Pin
import utime
LED = Pin("LED",Pin.OUT) # Pico W
#LED = Pin(25,Pin.OUT) # Pico
while True:
LED.toggle()
utime.sleep(.1)
Read a button press¶
Connect a push-button to pin 4 (GP2) and pin 36 (3V3)
from machine import Pin
BUTTON = Pin(2,Pin.IN,Pin.PULL_DOWN)
while True:
if BUTTON.value():
# do something when the button is pushed
Read a potentiometer value¶
Connect a potentiometer's middle pin to pin 34 (GP28), and the remaining pins of the pot to pin 38 (GND) and pin 36 (3V3)
from machine import ADC
POT = ADC(28)
while True:
potentiometer_value = POT.read_u16()
print(potentiometer_value)
utime.sleep(.1)