Lesson 7 Pico MicroPython Digital Input Output To Pico

Опубликовано: 25 Март 2026
на канале: CodingScientist
329
7

In this lesson I will show you how to control the digital IN and digital OUT using MicroPython into Pico controller board.

In last few lessons I showed you very basics, from here on, we will dig deeper into the MicroPython coding and using Pico microcontroller to communicate with external components, In this lesson you can learn to control an external LED with your Raspberry Pi Pico, and get it to read input from a button.

Use a resistor between about 50 and 330 ohms, an LED, and a pair of M-M jumper leads to connect up your Raspberry Pi Pico as shown in the image below.

In this example, the LED is connected to pin 15. If you use a different pin, remember to look up the number in the pinout diagram

Use the same code as you did to blink the onboard LED, but change the pin number to 15.

from machine import Pin, Timer
led = Pin(15, Pin.OUT)
timer = Timer()

def blink(timer):
led.toggle()

timer.init(freq=2.5, mode=Timer.PERIODIC, callback=blink)

Run your program and your LED should start to blink. If it’s not working, check your wiring to be sure that the LED is connected.


Project Source Codes : https://github.com/AnbuKumar-maker
Contact us for more projects: [email protected]
WhatsApp Support: +91-99725-77735
About us: https://www.codingscientist.com
Hackster Community: https://www.hackster.io/anbu-kumar
LinkedIn:   / codingscientist  
Facebook:   / coding.scientist  
Twitter:   / robo_thoughts