Hi,
(first of all I apologize for my English , I’m French)
I need help to advance my school project ,
It is to control the speed of a car has 2 moteurs at the rear and a ball to the middle.
It is necessary that when I click on ‘Z’ , the speed was 150 is incremented to 250. That’s all for now.
I 'm trying to transfer my program but this does not work, yet it does there is no error message
int incomingByte;
int pwma = 3; // motor A
int pwmb = 11; // motor B
int dira = 12;
int dirb = 13;
int vara; // spped of motor A
int varb; // speed of motor B
void setup() {
pinMode(pwma, OUTPUT);
pinMode(pwmb, OUTPUT);
pinMode(dira, OUTPUT);
pinMode(dirb, OUTPUT);
vara = 150; // speed motor A 150/255
varb = 150; // speed motor B 150/255
}
void loop() {
// if I click on Z (in the keyborad)
if (incomingByte == 'Z') {
if ( vara < 251 ) //As the speed of motor A < 251 , the speed can increase
{vara = vara + 100;} // Speed of Motor A +100 (it's increases from 150 to 250)
if ( varb < 251 ) //As the speed of motor B < 251 , the speed can increase
{varb = varb + 100;} // Speed of Motor A +100 (it's increases from 150 to 250)
analogWrite(pwma, vara);
analogWrite(pwmb, varb);
digitalWrite(dira, HIGH);
digitalWrite(dirb, HIGH);
}
}
thank you very much !!