Arduino code uploaded success but nothing happens arduino uno

already tried, but nothing happens

Time for the night-shift to take over.

1 Like

Your basic problem seems to be,
you have a sketch that is written for a different library version than the one you are using.

Converting your 2.x program to the 3.x version

symptom:

warning: 'bool IRrecv::decode(decode_results*)' is deprecated: Please use IrReceiver.decode() without a parameter and IrReceiver.decodedIRData. . [-Wdeprecated-declarations]

There are a couple of other unrelated oopsies, value and pins mixed up.

1 Like

A very interesting solution, indeed.

1 Like

Here is your sketch, modified to work with the latest IRremote library and with some debug output added so we can make a guess as to what is not working (if you give it a try and show us what it shows you on Serial Monitor).

#include <IRremote.h>
int IRpin = 4;
String kodeKu;

struct kode
{
  uint32_t kodeValue;
  const char * ku;
} KodeList[] =
{
  {0xFF9867, "NOL"},
  {0xFFA25D, "SATU"},
  {0xFF629D, "DUA"},
  {0xFFE21D, "TIGA"},
  {0xFF22DD, "EMPAT"},
  {0xFF02FD, "LIMA"},
  {0xFFC23D, "ENAM"},
  {0xFFE01F, "TUJUH"},
  {0xFFA857, "DELAPAN"},
  {0xFF906F, "SEMBILAN"},
  {0xff6897, "BINTANG"},
  {0xFFB04F, "PAGAR"},
  {0xFF18E7, "UP"},
  {0xFF4AB5, "DOWN"},
  {0xFF5AA5, "FORWARD"},
  {0xFF10EF, "REWIND"},
  {0xFF38C7, "OK"},
};

const char * GetKodeKu(uint32_t kode)
{
  size_t kuCount = sizeof KodeList / sizeof KodeList[0];
  for (size_t i = 0; i < kuCount; i++)
  {
    if (KodeList[i].kodeValue == kode)
    {
      Serial.print("Recognized as ");
      Serial.println(KodeList[i].ku);

      return KodeList[i].ku;
    }
  }
  Serial.println("Kode Not Recognized");
  return "";
}

const int relayPin = 7;

const int motor1pin1 = 8; //in1 motor1
const int motor1pin2 = 12; //in2 motor1
const int motor1pin3 = 11; //enable motor1
int mSpeed1 = 50;

const int motor2pin1 = A0; //in1 motor2
const int motor2pin2 = A1; //in2 motor2
const int motor2pin3 = 10; //enable motor2
int mSpeed2 = 50;

const int motor3pin1 = A2; //in1 motor3
const int motor3pin2 = A3; //in2 motor3
const int motor3pin3 = 9; //enable motor3
int mSpeed3 = 50;

const int motor4pin1 = A4; //in1 motor4
const int motor4pin2 = A5; //in2 motor4
const int motor4pin3 = 6; //enable motor4
int mSpeed4 = 50;

void setup()
{
  // put your setup code here, to run once:
  Serial.begin(115200);
  delay(200);
  Serial.println("setup()");

  IrReceiver.begin(IRpin);

  pinMode (relayPin, OUTPUT);

  pinMode(motor1pin1, OUTPUT); //in1 pin motor1
  pinMode(motor1pin2, OUTPUT); //in2 pin motor1
  pinMode(motor1pin3, OUTPUT); //enable pin motor1

  pinMode(motor2pin1, OUTPUT); //in1 pin motor2
  pinMode(motor2pin2, OUTPUT); //in2 pin motor2
  pinMode(motor2pin3, OUTPUT); //enable pin motor2

  pinMode(motor3pin1, OUTPUT); //in1 pin motor3
  pinMode(motor3pin2, OUTPUT); //in2 pin motor3
  pinMode(motor3pin3, OUTPUT); //enable pin motor3

  pinMode(motor4pin1, OUTPUT); //in1 pin motor4
  pinMode(motor4pin2, OUTPUT); //in2 pin motor4
  pinMode(motor4pin3, OUTPUT); //enable pin motor4

  IrReceiver.enableIRIn();
}

