代码拉取完成,页面将自动刷新
同步操作将从 KBCX/蓝牙小车 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
/*1111 ****** 2222*/
/*1111**********2222*/
/*1111 ****** 2222*/
/* ** */
/* ** */
/*3333 ****** 4444*/
/*3333**********4444*/
/*3333 ****** 4444*/
#include <Arduino.h>
#include "BluetoothSerial.h"
BluetoothSerial SerialBT;
char A = 'c';
void ting()
{
digitalWrite(12, 0); // 1
digitalWrite(14, 0);
digitalWrite(27, 0); // 2
digitalWrite(26, 0);
digitalWrite(17, 0); // 4
digitalWrite(16, 0);
digitalWrite(19, 0); // 3
digitalWrite(18, 0);
digitalWrite(25, 0);
digitalWrite(15, 0); // 3
digitalWrite(33, 0);
digitalWrite(23, 0); // 3
}
void qianjing()
{
digitalWrite(12, 0); // 1
digitalWrite(14, 1);
digitalWrite(27, 1); // 2
digitalWrite(26, 0);
digitalWrite(17, 1); // 4
digitalWrite(16, 0);
digitalWrite(19, 1); // 3
digitalWrite(18, 0);
digitalWrite(33, 1);
digitalWrite(23, 1); // 3
}
void houtui()
{
digitalWrite(12, 1); // 1
digitalWrite(14, 0);
digitalWrite(27, 0); // 2
digitalWrite(26, 1);
digitalWrite(17, 0); // 3
digitalWrite(16, 1);
digitalWrite(19, 0); // 4
digitalWrite(18, 1);
digitalWrite(25, 1);
digitalWrite(15, 1); // 3
}
void youyi()
{
digitalWrite(12, 1); // 1
digitalWrite(14, 0);
digitalWrite(27, 1); // 2
digitalWrite(26, 0);
digitalWrite(17, 0); // 4
digitalWrite(16, 1);
digitalWrite(19, 1); // 3
digitalWrite(18, 0);
digitalWrite(15, 1); // 3
digitalWrite(23, 1); // 3
}
void zhuoyi()
{
digitalWrite(12, 0); // 1
digitalWrite(14, 1);
digitalWrite(27, 0); // 2
digitalWrite(26, 1);
digitalWrite(17, 1); // 4
digitalWrite(16, 0);
digitalWrite(19, 0); // 3
digitalWrite(18, 1);
digitalWrite(25, 1);
digitalWrite(33, 1);
}
void zhuoxuan()
{
digitalWrite(12, 1); // 1
digitalWrite(14, 0);
digitalWrite(27, 1); // 2
digitalWrite(26, 0);
digitalWrite(17, 1); // 4
digitalWrite(16, 0);
digitalWrite(19, 0);
digitalWrite(18, 1); // 3
digitalWrite(23, 1); // 3
digitalWrite(25, 1);
}
void youxuan()
{
digitalWrite(12, 0); // 1
digitalWrite(14, 1);
digitalWrite(27, 0); // 2
digitalWrite(26, 1);
digitalWrite(17, 0); // 4
digitalWrite(16, 1);
digitalWrite(19, 1);
digitalWrite(18, 0); // 3
digitalWrite(15, 1);
digitalWrite(33, 1);
}
void deng(int i)
{
digitalWrite(23, i);
digitalWrite(25, i);
digitalWrite(15, i);
digitalWrite(33, i);
}
void setup()
{
pinMode(33, OUTPUT);
pinMode(25, OUTPUT);
pinMode(15, OUTPUT);
pinMode(23, OUTPUT);
pinMode(12, OUTPUT);
pinMode(14, OUTPUT);
pinMode(27, OUTPUT);
pinMode(26, OUTPUT);
pinMode(16, OUTPUT);
pinMode(17, OUTPUT);
pinMode(18, OUTPUT);
pinMode(19, OUTPUT);
digitalWrite(15, 1);
digitalWrite(33, 1);
delay(200);
digitalWrite(15, 0);
digitalWrite(33, 0);
delay(400);
digitalWrite(23, 1);
digitalWrite(25, 1);
delay(200);
digitalWrite(23, 0);
digitalWrite(25, 0);
delay(200);
digitalWrite(15, 1);
digitalWrite(33, 1);
digitalWrite(23, 1);
digitalWrite(25, 1);
delay(500);
digitalWrite(15, 0);
digitalWrite(33, 0);
digitalWrite(23, 0);
digitalWrite(25, 0);
SerialBT.begin("ESP32小车");
}
void loop()
{
if (SerialBT.available())
A = SerialBT.read();
switch (A)
{
case 'a':qianjing(); break; //前
case 'b':houtui();break; //后
case 'c':ting();break; //停
case 'd':youyi(); break; //右移
case 'e':zhuoyi();break; //左移
case 'f':zhuoxuan();break; //左旋
case 'g':youxuan(); break; //右旋
case 'h':deng(1); break; //开灯
case 'j':deng(0); break; //关灯
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。