行空板K10驱动摄像头与板载传感器驱动舵机电机
本帖最后由 meiyao 于 2025-2-15 11:06 编辑行空板K10是一款专为快速体验物联网和学习人工智能而设计的开发学习板,其驱动摄像头与板载传感器驱动舵机电机的相关信息如下:
一、行空板K10的硬件特性核心处理器:采用ESP32-S3 N16R8处理器,Xtensa LX7双核32位,主频达到240MHz。板载元件:集成2.8寸彩色LCD屏幕、WiFi蓝牙模块、200W像素摄像头、MEMS麦克风(x2)、扬声器、RGB指示灯、多种传感器(温湿度传感器AHT20、环境光传感器LTR303ALS、三轴加速度传感器SC7A20H)等。扩展接口:提供Type-C供电&烧录接口、2Pin PH2.0电池供电接口、3Pin PH2.0全功能IO接口(x2)、4Pin PH2.0 I2C接口、自弹式TF卡槽、金手指扩展口等。
二、驱动摄像头功能:行空板K10集成的摄像头支持200W像素,可进行离线图像检测。通过编程,用户可以轻松实现拍照、录像、图像识别等功能。驱动方式:利用行空板K10的摄像头接口和相关的编程库,用户可以编写代码来驱动摄像头。使用积木,通过行空板K10的API接口来控制摄像头的拍摄、图像传输和处理等功能。
三、板载传感器驱动舵机电机板载传感器:行空板K10配备了多种传感器,温湿度传感器、环境光传感器、三轴加速度传感器等。这些传感器可以实时监测环境参数,并将数据传输给行空板K10进行处理。舵机电机驱动:行空板K10可以通过PWM(脉冲宽度调制)信号来驱动舵机电机。用户可以通过编程来设置PWM信号的频率和占空比,从而控制舵机的转动角度和速度。实现方式:在编程时,用户可以利用行空板K10的GPIO(通用输入输出)引脚来输出PWM信号。通过调整PWM信号的参数,用户可以实现对舵机的精确控制。同时,行空板K10还支持通过I2C、SPI等接口连接更复杂的外部设备,进一步扩展其功能。
四、积木程序
屏显示程序:
传感器采集程序:
姿态传感器程序:
串口发送RGB,点亮LED程序:
按键程序:
驱动电机与舵机程序:
五,代码:/*!
* MindPlus
* esp32s3bit
*
*/
#include "unihiker_k10.h"
#include "AIRecognition.h"
// 动态变量
volatile float mind_n_ChuanKouShuJu;
// 函数声明
void onButtonAPressed();
void onButtonAUnPressed();
void onButtonBUnPressed();
void onButtonBPressed();
void onButtonABPressed();
void onButtonABUnPressed();
// 创建对象
UNIHIKER_K10k10;
uint8_t screen_dir=2;
AIRecognition ai;
AHT20 aht20;
// 主程序开始
void setup() {
k10.begin();
k10.initScreen(screen_dir);
ai.initAi();
k10.initBgCamerImage();
k10.setBgCamerImage(false);
k10.creatCanvas();
ai.switchAiMode(ai.NoMode);
k10.buttonA->setPressedCallback(onButtonAPressed);
k10.buttonA->setUnPressedCallback(onButtonAUnPressed);
k10.buttonB->setUnPressedCallback(onButtonBUnPressed);
k10.buttonB->setPressedCallback(onButtonBPressed);
k10.buttonAB->setPressedCallback(onButtonABPressed);
k10.buttonAB->setUnPressedCallback(onButtonABUnPressed);
k10.setBgCamerImage(true);
ai.switchAiMode(ai.Face);
Serial.begin(9600);
pinMode(P0, OUTPUT);
pinMode(P1, OUTPUT);
}
void loop() {
delay(1000);
if (ai.isDetectContent(AIRecognition::Face)) {
k10.canvas->canvasText((String("人脸长") + String(ai.getFaceData(AIRecognition::Length))), 120, 120, 0x0000FF, k10.canvas->eCNAndENFont24, 50, true);
k10.canvas->canvasText((String("人脸宽") + String(ai.getFaceData(AIRecognition::Width))), 120, 120, 0x0000FF, k10.canvas->eCNAndENFont24, 50, true);
k10.canvas->canvasText((String("人脸中心坐标x:") + String(ai.getFaceData(AIRecognition::CenterX))), 220, 120, 0x0000FF, k10.canvas->eCNAndENFont24, 50, true);
k10.canvas->canvasText((String("人脸中心坐标y:") + String(ai.getFaceData(AIRecognition::CenterY))), 200, 220, 0x0000FF, k10.canvas->eCNAndENFont24, 50, true);
k10.canvas->updateCanvas();
}
k10.setScreenBackground(0xFFFFFF);
k10.canvas->canvasText("行空板", 80, 5, 0xFF0000, k10.canvas->eCNAndENFont24, 3, true);
k10.canvas->canvasText((String("温度") + String(aht20.getData(AHT20::eAHT20TempC))), 2, 0x0000FF);
k10.canvas->canvasText((String("湿度") + String(aht20.getData(AHT20::eAHT20HumiRH))), 3, 0x0000FF);
k10.canvas->canvasText((String("光线") + String(k10.readALS())), 4, 0x0000FF);
k10.canvas->canvasText((String("加速度") + String((k10.getAccelerometerX()))), 5, 0x0000FF);
k10.canvas->updateCanvas();
delay(1000);
if ((k10.isGesture(TiltRight))) {
k10.canvas->canvasText(" 右 ", 100, 130, 0x0000FF, k10.canvas->eCNAndENFont24, 2, true);
k10.canvas->updateCanvas();
}
else {
k10.canvas->canvasText("", 100, 130, 0x0000FF, k10.canvas->eCNAndENFont24, 2, true);
k10.canvas->updateCanvas();
}
if ((k10.isGesture(TiltLeft))) {
k10.canvas->canvasText("左", 10, 130, 0x0000FF, k10.canvas->eCNAndENFont24, 2, true);
k10.canvas->updateCanvas();
}
else {
k10.canvas->canvasText("", 10, 130, 0xFFFFFF, k10.canvas->eCNAndENFont24, 2, true);
k10.canvas->updateCanvas();
delay(1000);
}
if ((Serial.available())) {
mind_n_ChuanKouShuJu = Serial.read();
if ((Serial.available())) {
Serial.println("");
if ((mind_n_ChuanKouShuJu==(toascii('R')))) {
k10.rgb->write(-1, 0xFF0000);
}
if ((mind_n_ChuanKouShuJu==(toascii('G')))) {
k10.rgb->write(-1, 0x00FF00);
}
if ((mind_n_ChuanKouShuJu==(toascii('B')))) {
k10.rgb->write(-1, 0x0000FF);
}
if ((mind_n_ChuanKouShuJu==(toascii('0')))) {
k10.rgb->write(-1, 0x000000);
}
}
k10.canvas->updateCanvas();
}
}
// 事件回调函数
void onButtonAPressed() {
k10.rgb->write(0, 0x0000FF);
}
void onButtonAUnPressed() {
k10.rgb->write(0, 0x000000);
}
void onButtonBUnPressed() {
k10.rgb->write(1, 0x000000);
}
void onButtonBPressed() {
k10.rgb->write(1, 0xFF0000);
}
void onButtonABPressed() {
analogWrite(P0, map(512, 0, 1023, 0, 255));
digitalWrite(P1, HIGH);
k10.rgb->write(-1, 0x00FF00);
}
void onButtonABUnPressed() {
analogWrite(P0, map(0, 0, 1023, 0, 255));
digitalWrite(P1, LOW);
k10.rgb->write(-1, 0x000000);
}
六,模块图
MOS电机驱动板:
2.0与2.54转接板:
七,示意图
八,视频
https://www.bilibili.com/video/BV1dqKTepEdy/
页:
[1]