yahboom
HomeLearn
Solution
Blog
Online Store
About Us
EN/中文
Pico Robot Car📖
0.Introduction
  • 0.1 Description of Pico Robot
  • 0.2 Interface Description
1.Assembly steps
  • Assembly video
2.Development environment construction
  • 2.1 Update firmware
  • 2.2 Build environment
  • 2.3 Download code Startup automatically
  • 2.4 Import library file
3.Basic course
  • 3.1 Control LED light
  • 3.2 Onboard temperature sensor
  • 3.3 Passive buzzer
  • 3.4 Breathing light
  • 3.5 Marquee light
  • 3.6 OLED display
  • 3.7 Battery power display
  • 3.8 Servo control
4.Advanced course
  • 4.1 Light sensor
  • 4.2 Sound sensor
  • 4.3 Tracking sensor
  • 4.4 Ultrasonic sensor
  • 4.5 IR control display
5.Robot course
  • 5.1 Car forward
  • 5.2 Car movement
  • 5.3 Singing dancing
  • 5.4 Car tracking
  • 5.5 Edge detection
  • 5.6 Ultrasonic avoiding
  • 5.7 Ultrasounic following
  • 5.8 Light follow
  • 5.9 Voice control car
  • 5.10 Infrared control
  • 5.11 Bluetooth control
6.Battery and charge
  • Battery and charge
Download
  • APP(iOS/Android)
  • Code
  • Instructions Manual
  • Appendix
Download ZIP

Welcome to Pico Robot Car repository

3.1 Control LED light

3.1 Control the onboard LED light to flash

In the previous section, we learned how to build a development environment and run the program to control the onboard LED to flash. In this section, we will learn how this part of the program realizes LED control.

1. Learning objectives

  1. Learn the basic use of the pins of the Raspberry Pi Pico 2/Pico board.
  2. Understand how to control the onboard LED light.

2. Hardware usage

This course does not require additional hardware, and can directly use the onboard LED light on the Raspberry Pi Pico 2/Pico board. (The LED positions on Pico 2/Pico board are the same)

image-20220208161613985

3. Program Analysis

Code path: Code -> 1.Basic course -> 1. On board LED lamp.py

For the use of ThonnyIDE, please refer to the second chapter course.

​x
import machine 
import time 
led_onboard = machine.Pin(25, machine.Pin.OUT)
​
while True: 
    led_onboard.value(1) 
    time.sleep(1) 
    led_onboard.value(0) 
    time.sleep(1)

import machine

The machine library contains all the instructions MicroPython needs to communicate with Pico and other MicroPython-compatible devices, extending the language of physical computing.

import time

The "time" library. This library handles everything to do with time, from measuring it to inserting delays into your program. The units are in seconds.

led_onboard = machine.Pin(25, machine.Pin.OUT)

The first argument, 25, is the number of pins you are setting; the second argument, machine.Pin.OUT, tells Pico that the pin should be used as an output rather than an input.

time.sleep(1)

This calls the sleep function from the time library, which will cause the program to pause for whatever number of seconds you type - in this case, 1 second.

4. Experimental Phenomenon

After the program is downloaded, we can see that the LED light on the Raspberry Pi Pico 2/Pico development board flashes every 1 second.

Import library file
Onboard temperature sensor

COMPANY

  • About us
  • Team Style
  • Blog

LEARNING & EXPLORATION

  • Tutorials
  • Edge AI hardware
  • Educational robots
  • Embedded intelligent hardware

WHERE TO BUY

  • Yahboom Online Store
  • Amazon
  • Alibaba
  • AliExpress
  • Mercado

TECHNOLOGY SUPPORT

  • Email: support@yahboom.com

BE A DISTRIBUTOR

  • Email: sales@yahboom.com
QR Code
QR Code

Copyright © 2017-2026 Yahboom. All Rights Reserved.

EN/中文