DC Motors spin via IR Remote, but won't stop

Hello,

This is more of a circuitry question rather than a coding question, but you need one for the other to be useful so I figured I’d give this a shot. I am working on a project and finally have the code and circuit (see below) assembled much like examples I was able to find online.

#include <IRremote.h>

#define Next 0xFFC23D//insert code for next button
#define Prev 0xFF22DD //insert code for prev button
#define Up 0xFF906F //insert code for up button
#define Down 0xFFE01F //insert code for down button
#define Pause 0xFF02FD //insert code for play/pause button

int receiver_pin = 8; //IR receiver is connected to pin 2 of arduino

int Yellow_motor1 = 11; 
int Yellow_motor2 = 12;
int Black_motor1 = 6;
int Black_motor2 = 5;

IRrecv receiver(receiver_pin); //arduino takes output from receiver
decode_results output;

void setup() {
  Serial.begin(9600);
  receiver.enableIRIn(); //start to take output from IR receiver
  //initializing all pins have connected led's as outputs
  pinMode(Yellow_motor1, OUTPUT);
  pinMode(Yellow_motor2, OUTPUT);
  pinMode(Black_motor1, OUTPUT);
  pinMode(Black_motor2, OUTPUT);

}

void loop() {
  if (receiver.decode(&output)) {
    unsigned int value = output.value;
    Serial.println(output.value, HEX);
    
    switch(value) {
      
      case Next:
        digitalWrite(Yellow_motor1, LOW);
        digitalWrite(Yellow_motor2, HIGH);
        digitalWrite(Black_motor1, HIGH);
        digitalWrite(Black_motor2, LOW);
        break;

      case Prev:
        digitalWrite(Yellow_motor1, HIGH);
        digitalWrite(Yellow_motor2, LOW);
        digitalWrite(Black_motor1, LOW);
        digitalWrite(Black_motor2, HIGH);
        break;

      case Up:
        digitalWrite(Yellow_motor1, LOW);
        digitalWrite(Yellow_motor2, HIGH);
        digitalWrite(Black_motor1, LOW);
        digitalWrite(Black_motor2, HIGH);
        break;

        
      case Down:
        digitalWrite(Yellow_motor1, HIGH);
        digitalWrite(Yellow_motor2, LOW);
        digitalWrite(Black_motor1, HIGH);
        digitalWrite(Black_motor2, LOW);
        break;

      case Pause:
        digitalWrite(Yellow_motor1, LOW);
        digitalWrite(Yellow_motor2, LOW);
        digitalWrite(Black_motor1, LOW);
        digitalWrite(Black_motor2, LOW);
        break;
    }
    receiver.resume();
  }

}

Also, I apologize if the code and image don’t display properly, I haven’t posted either on here before.

Some project information:
I’m trying to get 2 DC motors to spin independently of each other in order to have a structure move forward, backward, spin clockwise, and spin counterclockwise. I have browsed the web for hours (especially the little car tutorials) trying to find some semblance of someone else having this issue but haven’t been able to find many other posts I could use to help me. This problem started recently. For the longest time, when I hit the buttons on the remote to control motors, I would need to nudge them in order to rotate. Now they spin on their own, but won’t stop, even when I physically stop the propeller it starts right back up again. I’m not sure if there’s electricity leaking into the motors from somewhere or not, so hopefully someone can give me some insight.

Some information on the image:
I don’t use a 9V battery, I use 8 AA batteries connected in a series for a total of 12V, still connected like the 9V in the image. I also have the another similar battery bank powering the Arduino when it’s not connected to the computer. When the Arduino was connected to the computer the motors wouldn’t stop spinning, when it’s connected to the second battery bank, they wouldn’t start without help, could that indicate something?

Should I ditch everything I am working on now and purchase a new kit that has all the components to make a car and modify it for my structure?

Every bit of information helps, and if you need clarification on something please ask. I will be traveling in the near future and won’t have access to the internet for a couple of days, but will get caught up with everything next week, so post away!

Does the serial monitor show 0xFF02FD when you press the pause button? Is the battery bank full charged?

When not plugging the Arduino into the computer, how is it powered?

Silly question, are you 100% sure you have the chip oriented correctly?

Correct way has your 12volts going to the motor pin.

If it’s backwards your putting 12volts into logic side with only 5volts going to motors resulting in very poor performance.

Very likely logic side would start “frying” so that would explain your system getting worse also..

Just my thoughts as you seem to have everything else correct.