void loop()
{
  Serial.println("loop()");

  // put your main code here, to run repeatedly:
  while (IrReceiver.decode() == 0);
  unsigned long value = IrReceiver.decodedIRData.decodedRawData;
  Serial.print("Received: ");
  Serial.println(value, HEX);
  IrReceiver.resume();

  kodeKu = GetKodeKu(value);

  if (kodeKu == "OK")
  {
    digitalWrite(relayPin, LOW);
  }
  else
  {
    digitalWrite(relayPin, HIGH);
  }

  if (kodeKu == "SATU")
  {
    digitalWrite (motor1pin1, HIGH);
    digitalWrite (motor1pin2, LOW);
    analogWrite (mSpeed1, 50);
  }
  else
  {
    digitalWrite (motor1pin1, LOW);
    digitalWrite (motor1pin2, LOW);
    analogWrite (mSpeed1, 0);
  }

  if (kodeKu == "FORWARD")
  {
    (mSpeed1 = mSpeed1 + 10);
    if (mSpeed1 > 255)
      mSpeed1 = 50;
    analogWrite(motor1pin3, mSpeed1);
  }

  if (kodeKu == "REWIND")
  {
    (mSpeed1 = mSpeed1 - 10);
    if (mSpeed1 < 0)
      mSpeed1 = 0;
    analogWrite(motor1pin3, mSpeed1);
  }

  if (kodeKu == "DUA")
  {
    digitalWrite (motor2pin1, HIGH);
    digitalWrite (motor2pin2, LOW);
    analogWrite (mSpeed2, 50);
  }
  else
  {
    digitalWrite (motor2pin1, LOW);
    digitalWrite (motor2pin2, LOW);
    analogWrite (mSpeed2, 0);
  }

  if (kodeKu == "UP")
  {
    (mSpeed2 = mSpeed2 + 10);
    if (mSpeed2 > 255)
      mSpeed2 = 50;
    analogWrite(motor2pin3, mSpeed2);
  }

  if (kodeKu == "DOWN")
  {
    (mSpeed2 = mSpeed2 - 10);
    if (mSpeed2 < 0)
      mSpeed2 = 0;
    analogWrite(motor2pin3, mSpeed2);
  }

  if (kodeKu == "TIGA")
  {
    digitalWrite (motor3pin1, HIGH);
    digitalWrite (motor3pin2, LOW);
    analogWrite (mSpeed3, 50);
  }
  else
  {
    digitalWrite (motor3pin1, LOW);
    digitalWrite (motor3pin2, HIGH);
    analogWrite (mSpeed3, 50);
  }

  if (kodeKu == "PAGAR")
  {
    (mSpeed3 = mSpeed3 + 10);
    if (mSpeed3 > 255)
      mSpeed3 = 50;
    analogWrite(motor3pin3, mSpeed3);
  }

  if (kodeKu == "BINTANG")
  {
    (mSpeed3 = mSpeed3 - 10);
    if (mSpeed3 < 0)
      mSpeed3 = 0;
    analogWrite(motor3pin3, mSpeed3);
  }

  if (kodeKu == "NOL")
  {
    digitalWrite (motor3pin1, LOW);
    digitalWrite (motor3pin2, LOW);
    analogWrite (mSpeed3, 0);
  }

  if (kodeKu == "EMPAT")
  {
    digitalWrite (motor4pin1, HIGH);
    digitalWrite (motor4pin2, LOW);
    analogWrite (mSpeed4, 50);
  }
  else
  {
    digitalWrite (motor4pin1, LOW);
    digitalWrite (motor4pin2, HIGH);
    analogWrite (mSpeed4, 50);
  }

  if (kodeKu == "SEMBILAN")
  {
    (mSpeed4 = mSpeed3 + 10);
    if (mSpeed4 > 255)
      mSpeed4 = 50;
    analogWrite(motor4pin3, mSpeed4);
  }

  if (kodeKu == "TUJUH")
  {
    (mSpeed4 = mSpeed4 - 10);
    if (mSpeed4 < 0)
      mSpeed4 = 0;
    analogWrite(motor4pin3, mSpeed4);
  }

  if (kodeKu == "DELAPAN")
  {
    digitalWrite (motor4pin1, LOW);
    digitalWrite (motor4pin2, LOW);
    analogWrite (mSpeed4, 0);
  }
}
1 Like

