蓝牙小车想加上PWM控制车速,串口要收前进(F)和200(PWM),请问要怎样改?
[mw_shl_code=c,true]void Forward()
{
analogWrite(MotorLeftEn, 255);
digitalWrite(MotorLeftA, HIGH);
digitalWrite(MotorLeftB, LOW);
analogWrite(MotorRightEn, 255);
digitalWrite(MotorRightA, HIGH);
digitalWrite(MotorRightB, LOW);
Serial.println("Forward");
}
void loop()
{
while(Serial.available()>0)
{
char val = Serial.read();
if(val == 'f'){
Forward();
delay(20);
}
}[/mw_shl_code]
|