收到开发板后接下来就是上手搭建编译环境以及点灯啦,在此次活动中我使用的开发环境是老师教程中使用的Circuit python。在本贴中实现无操作时红灯常亮,按键按下红灯熄灭的效果。
1.首先根据教程给开发板安装Circuit python固件,Install CircuitPython | Adafruit ESP32-S3 Reverse TFT Feather | Adafruit Learning System固件下载操作如下图所示:
开发板进入文件系统模式操作如下所示:
电脑出现U盘,打开U盘,将下载好的固件复制到U盘当中。
复制完成后如下图所示开发板环境就算搭建完成了
2.接下来安装Thonny编译环境Thonny, Python IDE for beginners我这里选择安装的如下图所示:
依据安装步骤安装即可
安装完成后打开应用程序主界面如下图所示:
3. 使用编译环境操作IO口按键检测+点灯,首先找到开发板硬件接口图以及原理图,接下来通过原理图的按键、LED的引脚来实现IO的输入检测与输出控制。
打开软件按照如下图所示步骤操作将程序编写烧录完成即可完成按键控制LED灯的基本操作
源码如下:
# SPDX-FileCopyrightText: 2018 Kattni Rembor for Adafruit Industries # # SPDX-License-Identifier: MIT """CircuitPython Essentials Digital In Out example""" import time import board from digitalio import DigitalInOut, Direction, Pull # LED setup. led = DigitalInOut(board.LED) # For QT Py M0. QT Py M0 does not have a D13 LED, so you can connect an external LED instead. # led = DigitalInOut(board.SCK) led.direction = Direction.OUTPUT # For Gemma M0, Trinket M0, Metro M0 Express, ItsyBitsy M0 Express, Itsy M4 Express, QT Py M0 switch = DigitalInOut(board.D1) # switch = DigitalInOut(board.D2) # For Feather M0 Express, Feather M4 Express # switch = DigitalInOut(board.BOOT0) # For Circuit Playground Express switch.direction = Direction.INPUT switch.pull = Pull.DOWN #switch.direction = Direction.INPUT #switch.pull = Pull.UP while True: # We could also do "led.value = not switch.value"! if switch.value: led.value = False else: led.value = True time.sleep(0.01) # debounce delay
4. 成果演示
烧录成功后无操作红灯亮起
按下D1按键红灯熄灭