【Follow me Season 2 Episode 1】Introductory Task, Basic Task 1: Lighting the Lamp
[Copy link]
This post was last edited by nemon on 2024-8-31 19:06
After getting the Adafruit Circuit Playground Express, first go to the official website ( https://learn.adafruit.com/adafruit-circuit-playground-express ) and take a look around, then you will know how to get started.
First, I flashed the latest version of the firmware - the so-called Pinyin version. The output was actually Pinyin, which was really tiring to read, so I flashed the English version:
Then I installed MU ( https://download.eeworld.com.cn/detail/nemon/634235 )
The entry-level task requires "building the development environment and lighting up the onboard LED", and the basic task requires "controlling the onboard colorful LED, lighting up the marquee and changing the color", so I went to the board to find resources.
The Adafruit Circuit Playground Express has 1 red LED and 10 three-color full-color LEDs, which is enough.
There is an official adafruit_circuitplayground library that encapsulates the resources on the board. The LED can be referenced using red_led, and the colorful lights can be used using pixels.
So the code is simple:
import time
from adafruit_circuitplayground import cp as my_cp
my_cp.pixels.brightness=0.1
while True:
for i in range(100):
for j in range(10):
my_cp.pixels[j]=( 25*(i%10), 0+25*((j-i)%10) , 255-25*((j-i)%10) )
if i%50==0:
my_cp.red_led = (i==0)
time.sleep(0.01)
print(i,end=' ')
The convention of CircuitPython is that code.py will be executed automatically, so save the above file as code.py.
Here, in order to demonstrate the LED, the colorful light changes on and off every 5 turns.
The effect is like this:
|