woww .... really thanks alot, yes you are correct. now i start learn coding with this version 3.x of irremote library.

Hi Mr. Wasser, thanks a lot for your effort modified of my coding. it is very helfull . when i read your modified coding, a lot of statement which i never touch before during learn of coding. because i am really new in coding.

I will let you know after testing and learn one by one the statements in your modified coding. once again thanks a lot.

also to all the forum member thank you. I am really apreciate of all your respons. thank you.

verify and upload are success.
in serial monitor appear :
setup( )
loop( )
Received: 0
Kode Not Recognized
loop( )

but when i touch "OK" button in serial monitor appear :
Received: E31CFF00
Kode Not Recognized
loop()
Received: 0
Kode Not Recognized
loop()

but i still could not get what i expected. its look like the code list and the code received are different!

is this code testing require in full complete circuits?

for me your coding are more advance. but really give me a challenge how to understand coding especially with aduino ide.

Just press all the buttons you are interested and see what value comes out on the Serial Monitor. Then, go back into the code and update your KodeList[] array with these new values.
Re-compile and upload the code and do it again.

1 Like

yes , your suggesting really work out. first the button code keep changing then i try a few times till get code working one. but there is another problem that when :
Received: F807FF00
Recognized as TUJUH
loop()
Receiv⸮
(the highligth one can come to any button, this one just for example one).
button become hang / stuck. no respons at all. then i rest the board, working again till the highligh one come out then hang again and again.

what is the meaning of that kind of sign? thank you

Rather than guessing, please post your new code (with code tags) as well as the output from the Serial Monitor (again, with code tags, not a picture) so we can all see.

below the code with correct remote code.

#include <IRremote.h>
int IRpin = 4;
String kodeKu;

struct kode
{
  uint32_t kodeValue;
  const char * ku;
} KodeList[] =
{
  {0xE619FF00, "NOL"},
  {0xBA45FF00, "SATU"},
  {0xB946FF00, "DUA"},
  {0xB847FF00, "TIGA"},
  {0xBB44FF00, "EMPAT"},
  {0xBF40FF00, "LIMA"},
  {0xBC43FF00, "ENAM"},
  {0xF807FF00, "TUJUH"},
  {0xEA15FF00, "DELAPAN"},
  {0xF609FF00, "SEMBILAN"},
  {0xE916FF00, "BINTANG"},
  {0xF20DFF00, "PAGAR"},
  {0xE718FF00, "UP"},
  {0xAD52FF00, "DOWN"},
  {0xA55AFF00, "FORWARD"},
  {0xF708FF00, "REWIND"},
  {0xE31CFF00, "OK"},
};

const char * GetKodeku(uint32_t kode)
{
  size_t kuCount = sizeof KodeList / sizeof KodeList[0];
  for (size_t i = 0; i < kuCount; i++)
  {
    if (KodeList[i].kodeValue == kode)
    {
      Serial.print("Recognized as ");
      Serial.println(KodeList[i].ku);

      return KodeList[i].ku;
    }
  }
  Serial.println("Kode Not Recognized");
  return "";
}

const int relayPin = 7;

const int motor1pin1 = 8; //in1 motor1
const int motor1pin2 = 12; //in2 motor1
const int motor1pin3 = 11; //enable motor1
int mSpeed1 = 50;

const int motor2pin1 = A0; //in1 motor2
const int motor2pin2 = A1; //in2 motor2
const int motor2pin3 = 10; //enable motor2
int mSpeed2 = 50;

const int motor3pin1 = A2; //in1 motor3
const int motor3pin2 = A3; //in2 motor3
const int motor3pin3 = 9; //enable motor3
int mSpeed3 = 50;

