3419 views|10 replies

1455

Posts

1

Resources
The OP
 

[Raspberry Pi Pico Review] How to use the I/O port output function [Copy link]

 
This post was last edited by jinglixixi on 2021-3-31 17:44

The I/O port of the Raspberry Pi Pico plays an important role. In addition to controlling the onboard LED, you can also use the I/O resources provided by the Arduino interface to control the fan, and even use multiple I/O ports to implement running lights, etc.

1. Light up the external LED

By using the LED light routine and the pins of the Arduino interface, you can light up the external LED. The effect is shown in Figure 1.

Figure 1 Light up the external LED

2. Fan Control

Based on the previous, if the LED is replaced with a fan, the speed of the fan can be adjusted. The procedure is shown in Figure 2.

Figure 2 Fan control program

Since the delay function is called in the program, the fan is in an intermittent operation state, and naturally its speed has a certain degree of reduction. The shorter the power-on time, the lower the speed. Its overall structure is shown in Figure 3.

Figure 3 Hardware composition

In addition, if the LED on the board is used to indicate the working status of the fan, the procedure is shown in FIG4 .

Figure 4 Status Indicator Program

Figure 5 Fan rotation effect

Animation effects:

3. Flowing water light effect

Having only one LED on the board is not enough to display the flowing light effect. A multi-segment integrated LED display block can achieve the purpose.

The program to implement the water lamp demonstration is as follows:

import machine
import utime
l1 = machine.Pin(21, machine.Pin.OUT)
l2 = machine.Pin(20, machine.Pin.OUT)
l3 = machine.Pin(13, machine.Pin.OUT)
l4 = machine.Pin(18, machine.Pin.OUT)
l5 = machine.Pin(17, machine.Pin.OUT)
l6 = machine.Pin(16, machine.Pin.OUT)
l7 = machine.Pin(15, machine.Pin.OUT)
l8 = machine.Pin(14, machine.Pin.OUT)
while True:
    l1.value(1)
    utime.sleep_ms(200)
    l1.value(0)
    utime.sleep_ms(200)
    l2.value(1)
    utime.sleep_ms(200)
    l2.value(0)
    utime.sleep_ms(200)
    l3.value(1)
    utime.sleep_ms(200)
    l3.value(0)
    utime.sleep_ms(200)
    l4.value(1)
    utime.sleep_ms(200)
    l4.value(0)
    utime.sleep_ms(200)
    l5.value(1)
    utime.sleep_ms(200)
    l5.value(0)
    utime.sleep_ms(200)
    l6.value(1)
    utime.sleep_ms(200)
    l6.value(0)
    utime.sleep_ms(200)
    l7.value(1)
    utime.sleep_ms(200)
    l7.value(0)
    utime.sleep_ms(200)
    l8.value(1)
    utime.sleep_ms(200)
    l8.value(0)
    utime.sleep_ms(200)

Figure 6 Flowing water light effect

Animation effects:

4. Incremental lighting effect

Based on the flowing lights, the demonstration effect can also be changed to an incremental lighting effect.

The procedure to achieve the incremental lighting effect is as follows:

import machine
import utime
l1 = machine.Pin(12, machine.Pin.OUT)
l2 = machine.Pin(20, machine.Pin.OUT)
l3 = machine.Pin(13, machine.Pin.OUT)
l4 = machine.Pin(18, machine.Pin.OUT)
l5 = machine.Pin(17, machine.Pin.OUT)
l6 = machine.Pin(16, machine.Pin.OUT)
l7 = machine.Pin(15, machine.Pin.OUT)
l8 = machine.Pin(14, machine.Pin.OUT)

l1.value(0)
l2.value(0)
l3.value(0)
l4.value(0)
l5.value(0)
l6.value(0)
l7.value(0)
l8.value(0)

while True:
    l1.value(1)
    utime.sleep_ms(200)
    l2.value(1)
    utime.sleep_ms(200)
    l3.value(1)
    utime.sleep_ms(200)
    l4.value(1)
    utime.sleep_ms(200)
    l5.value(1)
    utime.sleep_ms(200)
    l6.value(1)
    utime.sleep_ms(200)
    l7.value(1)
    utime.sleep_ms(200)
    l8.value(1)
    utime.sleep_ms(200)
    l1.value(0)
    l2.value(0)
    l3.value(0)
    l4.value(0)
    l5.value(0)
    l6.value(0)
    l7.value(0)
    l8.value(0)
    utime.sleep_ms(200)

Figure 7 Incremental lighting effect

Animation effects:

This post is from DIY/Open Source Hardware

Latest reply

Is py easy to get started with? How does it compare to C?   Details Published on 2021-4-9 10:29

赞赏

1

查看全部赞赏

 

9717

Posts

24

Resources
2
 

Is there a driver circuit on the fan board?

This post is from DIY/Open Source Hardware

Comments

There should be, otherwise the I/O driving current would not be so large.  Details Published on 2021-3-31 23:23
 
 

2w

Posts

341

Resources
3
 

I saw that the drive motor of the host has a 2-blade fan.

Another topic, usually the fan has 3 blades, and the design of odd number of blades with asymmetric rotation axis

How to balance a 2-blade fan?

This post is from DIY/Open Source Hardware

Comments

As long as the center of gravity falls on the axis  Details Published on 2021-3-31 23:28
 
 
 

1455

Posts

1

Resources
4
 
littleshrimp posted on 2021-3-31 19:07 Is there a drive circuit on the fan board?

There should be, otherwise the I/O driving current would not be so large.

This post is from DIY/Open Source Hardware
 
 
 

1455

Posts

1

Resources
5
 
qwqwqw2088 posted on 2021-3-31 22:12 I saw that the drive motor of the OP has a 2-blade fan. Usually the fan has 3 blades, and the design of odd number of blades with asymmetric rotating axis...

As long as the center of gravity falls on the axis

This post is from DIY/Open Source Hardware
 
 
 

1942

Posts

2

Resources
6
 

It feels pretty good. The host has quite a lot of peripheral modules! It looks pretty good!

This post is from DIY/Open Source Hardware

Comments

Haha, it’s newly purchased.  Details Published on 2021-4-6 18:18
 
 
 

1455

Posts

1

Resources
7
 
w494143467 posted on 2021-4-6 10:05 It feels pretty good. The host has quite a lot of peripheral modules! It looks pretty good!

Haha, it’s newly purchased.

This post is from DIY/Open Source Hardware
 
 
 

7462

Posts

2

Resources
8
 

Interesting! Thanks for sharing

This post is from DIY/Open Source Hardware
Personal signature

默认摸鱼,再摸鱼。2022、9、28

 
 
 

6593

Posts

0

Resources
9
 

Raspberry Pico is really more fun

This post is from DIY/Open Source Hardware
 
 
 

71

Posts

2

Resources
10
 

Is py easy to get started with? How does it compare to C?

This post is from DIY/Open Source Hardware

Comments

It is quite easy to use, and it is best to have a suitable introductory learning material. It is comparable to C language, but it does not have as many instructions as C language, so it may be more difficult to learn in depth. When you can use it, you may rely more on the developed libraries.  Details Published on 2021-4-9 12:16
 
 
 

1455

Posts

1

Resources
11
 
This post was last edited by jinglixixi on 2021-4-9 17:20
Albert.G posted on 2021-4-9 10:29 OP, is py easy to get started with? How does it compare to C?

It is quite easy to use, and it is best to have a suitable introductory learning material. It is comparable to C language, but it does not have as many instructions as C language, so it may be more difficult to learn in depth. People may rely more on the developed libraries when using it.

This post is from DIY/Open Source Hardware
 
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list