IRremote library "Error Compilling" Help!

Hello!

I’m working on my DFRobotShop Rover and I’m trying to control my car via Infrared and using IRremote library(github.com/shirriff/Arduino-IRremote).

However, After I verify the code it appear the error message:

Below is my code:

[code]

////重复码的部分没处理好,我按着不放,它就动一下就不动了
#include <IRremote.h>
#include <IRremoteInt.h>

//红外遥控逻辑代码 自己通过串口监视器可以找出
#define UP 0xC26BF044 //我的遥控器UP键
#define DOWN 0xC4FFB646 //我的遥控器DOWN键
#define LEFT 0x758C9D82 //我的遥控器LEFT键
#define RIGHT 0x53801EE85LL //我的遥控器RIGHT键
#define STOP 0x8AF13528 //我的遥控器STOP键

/To control the rover, Copy and paste the code below into the Arduino software/
int E1 = 6; //M1 Speed Control
int E2 = 5; //M2 Speed Control
int M1 = 8; //M1 Direction Control
int M2 = 7; //M2 Direction Control

int RECV_PIN = 11; //红外接收信号引脚

IRrecv irrecv(RECV_PIN);//初始化

decode_results results;//定义结构体类型

void setup(void)
{
int i;
for(i=5;i<=8;i++)
pinMode(i, OUTPUT);
Serial.begin(9600);

irrecv.enableIRIn(); // 开始接收
}

void loop(void)
{
if (irrecv.decode(&results))
{
Serial.println(results.value, HEX);

int leftspeed = 255;
int rightspeed = 255;

    switch(results.value)
    {
          case UP://2键前进
            forward (leftspeed,rightspeed);
            break;
          case DOWN://4键左转
            reverse (leftspeed,rightspeed);
            break;
          case LEFT://8键后退
            left (leftspeed,rightspeed);
            break;
          case RIGHT://6键右转
            right (leftspeed,rightspeed);
            break;
          case STOP://5键前进
            stop();
            break;
         default:
            stop();
            delay(100);
    }
    irrecv.resume(); // Receive the next value

}
stop();//松开按钮停止
}

void stop(void) //Stop
{
digitalWrite(E1,LOW);
digitalWrite(E2,LOW);
}
void forward(int a,int b)
{
analogWrite (E1,a);
digitalWrite(M1,LOW);
analogWrite (E2,b);
digitalWrite(M2,LOW);
}
void reverse (int a,int b)
{
analogWrite (E1,a);
digitalWrite(M1,HIGH);
analogWrite (E2,b);
digitalWrite(M2,HIGH);
}
void left (int a,int b)
{
analogWrite (E1,a);
digitalWrite(M1,HIGH);
analogWrite (E2,b);
digitalWrite(M2,LOW);
}
void right (int a,int b)
{
analogWrite (E1,a);
digitalWrite(M1,LOW);
analogWrite (E2,b);
digitalWrite(M2,HIGH);
}[/code]

Please help me figure out what’s wrong with my program.

Thank you!
Tony

Hello!Casmat

Thank you for your suggestion. After I remove the " #include <IRremoteInt.h> " It works without any issues. Hope the following code is useful for anyone who want to use their TV IR remote to control their DFRobotshop Rover.

P.S: don’t forget to create a library and upload the IRremote file in it.



///重复码的部分没处理好,我按着不放,它就动一下就不动了
#include <IRremote.h>


#define E1 6//左电机引脚

#define E2 5

#define M1 8//右电机引脚

#define M2 7

//红外遥控逻辑代码  自己通过串口监视器可以找出
#define UP    0xC26BF044    //我的遥控器UP键
#define DOWN  0xC4FFB646    //我的遥控器DOWN键
#define LEFT  0x758C9D82    //我的遥控器LEFT键
#define RIGHT 0x53801EE8   //我的遥控器RIGHT键
#define STOP  0x8AF13528    //我的遥控器STOP键


int RECV_PIN = 11;     //红外接收信号引脚

IRrecv irrecv(RECV_PIN);//初始化

decode_results results;//定义结构体类型

void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // 开始接收
}

void loop() 
{
  if (irrecv.decode(&results))
  {
        Serial.println(results.value, HEX);

        switch(results.value)
        {
              case UP://2键前进
              advance(255);
              break;
              case LEFT://4键左转
              left_handed(255);
              break;
              case DOWN://8键后退
              retreat(255);
              break;
              case RIGHT://6键右转
              right_handed(255);
              break;
              case STOP://5键前进
              stop_m();
              break;
             default:
delay(100);

        }
        irrecv.resume(); // Receive the next value
  }
  
stop_m();


}




void foreward_mechine_a()//左电机正转
{
    analogWrite(E1,255);
    digitalWrite(M1,LOW);

}
void inversion_mechine_a()//左电机反转
{
    analogWrite(E1,255);
    digitalWrite(M1,HIGH);

  
}

void stop_a(void)//左电机停止
{
      digitalWrite(E1,LOW);

}

void stop_b(void)//右电机停止
{
      digitalWrite(E2,LOW);

}

void foreward_mechine_b()//右电机正转
{
    analogWrite(E2,255);
    digitalWrite(M2,LOW);

}
void inversion_mechine_b()//右电机反转
{
    analogWrite(E2,255);
    digitalWrite(M2,HIGH);
 
}
void advance(int time)//小车前进
{
     foreward_mechine_a();
     foreward_mechine_b();
    delay(time);  
}
void retreat(int time)//小车后退
{
      inversion_mechine_a();
      inversion_mechine_b();
      delay(time);  
}

