Problem with IR controlling dc motor

Hi,
i have a problem with controlling dc motor (mot1n) (l293d is driver) with ir remote and ir receiver (tl1838). When send the signal to, for example spin left, it starts spinning left and when i try spinning it right it does not spin and vice versa. It stops reading the after the first ir signal (it only reads ones), i checked with Serial monitor. I'm almost 100% sure it is software problem so here is the code. I attached the pic too, just in case. If you need any other info, just ask.

#include <IRremote.h>
int receivePin = 11;
IRrecv irrecv(receivePin);
decode_results results;

#define napred 0x806D9980
#define nazad 0x7F6D97EF

int dir1 = 3;
int dir2 = 2;
int SpeedPin = 5;
int led1 = 7;
int led2 = 8;

void setup(){
irrecv.enableIRIn();
pinMode(dir1, OUTPUT);
pinMode(dir2, OUTPUT);
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(SpeedPin, OUTPUT);
Serial.begin(115200);
}
void loop(){
if (irrecv.decode(&results)){
unsigned int value = results.value;
switch(value){
case napred:
digitalWrite(dir1, HIGH);
digitalWrite(dir2, LOW);
analogWrite(SpeedPin, 255);
digitalWrite(led1, HIGH);
digitalWrite(led2, LOW);
break;
case nazad:
digitalWrite(dir1, LOW);
digitalWrite(dir2, HIGH);
analogWrite(SpeedPin, 255);
digitalWrite(led2, HIGH);
digitalWrite(led1, LOW);
break;
}
Serial.println(value);
irrecv.resume();
}
}

I connected a 754410 (L293 equivalent) and an IR decoder to my Uno and tried your code. I had to make a few minor changes but it works just fine. I added a stop function, put in the codes for my remote and fixed the data type for the value variable. It needs to be unsigned long to match the key codes (they are 32 bit numbers).

I cannot see if the ground is from the breadboard to the Uno. It must be. How is the motor powered? Motors draw a large amount of current when starting. The motor power supply must be capable of supplying that stall (starting) current. The motor stall current should be listed in its data sheet. What is the motor stall current? The motor could be pulling the power supply voltage down and effecting the processor (MCU). Can you monitor the power with your DMM to see if it is effected by the motor starting?

Here is the code that works as expected for me. Press 1 and it runs clock wise, 2 and it runs counter clock wise and 3 stops the motor. You will need to insert your IR remote's key codes.

#include <IRremote.h>
int receivePin = 11;
IRrecv irrecv(receivePin);
decode_results results;

// ******************** change to match your remote ********************
#define napred 0x4EB3C837
#define nazad 0x4EB308F7
#define stop 0x4EB38877

int dir1 = 3;
int dir2 = 2;
int SpeedPin = 5;
int led1 = 7;
int led2 = 8;


void setup()
{
   irrecv.enableIRIn();
   pinMode(dir1, OUTPUT);
   pinMode(dir2, OUTPUT);
   pinMode(led1, OUTPUT);
   pinMode(led2, OUTPUT);
   pinMode(SpeedPin, OUTPUT);
   Serial.begin(115200);
}

void loop()
{
   if (irrecv.decode(&results))
   {
      unsigned long value = results.value;  // ****** change to unsigned long
      switch (value)
      {
         case napred:
            digitalWrite(dir1, HIGH);
            digitalWrite(dir2, LOW);
            analogWrite(SpeedPin, 255);
            digitalWrite(led1, HIGH);
            digitalWrite(led2, LOW);
            break;
         case nazad:
            digitalWrite(dir1, LOW);
            digitalWrite(dir2, HIGH);
            analogWrite(SpeedPin, 255);
            digitalWrite(led2, HIGH);
            digitalWrite(led1, LOW);
            break;
         case stop:
            digitalWrite(dir1, LOW);
            digitalWrite(dir2, LOW);
            analogWrite(SpeedPin, 0);
            digitalWrite(led2, LOW);
            digitalWrite(led1, LOW);
      }
      Serial.println(value, HEX);
      irrecv.resume();
   }
}

This is how code should be posted. Read the how get the most out of this forum sticky to see how to properly post code. Remove useless white space and format the code with the IDE autoformat tool (crtl-t or Tools, Auto Format) before posting code.

i figured it out! when motor starts rotating it creates a lot of buzz around it, like static. So it interferes the ir signals. i had to add a couple of capacitors and twist the conductors but it works perfectly now. thank you anyway.