control 1 Dc motor with UNO and L293D H-bridge

I’m trying to control 1 Dc motor with UNO and L293D H-bridge

here is the code

const int controlPin1 = 7; // connected to pin 7 on the H-bridge
const int controlPin2 = 8; // connected to pin 2 on the H-bridge
const int enablePin = 5;   // connected to pin 1 on the H-bridge


void setup(){
  pinMode(controlPin1, OUTPUT);
  pinMode(controlPin2, OUTPUT);
  pinMode(enablePin, OUTPUT);
  //analogWrite(enablePin, 0);
  digitalWrite(enablePin, HIGH);
 // digitalWrite(controlPin1, LOW);
  //digitalWrite(controlPin2, HIGH);
Serial.begin(9600); 
}


void loop(){
if (Serial.available() > 0) {
    int inByte = Serial.read();
    
    switch (inByte) {
    case '0':    
     digitalWrite(controlPin1, LOW);
  digitalWrite(controlPin2, LOW);
      break;
    case '1':    
     digitalWrite(controlPin1, LOW);
  digitalWrite(controlPin2, HIGH);
    analogWrite(enablePin, 50);
      break;
          case '2':    
     digitalWrite(controlPin1, LOW);
  digitalWrite(controlPin2, HIGH);
    analogWrite(enablePin, 100);
      break;
          case '3':    
     digitalWrite(controlPin1, LOW);
  digitalWrite(controlPin2, HIGH);
    analogWrite(enablePin, 150);
      break;
          case '4':    
     digitalWrite(controlPin1, LOW);
  digitalWrite(controlPin2, HIGH);
    analogWrite(enablePin, 200);
      break;
          case '5':    
     digitalWrite(controlPin1, LOW);
  digitalWrite(controlPin2, HIGH);
    analogWrite(enablePin, 250);
      break;
}
}
}

the motoro is not moving when i send 1-5 numbers on serial
what i’am doing wrong ?

A couple of things:

  1. Does each separate operation (serial read, motor control, etc) work independently (ie - make sure you have your serial code working, then your motor control code, plus your hardware - then bring them together)? Maybe you have already verified this - but if you haven't, it would be a good place to start.

  2. It appears that you are comparing an integer to a char - that won't work too well, because of casting issues, plus because - for instance - char '0' != int 0; char '0' == int 48 (well, not strictly speaking, because of casting).

Finally - when you code, be sure to maintain a consistent style for variable naming, method/function naming, and especially indentation - this last one, if you don't follow it (which I see you aren't) - will trip you up, when you get an error about a missing brace or such, and you can't follow your indentation to see where you left one off (or put in too many!)...

thanks for replay bro, can you please fix my code, cuz i couldn't understand what you meant

the problem was with the ground pins , i ddnt new that the board was 2 consisted of 2 small boards right , left