[Digi-Key Electronics Follow me Issue 2] + Mission Collection (optional mission LED water light)
[Copy link]
I was lucky enough to participate in the Follow me 2nd event organized by EEWORL and DigKey Electronics, which allowed me to deeply experience the Adafruit ESP32-S3 TFT Feather development board. Adafruit has created many official tutorials for this development board, especially for the circuitpython language, which is very helpful for beginners to learn. I completed this task under the guidance of these tutorials and WeChat group friends.
Part 1: Mission video explanation
【Digi-Key Follow me Issue 2】Task Collection
Part II: Project Report
I directly use the official code.circuitpython.org to edit. Although it is relatively crude, the code is simple and it is very convenient to implement with almost no obstacles.
This mission has three required tasks + one optional task (additional tasks are abandoned)
The three required tasks are:
1. Control the screen to display Chinese
2. Use of network functions
3. Control board WS2812B
4.WS2812B effect control
I put tasks 1, 3, and 4 together to achieve the effect. 2. The task codes are listed separately. The following is the code explanation
First is Task 2: Network Function Usage
##此部分是code.py文件内的代码
import wifi
#创建wifi()前面是名字,后面是密码
wifi.radio.start_ap("my wife", "520521522")
##此部分在文件setting.toml 中负责wifi连接(只有2.4G波段)
CIRCUITPY_WIFI_SSID = "your wifi SSID"
CIRCUITPY_WIFI_PASSWORD = "your wifi passwoird"
The above code implements the connection and establishment of Wiif. The following is the effect diagram
Figure 1: Wi-Fi is successfully established
Figure 2, the existing wifi connection is successful
Next are tasks 1, 3, and 4: Chinese character display, onboard RGBLED lights, and external running lights.
#导入相关库
import board
import neopixel
import keypad
import time as Time
from adafruit_display_text import label
from adafruit_bitmap_font import bitmap_font
from digitalio import DigitalInOut, Direction, Pull
#字体点阵设置
font = bitmap_font.load_font("/font/lulu.pcf")
#内容,颜色,位置,大小
text_red = label.Label(font, text="红", color=0xFF0000,x = 80,y = 20,scale = 4)
text_green = label.Label(font, text="绿", color=0x00FF00,x = 80,y = 20,scale = 4)
text_bule = label.Label(font, text="蓝", color=0x0000FF,x = 80,y = 20,scale = 4)
#创建wifi
wifi.radio.start_ap("my wife", "520521522")
#关于LED的定义*********
pixe1 = neopixel.NeoPixel(board.NEOPIXEL,1)
pixe2 = neopixel.NeoPixel(board.A0,24)
# 亮度
pixe1.brightness = 0.1
pixe2.brightness = 0.1
#颜色控制
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BULE = (0, 0, 255)
i = 0
#设置按键
btn = DigitalInOut(board.BOOT0)
btn.direction = Direction.INPUT
btn.pull = Pull.UP
while True:
if not btn.value:
if(i%3==0):
board.DISPLAY.show(text_red)
pixe1.fill(RED)
pixe2.fill(RED)
if(i%3==1):
board.DISPLAY.show(text_green)
pixe1.fill(GREEN)
pixe2.fill(GREEN)
if(i%3==2):
pixe1.fill(BULE)
pixe2.fill(BULE)
board.DISPLAY.show(text_bule)
i += 1
#按键防抖
Time.sleep(0.3)
Code explanation:
1. Import relevant font files and set preset display information
2. Set related buttons (onboard boot button)
3. Set the preset color value RGB value
4. Use the neopixel function in the module introduced by the system to set two RGBled modules
5. Set the RGB color values of the two RGBLED light modules in the main loop and display them on the screen synchronously
The following is the implementation diagram
The above three diagrams achieve the effect
Part 3: Project Summary (Experience)
This activity was my first time to use the ESP32S3 development board, and also my first time to use CircuitPython programming. I have to say that the rich information provided by Adafruit made the learning process much easier. This experience is really rare for poor students. I hope I can have the opportunity to participate next time. I am preparing for the postgraduate entrance examination, so time is very precious. This saved me a lot of time.
Comments and suggestions, delivery is a bit slow!
Part 3: Project Code
|