Author Topic: Ir sensor from asus eeepc remote - inconsistent ir signal using arduino  (Read 2360 times)

0 Members and 1 Guest are viewing this topic.

Offline amateur_25

  • Regular Contributor
  • *
  • Posts: 96

I took apart a asus eee pc remote control and borrowed it's ir sensor to implement the remote using my arduino. I have a sketch I borrowed from ladyada so I can look at the raw ir signal. Since she has a professional scope and I have a cheapo one who doesn't trigger properly. But I don't get the same results each time. I tested the sensor using the asus board without it's case and it works fine.

I noticed on the asus board it has some fitlering caps,100 ohm resistor and what looks like an inductor/fuse. Am assuming I shouldn't just wire the vcc = 5v gnd=gnd ouput = digital 2? How should I be wiring this up

Offline ttp

  • Regular Contributor
  • *
  • Posts: 155
  • Country: au
There is nothing wrong with wiring like you have described - vcc = 5v gnd=gnd ouput = digital 2. What are the inconsistencies/differences you are not happy about?

Offline amateur_25

  • Regular Contributor
  • *
  • Posts: 96
Code: [Select]
    /* Raw IR decoder sketch!
    This sketch/program uses the Arduno and a PNA4602 to
    decode IR received. This can be used to make a IR receiver
    (by looking for a particular code)
    or transmitter (by pulsing an IR LED at ~38KHz for the
    durations detected
    Code is public domain, check out [url=][/url] and
    for more tutorials!
    // We need to use the 'raw' pin reading methods
    // because timing is very important here and the digitalRead()
    // procedure is slower!
    //uint8_t IRpin = 2;
    // Digital pin #2 is the same as Pin D2 see
    // for the 'raw' pin mapping
    #define IRpin_PIN PIND
    #define IRpin 2
    // for MEGA use these!
    //#define IRpin_PIN PINE
    //#define IRpin 4
    // the maximum pulse we'll listen for - 65 milliseconds is a long time
    #define MAXPULSE 65000
    // what our timing resolution should be, larger is better
    // as its more 'precise' - but too large and you wont get
    // accurate timing
    #define RESOLUTION 20
    // we will store up to 100 pulse pairs (this is -a lot-)
    uint16_t pulses[100][2]; // pair is high and low pulse
    uint8_t currentpulse = 0; // index for pulses we're storing
    void setup(void) {
    Serial.println("Ready to decode IR!");
    void loop(void) {
    uint16_t highpulse, lowpulse; // temporary storage timing
    highpulse = lowpulse = 0; // start out with no pulse length
    // while (digitalRead(IRpin)) { // this is too slow!
    while (IRpin_PIN & (1 << IRpin)) {
    // pin is still HIGH
    // count off another few microseconds
    // If the pulse is too long, we 'timed out' - either nothing
    // was received or the code is finished, so print what
    // we've grabbed so far, and then reset
    if ((highpulse >= MAXPULSE) && (currentpulse != 0)) {
    // we didn't time out so lets stash the reading
    pulses[currentpulse][0] = highpulse;
    // same as above
    while (! (IRpin_PIN & _BV(IRpin))) {
    // pin is still LOW
    if ((lowpulse >= MAXPULSE) && (currentpulse != 0)) {
    pulses[currentpulse][1] = lowpulse;
    // we read one high-low pulse successfully, continue!
    void printpulses(void) {
    Serial.println("\n\r\n\rReceived: \n\rOFF \tON");
    for (uint8_t i = 0; i < currentpulse; i++) {
    Serial.print(pulses[i][0] * RESOLUTION, DEC);
    Serial.print(" usec, ");
    Serial.print(pulses[i][1] * RESOLUTION, DEC);
    Serial.println(" usec");
    // print it in a 'array' format
    Serial.println("int IRsignal[] = {");
    Serial.println("// ON, OFF (in 10's of microseconds)");
    for (uint8_t i = 0; i < currentpulse-1; i++) {
    Serial.print("\t"); // tab
    Serial.print(pulses[i][1] * RESOLUTION / 10, DEC);
    Serial.print(", ");
    Serial.print(pulses[i+1][0] * RESOLUTION / 10, DEC);
    Serial.print("\t"); // tab
    Serial.print(pulses[currentpulse-1][1] * RESOLUTION / 10, DEC);
    Serial.print(", 0};");

This is supposed to output the raw data out of a PNA4602. I borrowed it from ladyada I can only assume if I press the same button each time, the output on the terminal should be the same right? Otherwise how does the arduino know I've actually pressed the same button? Am I correct in this I think reasonable assumption for an amateur

Offline electr_peter

  • Supporter
  • ****
  • Posts: 930
  • Country: lt
IR remotes use many different transmission protocols and IR frequencies, so I cannot say anything specific about your remote.

Repeated button presses can be implemented in multiple ways (depending on IR protocol):
1) send the same button press (repeat same codes)
2) send short command signaling repetition (receiver should remember last valid signal)
3) send alternating codefor multiple presses (for simple example, ENTER button code could be 00010, then 00011, then 00010, 00011, etc. I had LG tv which similar type remote)
4) any other way

I have tested multiple remotes - each may be different in radical ways, but most follow NEC IR pattern.
Code you posted may not take into account this behaviour. I would suggest for you too look at the code, modify it so it print IR pulse ON-OFF times. Then try pressing the button multiple times and see on-off time pattern - use this to adapt code to your remote.

Scope is not necessary, Arduino is well suited to decode IR frequencies.
« Last Edit: April 18, 2014, 10:35:15 am by electr_peter »

Offline JoeO

  • Frequent Contributor
  • **
  • Posts: 504
  • Country: us
  • I admit to being deplorable
This website is an excellent site to learn about IR.
The day Al Gore was born there were 7,000 polar bears on Earth.
Today, only 26,000 remain.

Offline AnalysIR

  • Contributor
  • Posts: 10
  • Country: ie
    • AnalysIR Blog
You may be best served using the IRremote or newer IRLib libraries for Arduino.

You will always get different timings for the same signal via typical IR receivers, so the behaviour you described seems normal.

Once you pass the raw timings into a decoder like the libraries above, you should start to see consistent 'decoded' results.
(Decoders can allow +/- 100USecs or more variance on mark space timings when analysing a signal)

You might be interested in some of our recent blog posts:

Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo