项目实践案例征集K10-六年级第24课 自动熄灭转向灯
本帖最后由 Isabella_J 于 2025-1-22 00:20 编辑https://makelogimg.dfrobot.com.cn/makelog/5e5bc08960b6fe37054a61af/863ea17c0ce93934ddac60f6f49c8551.pnghttps://makelogimg.dfrobot.com.cn/makelog/5e5bc08960b6fe37054a61af/f9092eb7022a944610d5c15ca953b40a.pnghttps://makelogimg.dfrobot.com.cn/makelog/5e5bc08960b6fe37054a61af/1fcaa70de2e357edf15c4bfee40c41d5.pnghttps://makelogimg.dfrobot.com.cn/makelog/5e5bc08960b6fe37054a61af/5b23a64f1cb00e67ae3465330c51087a.pnghttps://makelogimg.dfrobot.com.cn/makelog/5e5bc08960b6fe37054a61af/02e02749357b773aaaf6ee6635fccb4a.pnghttps://makelogimg.dfrobot.com.cn/makelog/5e5bc08960b6fe37054a61af/9978c32972c1ceca0543b2154288c966.png
代码
/*!
* MindPlus
* esp32s3bit
*
*/
#include "unihiker_k10.h"
// 创建对象
UNIHIKER_K10 k10;
uint8_t screen_dir=2;
// 主程序开始
void setup() {
k10.begin();
k10.initScreen(screen_dir);
k10.creatCanvas();
k10.rgb->brightness(round(9));
k10.setScreenBackground(0xFFFFFF);
}
void loop() {
if (((k10.getAccelerometerX())<=-150)) {
k10.canvas->canvasText("左转", 100, 150, 0x000000, k10.canvas->eCNAndENFont24, 50, true);
k10.canvas->updateCanvas();
k10.rgb->write(0, 0xFF0000);
delay(300);
k10.rgb->write(0, 0x000000);
delay(300);
}
else if (((k10.getAccelerometerX())>=150)) {
k10.canvas->canvasText("右转", 100, 150, 0x000000, k10.canvas->eCNAndENFont24, 50, true);
k10.canvas->updateCanvas();
k10.rgb->write(2, 0xFF0000);
delay(300);
k10.rgb->write(2, 0x000000);
delay(300);
}
else {
k10.canvas->canvasText("直行", 100, 150, 0x000000, k10.canvas->eCNAndENFont24, 50, true);
k10.canvas->updateCanvas();
k10.rgb->write(-1, 0x000000);
}
}
https://www.bilibili.com/video/BV15fweeEEWA/?vd_source=6ec67c00b0383a366d7377cd9c65f93f
页:
[1]