const int motor4pin1 = A4; //in1 motor4
const int motor4pin2 = A5; //in2 motor4
const int motor4pin3 = 6; //enable motor4
int mSpeed4 = 50;

void setup()
{
  // put your setup code here, to run once:
  Serial.begin(115200);
  delay(200);
  Serial.println("setup()");

  IrReceiver.begin(IRpin);

  pinMode (relayPin, OUTPUT);

  pinMode(motor1pin1, OUTPUT); //in1 pin motor1
  pinMode(motor1pin2, OUTPUT); //in2 pin motor1
  pinMode(motor1pin3, OUTPUT); //enable pin motor1

  pinMode(motor2pin1, OUTPUT); //in1 pin motor2
  pinMode(motor2pin2, OUTPUT); //in2 pin motor2
  pinMode(motor2pin3, OUTPUT); //enable pin motor2

  pinMode(motor3pin1, OUTPUT); //in1 pin motor3
  pinMode(motor3pin2, OUTPUT); //in2 pin motor3
  pinMode(motor3pin3, OUTPUT); //enable pin motor3

  pinMode(motor4pin1, OUTPUT); //in1 pin motor4
  pinMode(motor4pin2, OUTPUT); //in2 pin motor4
  pinMode(motor4pin3, OUTPUT); //enable pin motor4

  IrReceiver.enableIRIn();
}

void loop()
{
  Serial.println("loop()");

  // put your main code here, to run repeatedly:
  while (IrReceiver.decode() == 0);
  unsigned long value = IrReceiver.decodedIRData.decodedRawData;
  Serial.print("Received: ");
  Serial.println(value, HEX);
  IrReceiver.resume();

  kodeKu = GetKodeku(value);

  if (kodeKu == "OK")
  {
    digitalWrite(relayPin, HIGH);
  }
  else
  {
    digitalWrite(relayPin, LOW);
  }

  if (kodeKu == "SATU")
  {
    digitalWrite (motor1pin1, HIGH);
    digitalWrite (motor1pin2, LOW);
    analogWrite (mSpeed1, 50);
  }
  else
  {
    digitalWrite (motor1pin1, LOW);
    digitalWrite (motor1pin2, LOW);
    analogWrite (mSpeed1, 0);
  }

  if (kodeKu == "FORWARD")
  {
    (mSpeed1 = mSpeed1 + 10);
    if (mSpeed1 > 255)
      mSpeed1 = 50;
    analogWrite(motor1pin3, mSpeed1);
  }

  if (kodeKu == "REWIND")
  {
    (mSpeed1 = mSpeed1 - 10);
    if (mSpeed1 < 0)
      mSpeed1 = 0;
    analogWrite(motor1pin3, mSpeed1);
  }

  if (kodeKu == "DUA")
  {
    digitalWrite (motor2pin1, HIGH);
    digitalWrite (motor2pin2, LOW);
    analogWrite (mSpeed2, 50);
  }
  else
  {
    digitalWrite (motor2pin1, LOW);
    digitalWrite (motor2pin2, LOW);
    analogWrite (mSpeed2, 0);
  }

  if (kodeKu == "UP")
  {
    (mSpeed2 = mSpeed2 + 10);
    if (mSpeed2 > 255)
      mSpeed2 = 50;
    analogWrite(motor2pin3, mSpeed2);
  }

  if (kodeKu == "DOWN")
  {
    (mSpeed2 = mSpeed2 - 10);
    if (mSpeed2 < 0)
      mSpeed2 = 0;
    analogWrite(motor2pin3, mSpeed2);
  }

  if (kodeKu == "TIGA")
  {
    digitalWrite (motor3pin1, HIGH);
    digitalWrite (motor3pin2, LOW);
    analogWrite (mSpeed3, 50);
  }
  else
  {
    digitalWrite (motor3pin1, LOW);
    digitalWrite (motor3pin2, HIGH);
    analogWrite (mSpeed3, 50);
  }

  if (kodeKu == "PAGAR")
  {
    (mSpeed3 = mSpeed3 + 10);
    if (mSpeed3 > 255)
      mSpeed3 = 50;
    analogWrite(motor3pin3, mSpeed3);
  }

  if (kodeKu == "BINTANG")
  {
    (mSpeed3 = mSpeed3 - 10);
    if (mSpeed3 < 0)
      mSpeed3 = 0;
    analogWrite(motor3pin3, mSpeed3);
  }

  if (kodeKu == "NOL")
  {
    digitalWrite (motor3pin1, LOW);
    digitalWrite (motor3pin2, LOW);
    analogWrite (mSpeed3, 0);
  }

  if (kodeKu == "EMPAT")
  {
    digitalWrite (motor4pin1, HIGH);
    digitalWrite (motor4pin2, LOW);
    analogWrite (mSpeed4, 50);
  }
  else
  {
    digitalWrite (motor4pin1, LOW);
    digitalWrite (motor4pin2, HIGH);
    analogWrite (mSpeed4, 50);
  }

  if (kodeKu == "SEMBILAN")
  {
    (mSpeed4 = mSpeed3 + 10);
    if (mSpeed4 > 255)
      mSpeed4 = 50;
    analogWrite(motor4pin3, mSpeed4);
  }

  if (kodeKu == "TUJUH")
  {
    (mSpeed4 = mSpeed4 - 10);
    if (mSpeed4 < 0)
      mSpeed4 = 0;
    analogWrite(motor4pin3, mSpeed4);
  }

  if (kodeKu == "DELAPAN")
  {
    digitalWrite (motor4pin1, LOW);
    digitalWrite (motor4pin2, LOW);
    analogWrite (mSpeed4, 0);
  }
}

