小弟最近在做一个arduino的报告 内容是模拟汽车的牵引力控制系统 之前没接触过arduino 有些疑问 还请大哥些指教
我的设计是用arduino控制4个DC马达以模拟汽车轮胎 先把马达随意设定成150-255不等的速度 然后用编程把这些速自动度降到一个最低速度的那个马达上面去 但是我试过跑这个程序 速度没有变化 还是我之前设定的那些速度(比如180 180 255 255,理想的是全部变成180)
具体编程如下:
int motorPin1 = 3;
int motorPin2 = 6;
int motorPin3 = 9;
int motorPin4 = 11;
void setup()
{
pinMode (motorPin1, OUTPUT);
pinMode (motorPin2, OUTPUT);
pinMode (motorPin3, OUTPUT);
pinMode (motorPin4, OUTPUT);
}
void loop()
{
analogWrite(motorPin1, 180);//effective of slipping wheel
analogWrite(motorPin2, 180);
analogWrite(motorPin3, 255);
analogWrite(motorPin4, 255);
//delay(5000);
if (motorPin1 >
motorPin2);
analogWrite(motorPin1, motorPin2);
if (motorPin1 > motorPin3);
analogWrite(motorPin1, motorPin3);
if (motorPin1 > motorPin4);
analogWrite(motorPin1, motorPin4);
if (motorPin2 > motorPin1);
analogWrite(motorPin2, motorPin1);
if (motorPin2 > motorPin3);
analogWrite(motorPin2, motorPin3);
if (motorPin2 > motorPin4);
analogWrite(motorPin2, motorPin4);
if (motorPin3 > motorPin1);
analogWrite(motorPin3, motorPin1);
if (motorPin3 > motorPin2);
analogWrite(motorPin3, motorPin2);
if (motorPin3 > motorPin4);
analogWrite(motorPin3, motorPin4);
if (motorPin4 > motorPin1);
analogWrite(motorPin4, motorPin1);
if (motorPin4 > motorPin2);
analogWrite(motorPin4, motorPin2);
if (motorPin4 > motorPin3);
analogWrite(motorPin4, motorPin3);
}
|