Function descriptionQuadruped robot: currently supports voice control to move forward, backward, turn left, turn right, twist, shake hands, jump, etc.; supports AP mode, connect to hotspots with a terminal, and access web pages for control; supports control using HC05 and Bluetooth debugger ;OLED expression display and ultrasonic obstacle avoidance are still being optimized. (Optimization completed, see the demonstration video below for the final effect)
static void UART_Task(void){IotUartAttribute uart_attr = {//baud_rate: 9600.baudRate = 9600,//data_bits: 8bits.dataBits = 8,.stopBits = 1,.parity = 0,.rxBlock = 0,.txBlock = 0,};//Initialize uart driverIoTUartInit(HI_UART_IDX_1, &uart_attr);while (1){printf("======================================== ");printf("SIZU_example* ");printf("======================================== ");// //Send data through serial port 1// IoTUartWrite(HI_UART_IDX_1, (unsigned char *)data, strlen(data));//Receive data through serial port 1IoTUartRead(HI_UART_IDX_1, uart_buff_ptr, UART_BUFF_SIZE);SIZU_Uart_Cmd((char *)uart_buff_ptr);printf("Uart1 read data:%s ", uart_buff_ptr);usleep(500000);}}`
//Front//------------------ | D1 | -------------------// -------- --------// | D4 | | D13 |// | joint4 | | joint13 |// ----- -------- --------- -----// | D5 | | D12 |// | joint5 | | joint12 |// -------- --------// | D11 | | D3 |// | joint11 | | joint3 |// ----- -------- --------- -----// | D12 | | D2 |// | joint12 | | joint2 |// -------- --------
enum{Get_Down,//趴下Hand_shake,//握手Go_Forward,//前进Go_Backward,//后退Go_Left,//左转Go_Right,//右转Twist_Body,//扭身子Stretch_Oneself,//伸懒腰WAIT//d};<br><br>//检测串口指令void SIZU_Uart_Cmd(char *str){char *Str;unsigned char ID=255;Str=&str[1];//定位到指令的数字部分“G1”ID=atoi(Str);if(strstr((const char *)str,"G")!=NULL) //如果字符串str中包含有“G”{switch(ID){case Get_Down: //趴下 G0sithome();printf("Get_Down ");break;case Hand_shake: // 握手G1wink(10);printf("Handshake ");break;case Go_Forward: // 前进G2forward(5);printf("Go_Forward ");break;case Go_Backward: // 后退G3backward(5);printf("Go_Backward ");break;case Go_Left: // 左转G4leftturn(5);printf("Go_Left ");break;case Go_Right: // 右转G5rightturn(5);printf("Go_Right ");break;case Twist_Body: // 扭身子twist();printf("LED_Add ");break;case Stretch_Oneself: //伸懒腰printf("LED_Reduce ");stand3();break;default:printf("%s ERROR",str);standhome();//站立break;}}memset(uart_buff,0,sizeof(uart_buff));}
// An highlighted block#define Echo 8 //Echo //GPIO8#define Trig 7 //Trig //GPIO7#define GPIO_FUNC 0float GetDistance (void) {static unsigned long start_time = 0, time = 0;float distance = 0.0;IotGpioValue value = IOT_GPIO_VALUE0;unsigned int flag = 0;/*=============== GPIO通信模式流程 1初始化GPIO========================================*/IoTIoSetFunc(Echo, GPIO_FUNC);//设置Echo连接IO为普通GPIO模式,无复用IoTGpioSetDir(Echo, IOT_GPIO_DIR_IN);//设置Echo连接IO为输入模式IoTGpioSetDir(Trig, IOT_GPIO_DIR_OUT);//设置Trig连接IO为输出模式/*=============== GPIO通信模式流程 2输出起始信号========================================*/IoTGpioSetOutputVal(Trig, IOT_GPIO_VALUE1);//拉高TrigIoTUdelay(20);//20usIoTGpioSetOutputVal(Trig, IOT_GPIO_VALUE0);//拉低Trig/*=============== GPIO通信模式流程 3检测Echo脚输出的高电平时间========================================*/while (1) {IoTGpioGetInputVal(Echo, &value);//读取Echo脚的电平状态if ( value == IOT_GPIO_VALUE1 && flag == 0) {//如果为高start_time = IoTGetUs();//获取此时时间flag = 1;}if (value == IOT_GPIO_VALUE0 && flag == 1) {//高电平结束变成低电平time = IoTGetUs() - start_time;//计算高电平维持时间start_time = 0;break;}}/*=============== GPIO通信模式流程 4代入公式计算========================================*/distance = time * 0.034 / 2;// printf("distance is %f ",distance);return distance;}
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>听话的狗子</title><style> body {user-select: none;text-align: center;}table {margin: 0 auto} td div {width: 150px;height: 150px;border: 1px solid darkgrey;display: flex;align-items: center;justify-content: center;color:deepskyblue;}#s {background-color: red;color: white;} td div:active {background: yellow;color: white;}button {margin: 0.5rem;width: 9rem;height: 3rem;font-size: 1.2rem;border-radius: 1rem;}button:hover {border-radius: 1rem;background-color: green;color: yellow;}</style></head><body><h1>网页控制</h1><button id="c">安装模式</button><button id="a">第一组动作</button><button id="b">第二组动作</button><br><br><button id="d">前进</button><br data-tomark-pass><br data-tomark-pass><button id="e">左转</button><button id="f">右转</button><br data-tomark-pass><br data-tomark-pass><button id="g">后退</button><br data-tomark-pass><br data-tomark-pass><button id="h">趴下</button><button id="i">握手</button><button id="j">伸懒腰</button><button id="k">扭身子</button><br data-tomark-pass><br data-tomark-pass><script>function u(p) {return `${p}`;}function g(i) {return document.getElementById(i);}function fe(e, f){e.addEventListener('click', function (e) {/* do something*/f();});}function fg(u, f) {let x = new XMLHttpRequest();x.onreadystatechange = function () {if (this.readyState == 4 && this.status == 200) {f(x);}};x.open("GET", u, true);x.send();}function fp(u, d, f, p) {let x = new XMLHttpRequest();if (p) {x.upload.addEventListener('progress', function (e) {p(e);});}x.onreadystatechange = function () {if (this.readyState == 4 && this.status == 200) {f(x);}};x.open('POST', u, true);x.timeout = 45000;x.send(d);}fe(g('a'), () => {fg(u('/dog/first'), () => {});});fe(g('b'), () => {fp(u('/dog/second'), () => {});});fe(g('c'), () => {fp(u('/dog/init'), () => {});});fe(g('d'), () => {fp(u('/dog/forward'), () => {});});fe(g('e'), () => {fp(u('/dog/left'), () => {});});fe(g('f'), () => {fp(u('/dog/right'), () => {});});fe(g('g'), () => {fp(u('/dog/backward'), () => {});});fe(g('h'), () => {fp(u('/dog/fall'), () => {});});fe(g('i'), () => {fp(u('/dog/handshake'), () => {});});fe(g('j'), () => {fp(u('/dog/stretch'), () => {});});fe(g('k'), () => {fp(u('/dog/twist'), () => {});});</script></body></html>
Devices | Class | introduce | Datasheet |
---|---|---|---|
CA45-A-16V-22uF-K | Tantalum capacitor | Download | |
RST22UF16V024 | Patch type aluminum electrolytic capacitors | Download | |
RMC 0402 100K F N | SMD resistor | Download | |
0201X473K100NT | Download |
All reference designs on this site are sourced from major semiconductor manufacturers or collected online for learning and research. The copyright belongs to the semiconductor manufacturer or the original author. If you believe that the reference design of this site infringes upon your relevant rights and interests, please send us a rights notice. As a neutral platform service provider, we will take measures to delete the relevant content in accordance with relevant laws after receiving the relevant notice from the rights holder. Please send relevant notifications to email: bbs_service@eeworld.com.cn.
It is your responsibility to test the circuit yourself and determine its suitability for you. EEWorld will not be liable for direct, indirect, special, incidental, consequential or punitive damages arising from any cause or anything connected to any reference design used.
Supported by EEWorld Datasheet