below is serial monitor output :
(condition stuck or hang).

setup()
loop()
Received: E31CFF00
Recognized as OK
loop()
Received: 0
Kode Not Recognized
loop()
Received: BA45FF00
Recognized as SATU
loop()
Received: 0
Kode Not Recognized
loop()
Received: B946FF00
Recognized as DUA
loop()
Received: 0
Kode Not Recognized
loop()
Received: B847FF00
Recognized as TIGA
loop()
Received: 0
Kode Not Recognized
loop()
Received: BB44FF00
Recognized as EMPAT
loop()
Received: BF40FF00
Recognized as LIMA
loop()
Received: 0
Kode Not Recognized
loop()
Received: BC43FF00
Recognized as ENAM
loop()
Received: 0
Kode Not Recognized
loop()
Received: F807FF00
Recognized as TUJUH
loop()
Receiv⸮

I am trying to replace with another ir remote, and uno board also, i will let you know the result.

If you are pressing those buttons in order, the next will be DELAPAN which adjusts motor4. It may be that the wiring is not correct and you are shorting something out. That can happen way faster than the actual Serial.print() function to print those results.
You can test this by adding a Serial.flush() call after receiving a code

void loop()
{
  Serial.println("loop()");

  // put your main code here, to run repeatedly:
  while (IrReceiver.decode() == 0);
  unsigned long value = IrReceiver.decodedIRData.decodedRawData;
  Serial.print("Received: ");
  Serial.println(value, HEX);
  // make sure everything is printed before continuing
  Serial.flush();
  IrReceiver.resume();
  ...

Hi, for time being i remove all the code for motors. i need to check remote and uno board first. control relay for controlling on and off only. but after upload the code success. the relay immediately turn on, eventhough i set to LOW as mention in code below.

#include <IRremote.h>
int IRpin = 4;
String kodeKu;

struct kode
{
  uint32_t kodeValue;
  const char * ku;
} KodeList[] =
{
  {0xE619FF00, "NOL"},
  {0xBA45FF00, "SATU"},
  {0xB946FF00, "DUA"},
  {0xB847FF00, "TIGA"},
  {0xBB44FF00, "EMPAT"},
  {0xBF40FF00, "LIMA"},
  {0xBC43FF00, "ENAM"},
  {0xF807FF00, "TUJUH"},
  {0xEA15FF00, "DELAPAN"},
  {0xF609FF00, "SEMBILAN"},
  {0xE916FF00, "BINTANG"},
  {0xF20DFF00, "PAGAR"},
  {0xE718FF00, "UP"},
  {0xAD52FF00, "DOWN"},
  {0xA55AFF00, "FORWARD"},
  {0xF708FF00, "REWIND"},
  {0xE31CFF00, "OK"},
};

const char * GetKodeku(uint32_t kode)
{
  size_t kuCount = sizeof KodeList / sizeof KodeList[0];
  for (size_t i = 0; i < kuCount; i++)
  {
    if (KodeList[i].kodeValue == kode)
    {
      Serial.print("Recognized as ");
      Serial.println(KodeList[i].ku);

      return KodeList[i].ku;
    }
  }
  Serial.println("Kode Not Recognized");
  return "";
  }

const int relayPin = 5;


void setup()
{
  // put your setup code here, to run once:
  Serial.begin(115200);
  delay(200);
  Serial.println("setup()");
  IrReceiver.begin(IRpin);
  pinMode (relayPin, OUTPUT);
  IrReceiver.enableIRIn();
}

void loop()
{
   Serial.println("loop()");

  // put your main code here, to run repeatedly:
  while (IrReceiver.decode() == 0);
  unsigned long value = IrReceiver.decodedIRData.decodedRawData;
  Serial.print("Received: ");
  Serial.println(value, HEX);
  Serial.flush();
  IrReceiver.resume();

  kodeKu = GetKodeku(value);

  if (kodeKu == "OK")
  {
    digitalWrite(relayPin, LOW);
  }
  else
  {
    digitalWrite(relayPin, HIGH);
  }
}

all remote button working normally as per the remote code. mention below.

Received: BA45FF00
Recognized as SATU
loop()
Received: 0
Kode Not Recognized
loop()
Received: B946FF00
Recognized as DUA
loop()
Received: 0
Kode Not Recognized
loop()
Received: B847FF00
Recognized as TIGA
loop()
Received: 0
Kode Not Recognized
loop()
Received: BB44FF00
Recognized as EMPAT
loop()
Received: BF40FF00
Recognized as LIMA
loop()
Received: BC43FF00
Recognized as ENAM
loop()
Received: 0
Kode Not Recognized
loop()
Received: F807FF00
Recognized as TUJUH
loop()
Received: 0
Kode Not Recognized
loop()
Received: EA15FF00
Recognized as DELAPAN
loop()
Received: F609FF00
Recognized as SEMBILAN
loop()
Received: E916FF00
Recognized as BINTANG
loop()
Received: 0
Kode Not Recognized
loop()
Received: E619FF00
Recognized as NOL
loop()
Received: 0
Kode Not Recognized
loop()
Received: F20DFF00
Recognized as PAGAR
loop()
Received: 0
Kode Not Recognized
loop()
Received: E718FF00
Recognized as UP
loop()
Received: 0
Kode Not Recognized
loop()
Received: AD52FF00
Recognized as DOWN
loop()
Received: 0
Kode Not Recognized
loop()
Received: A55AFF00
Recognized as FORWARD
loop()
Received: F708FF00
Recognized as REWIND
loop()
Received: 0
Kode Not Recognized
loop()
Received: E31CFF00
Recognized as OK
loop()
Received: 0
Kode Not Recognized
loop()
Received: E31CFF00
Recognized as OK
loop()
Received: 0
Kode Not Recognized
loop()
Received: E31CFF00
Recognized as OK
loop()
Received: 0
Kode Not Recognized
loop()
Received: 0
Kode Not Recognized
loop()

It's not unusual for relay modules to be active low.

problem is eventhough i put relay :

if (kodeKu == "OK")
{
digitalWrite(relayPin, HIGH);
}
else
{
digitalWrite(relayPin, LOW);

relay immediately turn on after upload finish. looks like my uno board problem?

suppose to relay remain off position before i press OK button

I would write a test program that toggles the relay every few seconds and prints the state of the pin controlling it.

Look like a mistake in your sketch. Your code says: If what I received is "OK", turn off the relay, else turn the relay on.

EVERY INPUT (including unrecognized input) that is not "OK" will turn the relay ON.