Loading...
Pages: [1]   Go Down
Author Topic: IR Remote Code  (Read 147 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

PROBLEM SOLVED! Thanks to HazardMind!
Go to the IRremote library folder -> look for IRremoteInt.h -> right click and select EDIT -> find WProgram.h and change it to Arduino.h -> Save file -> restart the arduino software.

Question: I'm trying to continue my small project, which is control 3 servos with IR remote (directly to arduino), each button (1,2,3) makes different types of movement. can anybody help with my program? when I verify this i get
a lot of compiling error. Please help me fix it.
Code:
#include <IRremote.h>
#include <IRremoteInt.h>
#include <Servo.h>

int IR_PIN = 2;            // IR Sensor pin
IRrecv irrecv(IR_PIN);
decode_results IRResult;
int pos = 0;
unsigned long IRValue;

Servo myservo1;
Servo myservo2;
Servo myservo3;


void setup()
{
  myservo1.attach(9);
  myservo2.attach(10);
  myservo3.attach(11);
  pinMode(IR_PIN, INPUT);
  irrecv.enableIRIn();
}

void loop()
{
  if (irrecv.decode(&IRResult))                             
    {
      IRValue = IRResult.value;                             
      if ((IRValue == 1) || (IRValue == 2049))     
      {
        //If 1 is pressed
        }
      if ((IRValue == 2) || (IRValue == 2050))                                   
      {
        //If 2 is pressed
        }
       if((IRValue == 3) || (IRValue == 2051))                             
         {
          //If 3 is pressed
         }
       delay(1000);
       irrecv.resume();
    }
}
  
« Last Edit: March 14, 2013, 10:23:02 am by warboyzzzz » Logged

Queens, New York
Offline Offline
Edison Member
*
Karma: 27
Posts: 1537
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
when I verify this i get
a lot of compiling error.
Ok, what errors?
Logged

UNO, MEGA, NANO, 4x4 keypad, micro servos, RF transceivers, bluetooth, ultrasonic sensor, 20x4 I2C LCD, 3.2 TFT touch screen, L298N Dual motor driver, Voice Recognition 15W, Gameduino

Arduino Tutorials, coming soon.

"If your doing nothing, it does not mean your lazy, it just means your open for anything that suits you" - Unknown

Offline Offline
Full Member
***
Karma: 4
Posts: 187
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How to use this forum - please read.

Yes, Please read.

it will tell you if there is any error in your code always post it with your code. smiley-cool
Logged

From Idea To Invention

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 311
Posts: 35470
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have the IRremote library installed in the right place, although it is an older version that was not compatible with 1.0+.

I pasted your code, and got a number of errors. I edited IRremoteInt.h, changed WProgramh to Arduino.h, and all the errors went away.

Perhaps you need to do that, too.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have the IRremote library installed in the right place, although it is an older version that was not compatible with 1.0+.

I pasted your code, and got a number of errors. I edited IRremoteInt.h, changed WProgramh to Arduino.h, and all the errors went away.

Perhaps you need to do that, too.

i'm sorry, what do you mean by 'changed WProgramh to Arduino.h' ? i have changed the code and the number of errors is smaller.
Logged

Queens, New York
Offline Offline
Edison Member
*
Karma: 27
Posts: 1537
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Did you go into the .h file and actually change WProgram.h to Arduino.h?
Logged

UNO, MEGA, NANO, 4x4 keypad, micro servos, RF transceivers, bluetooth, ultrasonic sensor, 20x4 I2C LCD, 3.2 TFT touch screen, L298N Dual motor driver, Voice Recognition 15W, Gameduino

Arduino Tutorials, coming soon.

"If your doing nothing, it does not mean your lazy, it just means your open for anything that suits you" - Unknown

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 311
Posts: 35470
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Somewhere or other, a dot got lost.

I change WProgram.h to Arduino.h, in an include statement.

If you still have errors, you need to post them.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Did you go into the .h file and actually change WProgram.h to Arduino.h?

i dont get it, how to do that?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Somewhere or other, a dot got lost.

I change WProgram.h to Arduino.h, in an include statement.

If you still have errors, you need to post them.
Code:
In file included from KI_Alat_Lipat_Baju.ino:2:
D:\Arduino Libraries\libraries\IRremote/IRremoteInt.h:87: error: 'uint8_t' does not name a type
D:\Arduino Libraries\libraries\IRremote/IRremoteInt.h:88: error: 'uint8_t' does not name a type
D:\Arduino Libraries\libraries\IRremote/IRremoteInt.h:89: error: 'uint8_t' does not name a type
D:\Arduino Libraries\libraries\IRremote/IRremoteInt.h:92: error: 'uint8_t' does not name a type
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 311
Posts: 35470
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
i dont get it, how to do that?
Perhaps, if you used capital letters, like a big boy...

Use any text editor.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
i dont get it, how to do that?
Perhaps, if you used capital letters, like a big boy...

Use any text editor.
Code:
#include <IRremote.h>
#include <IRremoteInt.h>
#include <Servo.h>
#include "Arduino.h"

I have put these, but the error still came. why?
Logged

Queens, New York
Offline Offline
Edison Member
*
Karma: 27
Posts: 1537
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Go to the IRremote library folder -> look for IRremoteInt.h -> right click and select EDIT -> find WProgram.h and change it to Arduino.h -> Save file -> restart the arduino software.
Logged

UNO, MEGA, NANO, 4x4 keypad, micro servos, RF transceivers, bluetooth, ultrasonic sensor, 20x4 I2C LCD, 3.2 TFT touch screen, L298N Dual motor driver, Voice Recognition 15W, Gameduino

Arduino Tutorials, coming soon.

"If your doing nothing, it does not mean your lazy, it just means your open for anything that suits you" - Unknown

Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Go to the IRremote library folder -> look for IRremoteInt.h -> right click and select EDIT -> find WProgram.h and change it to Arduino.h -> Save file -> restart the arduino software.

Thank you so much for the info, now my code is working.  smiley-sweat
Logged

Pages: [1]   Go Up
Print
 
Jump to: