correcting of my arduino's program

(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 :confused:

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 !!

incomingByte is firstly not a byte, its an int, and secondly
its uninitialised and never set.... Is this the whole sketch?

Thank you for the reply, but I dont understand what you mean.
can you change my code, so I can see better what you mean ?

Yes it’s the whole sketch …


"incomingByte" is never given a value.
Where is it supposed to come from?
You haven't initialised the Serial interface, so it can't come from there.

It's your school project - we'll help you, but we won't write code for you.

In your loop, you use the value of incomingByte in this line:

    if (incomingByte == 'Z') {

but you never set it to a value such as like this:

  incomingByte = '!';

Where is this byte supposed to be incoming from? It's coming from the keyboard. So you need to set it somehow:

  incomingByte = read_a_byte_from_the_keyboard();

Try figuring this code out and then review the earlier comments for this post:

char inByte;

void setup()
  // start serial port at 9600 bps 

void loop()

  if (Serial.available() > 0) {
    // get incoming byte:
    inByte =;
    Serial.print("You entered: ");

Run the Serial monitor (Tools --> Serial Monitor, or Ctrl-Shift-M) and type in a letter on the input textbox and then click Send.