I need help with controlling a DC motor with an H bridge and IR sensor

what i want to do is to have two buttons from a IR remote controlling if a motor goes one way or the other way with an H bridge while also being able to control the speed of the motor using a potentiometer. I did my connections on TinkerCad Circuits and it worked out fine but when i tried doing it IRL it wouldnt do anything. any suggestions?

circuit of a test I did on my school cromebook on TinkerCad (it works):

code from said test:

#include <IRremote.h>

const int forward_pin=5;
const int backward_pin=6;
const int potentiometer_pin=A0;
const int speed_pin=9;
const int rcvPin=3;
int potentiometer;
int speed;

IRrecv irrecv(rcvPin);

decode_results results;

void setup(){
  Serial.begin(9600);
  irrecv.enableIRIn();
  
  pinMode(5,OUTPUT);
  pinMode(6,OUTPUT);
}

void loop(){
  potentiometer=analogRead(potentiometer_pin);
  speed=map(potentiometer,0,1023,0,255);
  analogWrite(speed_pin,speed);
  
   if(IrReceiver.decode()){
  auto value=IrReceiver.decodedIRData.decodedRawData;
  switch(value)
{
  case 4077698816:
      Serial.println("0");
      digitalWrite(6,LOW);
      digitalWrite(5,LOW);
  break;
  
  case 4010852096:
      Serial.println("1");
      digitalWrite(6,LOW);
      digitalWrite(5,HIGH);
  break;
    
  case 3994140416:
      Serial.println("2");
      digitalWrite(6,HIGH);
      digitalWrite(5,LOW);
  break;
                       
  default: Serial.println(value);
}
      IrReceiver.resume();
   }
}

the code i have now:

#include <IRremote.h>

const int forward_pin=5;
const int backward_pin=6;
const int potentiometer_pin=A0;
const int speed_pin=9;
const int rcvPin=3;
int potentiometer;
int speed;

IRrecv irrecv(rcvPin);

decode_results results;

void setup(){
  Serial.begin(9600);
  irrecv.enableIRIn();

  pinMode(5,OUTPUT);
  pinMode(6,OUTPUT);
}

void loop(){
  potentiometer=analogRead(potentiometer_pin);
  speed=map(potentiometer,0,1023,0,255);
  analogWrite(speed_pin,speed);

  if(IrReceiver.decode()){
    auto value=IrReceiver.decodedIRData.decodedRawData;
    switch(value)
{
    case 4077698816:
        Serial.println("0");
        digitalWrite(6,LOW);
        digitalWrite(5,LOW);
    break;
      
    case 4010852096:
        Serial.println("1");
        digitalWrite(6,LOW);
        digitalWrite(5,HIGH);
    break;
      
     
    case 3994140416:
        Serial.println("2");
        digitalWrite(6,HIGH);
        digitalWrite(5,LOW);
    break;e

    default: Serial.println(value);
}
        IrReceiver.resume();
  }
}

Are you using a 9V battery to control the motor?
These batteries are not suitable for this project.
For the motor, use a separate power supply that supports the motor current, and don't forget to connect the GND of this power supply to the GND of the Arduino.

A circuit diagram (annotated schematic) will help us see what you’re thinking.

I did some image processing in an attempt to identify your motor driver but the results were not conclusive...

It might be an L293D, but that could just be my imagination:

It's good you worked the bugs out with Tinkercad, but his motor does not need to stop before it can change directions. Your physical motor must actually come to a complete stop before turning the opposite direction. That takes time.

From what i know the motor can take 12 volts but i also don’t really know the motors specs

Ok thanks for the recommendation

It is a L293D

So should I add some sort of delay or like pause

Think about what you mean when you write that you want to control something. In order to control, you need to know what it is doing and decide if that is what you want or not. You want to control speed, you want to control direction, but in reality all you are doing is commanding speed and commanding direction. You are using your own personal visual feedback to know if the motor is doing what you want. Your project does not provide any way for your program to know what the motor is doing.

If you are ok with waiting and hoping the motor is going to stop before reversing rotation, then waiting is the thing to do.

The circuit could not possibly work on tinkercad or IRL
You have the positive and negative of the battery shorted together

Do you see your Serial.println() outputs on the serial monitor?

One of them should set pin 6 to output...

Wdym?

See the connections in the green circle

What do I do with them I still don’t understand

I fixed it but it still won’t work

Connect everything like you show in you first diagram done on school chrombook.
The second diagram is totally wrong and will never work

Yes every time i pressed button 1, 2, or even the newly added 0 it showed those numbers

@jim-p I don't see a short in your green circle. Were you thrown off by the fact that the breadboard rotated 90° compared to the Chromebook version of the diagram?

@bro1243 Why did you delete all those images from your OP?