195 views|0 replies

4

Posts

1

Resources
The OP
 

【Follow me Season 2 Episode 1】 Getting Started Task: Lighting up the onboard LED and the Marquee Effect [Copy link]

 This post was last edited by cyz6668 on 2024-8-27 00:40

I am very happy to participate in this Follow me development board experience event. After a series of evaluation tasks, I have now completed the initial exploration of the Adafruit development board and am ready to organize the experimental results and upload the report.

The following is a complete record of the experimental process:

1. Unboxing the development board:

The Adafruit development board I received has a beautiful appearance and complete accessories.


2. Getting Started Tasks (Required): Build the Development Environment and Light Up the Onboard LED

I first tried Makecode's graphical programming, but I still felt that the code editor interface was more convenient. In the end, I chose CircuitPython as the development language because it provides rich library support and easy-to-use features.

According to the provided user guide [ Overview | Adafruit Circuit Playground Express | Adafruit Learning System ], the .uf2 file and CircuitPython firmware library required for burning have been downloaded. As follows:

Double-click the Reset button of the development board to put the development board into the flashing state. At this time, the development board lights up green and the computer recognizes the new driver CPLAYBOOT, which indicates that the connection is successful.

Copy the previously prepared .uf2 file to the drive, wait for a while, and the board will show that all red lights are on, and the previous drive will be ejected and re-identified as CIRCUITPY, then you can burn the Python program.

Copy the downloaded firmware library to the board. These are the functions in the Circuit Playground Library, which provide various functions and reference routines. However, many of them are not used in this task for the time being, and will be studied later.

After looking at the example code provided in the tutorial, it seems that there are two different ways to call library functions. There are direct import board, import digitalio to call different input and output ports or peripherals of the board; there is also from adafruit_circuitplayground import cp , using cp.XX to call peripherals. Personally, I think it is a bit like the latter is an additional layer of library functions encapsulated, refer to this CircuitPython Made Easy【Circuit Playground Library | CircuitPython Made Easy on Circuit Playground Express and Bluefruit | Adafruit Learning System

I prefer the latter because it provides a more concise package. Subsequent tasks will be completed based on it, that is, the library functions of the Circuit Playground Library. There is not much difference between the two in essence.

After the board is adapted, install the CircuitPython compiler Mu Editor, select CircuitPython in the mode, and you can write and burn the code.

The simplest code to light up the onboard LED is as follows :

from adafruit_circuitplayground import cp

while True: 
	cp.red_led = True

The lighting effect of the onboard LED light is as follows, and you can see that the LED light at position D13 is lit:

See the first half of the video for a video demonstration.


3. Basic Task 1 (Must Do): Control the onboard colorful LED, light up the marquee and change the color

This part of the task requires using a circle of LED lights around the board, and lighting them up in turn and giving them different colors. Referring to the NeoPixels part of the tutorial [ NeoPixels | CircuitPython Made Easy on Circuit Playground Express and Bluefruit | Adafruit Learning System ], we can know that the following code can be used to light up the lights:

cp.pixels[i] = (R,G,B)

Where i represents the number of the LED light to be turned on, and the three-element array (R, G, B) is used to set the color of the light.

In order to facilitate the color change of the marquee, we pre-set a color list color to store the colors that may be used, and then each light only needs to take a color in sequence. If the color list range is exceeded, it will start from the beginning. At the same time, in each cycle, the starting color of the LED light will be updated to the next color in the color list, so that the entire LED light strip will present a flowing light effect.

The code is as follows:

from adafruit_circuitplayground import cp

cp.pixels.brightness = 0.1
num_pixels = 10 
colors = [(255, 0, 0), (0, 255, 0), (0, 0, 255), (255, 255, 0), (255, 0, 255),
     (0, 255, 255), (255, 127, 0), (127, 255, 0), (127, 0, 255), (0, 127, 255)]

while True:
  for i in range(num_pixels):
    start_color = i
    for j in range(num_pixels):
      cp.pixels[j] = colors[(i+j)%10]

You can see that the LEDs on the board show different colors, as follows:

See the second half of the video for a video demonstration, where you can see the color changes and flow effects.

板载LED点亮+跑马灯

This post is from DigiKey Technology Zone
 
 

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