void left_handed(int time)//小车左转
{
    inversion_mechine_a();
    foreward_mechine_b();
    delay(time);
    
}
void right_handed(int time)//小车右转
{
    foreward_mechine_a();
    inversion_mechine_b();
    delay(time);
}
void stop_m(void)//小车停止
{
      stop_a();
      stop_b();
}

Hi!

Just want to know does this “DFRobot 7.4V Lipo 2200mAh Battery” work for DFRobotshop Rover’s motor?

I have a issues with the “SFE Lithium Polymer Battery Cell - 3.7V 1000mAh” which come with the kit. When I use this battery( fully charged batteries) to run, rover immediately shut down the power. However, It works fine with the 4AA pack and 12V Barrel. so I think it might because the voltage is too low.

Does there have any way to solve this problem?

Thank you!
Tony

[video=youtube_share;cVtBO1qdWE0]http://youtu.be/cVtBO1qdWE0

Hello!

I was using the “RB-See-137 (2Ah)” when I first received my shipment, and I’ve know there are known issues with RB-See-137. so I e-mail your support team to exchange a new one, and they send me the RB-Spa-109 (1Ah) which make my motor to work when I just plug the charged new 1Ah battery into the DFRobotShop Rover’s white JST connector.

But, now I’m trying to use the Solar charger shield for my rover, however, When I’m jumping the wire between Vin and 5V on the solar shield v2.0 the power shut down immediately.the robot’s motor work on the JST connector but not work on the “BAT” plug in the shield.

Do you have any ways to make robot’s motor to work when I’m jumping the wire between the Vin and 5V?

Thank you for your help!

Tony

Hi!

How can I wire it differently? if not jumping between the Vin and 5V pin. I’was following the video showing on youtube you guys posting on here.

robotshop.com/forum/showthread.php?702-DFRobotShop-Rover/page8

The video show that robot’s motor works well when connected the battery to the shield and jumping between the 5v and Vin pin.

Why does this work? and my doesn’t work?

Is this why the power shut down immediately?

By the way, What is the best way to charger the battery? the solar shield or rover itself by using the onboard charger? If i use the onboard charger, How can I know that the battery is fully charged?

Thanks you so much for your help!

You might want to try using an older version of Arduino since the library code might not be up to date with the latest Arduino release.

The default motors which are included with the DFRobotShop Rover operate at 3-4V nominal, so 7.4V LiPo is not ideal. If you want to use a 7.4V LiPo, we suggest changing the motors to these which operate at 6V nominal. It’s odd that the rover shuts down as you show in the video - we have tested the 3.7V battery extensively and have not had any issues with the rover. Can you verify that the On/Off switch is set to On (towards the middle of the board) - I know, odd question considering it works with the other two? Can you check the charged voltage of the battery? Are you using the onboard charger? Note that if you use the 4xAA pack or the barrel connector, you need to remove the LiPo jumper so the USB won’t try to charge the NiMh batteries using the LiPo charger.

The DFRobotShop Rover V1.5 and V2 include an onboard LiPo charger at the left rear of the board. This allows you to plug in a USB cable and charge a 3.7V LiPo battery. If you do NOT use a 3.7V LiPo battery (for example the 4xAA battery pack with NiMh, NiCd or Alkaline batteries), then you need to remove the jumper at the left rear of the board so when you plug the USB cable from the computer to the Rover, it will not try to charge these batteries using the charger.

Yes, it’s probably best to remove the LiPo jumper when using the shield and solar cell. You need to follow the user manual for the shield.

The V1.0 XBee and BT versions of the DFRobotShop Rover came with the solar shield V1.0. You are likely using a much more recent version. From the manual:

Please confirm - what is the product code for the LiPo battery you are using? is it RB-Spa-109 (1Ah) or RB-See-137 (2Ah)? There are known issues with RB-See-137.

There is also a chance that the new solar charger shield cannot handle the required startup current for the motors - if you plug the charged battery into the DFRobotShop Rover’s white JST connector, does the robot work properly?

This is very important to know. It means that the DFRobotShop Rover PCB and the battery itself are fine.

In the user guide, it clearly indicates that the “maximum current provided by the board can get up to 700mA

The board shuts down because the current draw is too high (powering the Arduino and the motors). Therefore if you want to charge the battery while you operate the rover (rather than separately), you will need to wire it differently. The user guide does not indicate that you can charge the battery and use it at the same time.

We had a brief meeting and confirm that the Solar Power Shield can be used to charge the battery, but then you need to disconnect the battery and plug it into the DFRobotShop Rover to use it. The original solar shield did not have the 700mA maximum current protection. Therefore having the shield connected to the Rover has no effect; you cannot leave the Rover by the window, have it charge the battery and then use the Rover without physically changing the plug the battery is connected to. If anyone in the community sees a relatively easy solution, feel free to comment.

Correct. When both motors are in operation, the system consumes about 1A (too much for the shield) so it shuts down to protect itself. The best way to charge the LiPo battery on a V1.5 or V2 board is using the onboard LiPo charger; assuming you have the jumper installed, plug the battery into the JST connector and plug the USB cable between your computer and the robot. The USB will automatically charge the battery. The battery takes about 5-7 hours to charge. It’s a really simple circuit, so the only way to tell is to check if the battery is charged is with a multimeter (should be at ~3.74V).