6419| 4
|
[求助] 请教一下miniQ小车的问题 |
使用遥控器转弯时,我想让小车旋转90°,然后继续直线行走,但是按下左转后,小车一直转圈 这个命令: if (ir_item == 16591063) { setRomeoMotor(1, 10); setRomeoMotor(2, 50); delay(400); setRomeoMotor(1, 50); setRomeoMotor(2, 53); } 直接使用是好用的,可以跑正方形,但是放到通信命令下就一直转圈 if (irrecv_10.decode(&results_10)) { ir_item=results_10.value; String type="UNKNOWN"; String typelist[14]={"UNKNOWN", "NEC", "SONY", "RC5", "RC6", "DISH", "SHARP", "PANASONIC", "JVC", "SANYO", "MITSUBISHI", "SAMSUNG", "LG", "WHYNTER"}; if(results_10.decode_type>=1&&results_10.decode_type<=13){ type=typelist[results_10.decode_type]; } Serial.print("IR TYPE:"+type+" "); Serial.println(ir_item); delay(1000); irrecv_10.resume(); } else { } if (ir_item == 16615543) { setRomeoMotor(1, 50); setRomeoMotor(2, 53); }//前进 if (ir_item == 16619623) { setRomeoMotor(1, -50); setRomeoMotor(2, -53); }//后退 if (ir_item == 16591063) { setRomeoMotor(1, 10); setRomeoMotor(2, 50); delay(400); setRomeoMotor(1, 50); setRomeoMotor(2, 53); }//左转90°,继续前进 if (ir_item == 16607383) { setRomeoMotor(1, 50); setRomeoMotor(2, 10); delay(400); setRomeoMotor(1, 50); setRomeoMotor(2, 53); }//右转90°,继续前进 if (ir_item == 16621663) { if (!digitalRead(8) && digitalRead(9)) { setRomeoMotor(1, 10); setRomeoMotor(2, 50); } else { if (digitalRead(8) && !digitalRead(9)) { setRomeoMotor(1, 50); setRomeoMotor(2, 10); } else { setRomeoMotor(1, 50); setRomeoMotor(2, 53); } } }//巡线 if (ir_item == 16580863) { setRomeoMotor(1, 0); setRomeoMotor(2, 0); }//停止 } |
© 2013-2025 Comsenz Inc. Powered by Discuz! X3.4 Licensed