Me-infrared test sketch not working with Arduino UNO


#1

Hello,

I’m trying to make work the Me-infrared test sketch with Dupont wire and Arduino UNO.

I make the connection as show in this page

http://learn.makeblock.com/en/me-infrared-reciver-decode/

GND to GND Arduino
VCC to 5V Arduino
S1 to pin 6 Arduino
DAT to pin 0->RX Arduino

/**
 * \par Copyright (C), 2012-2016, MakeBlock
 * @file    InfraredReceiverTest.ino
 * @author  MakeBlock
 * @version V1.0.0
 * @date    2015/09/01
 * @brief   Description: this file is sample code for Me Infrared Receiver device.
 *
 * Function List:
 * 1. void MeInfraredReceiver::begin(void)
 * 2. int16_t MeInfraredReceiver::read(void)
 * 3. int16_t MeInfraredReceiver::available(void)
 * 4. bool MeInfraredReceiver::buttonState(void)
 *
 * \par History:
 * <pre>
 * <Author>     <Time>        <Version>      <Descr>
 * Mark Yan     2015/09/01    1.0.0          rebuild the old lib
 * </pre>
 */
#include "MeOrion.h"
#include <SoftwareSerial.h>

MeInfraredReceiver infraredReceiverDecode(PORT_6);

void setup()
{
  infraredReceiverDecode.begin();
  Serial.begin(9600);
  Serial.println("InfraredReceiverDecode Start!");
}

void loop()
{
  uint8_t ReceiverCode;
  uint8_t buttonState;
  static uint8_t PrebuttonState = 0;

  buttonState = infraredReceiverDecode.buttonState();
  if(PrebuttonState != buttonState)
  {
    PrebuttonState = buttonState;
    Serial.print("buttonState 0x");
    Serial.println(buttonState);
  }
  if(infraredReceiverDecode.available())
  {
    ReceiverCode = infraredReceiverDecode.read();
    switch(ReceiverCode)
    {
       case IR_BUTTON_A: Serial.println("Press A."); break;
       case IR_BUTTON_B: Serial.println("Press B."); break;
       case IR_BUTTON_C: Serial.println("Press C."); break;
       case IR_BUTTON_D: Serial.println("Press D."); break;
       case IR_BUTTON_E: Serial.println("Press E."); break;
       case IR_BUTTON_F: Serial.println("Press F."); break;
       case IR_BUTTON_SETTING: Serial.println("Press Setting."); break;
       case IR_BUTTON_UP: Serial.println("Press Up."); break;
       case IR_BUTTON_DOWN: Serial.println("Press Down."); break;
       case IR_BUTTON_LEFT: Serial.println("Press Left."); break;
       case IR_BUTTON_RIGHT: Serial.println("Press Right."); break;
       case IR_BUTTON_0: Serial.println("Press 0."); break;
       case IR_BUTTON_1: Serial.println("Press 1."); break;
       case IR_BUTTON_2: Serial.println("Press 2."); break;
       case IR_BUTTON_3: Serial.println("Press 3."); break;
       case IR_BUTTON_4: Serial.println("Press 4."); break;
       case IR_BUTTON_5: Serial.println("Press 5."); break;
       case IR_BUTTON_6: Serial.println("Press 6."); break;
       case IR_BUTTON_7: Serial.println("Press 7."); break;
       case IR_BUTTON_8: Serial.println("Press 8."); break;
       case IR_BUTTON_9: Serial.println("Press 9."); break;
       default: break;
    }
  }
}

And when I ran the sketch… sometimes the arduino IDE tell me that the port is busy and sometimes the upload work and on the monitor I can read

"InfraredReceiverDecode Start!“
then after
"buttonState 0x1
buttonState 0x2”

And nothing else…

Can you give me some help ? I don’t understand what’s wrong.

Thank you

PS : I try it with my MeBaseboard connecting Me_infrared Receiver decode to port 6 and the same thing happen… it won’t work…


#2

Hi Xawaks,

Do you use the Me Infrared Receiver Decode V2.1?
Please take a picture for your Me-infrared module to show me the Pin silk screen on the module?
If it has DAT, STA, VCC, GND, you need connect the DAT to A3 on Arduino uno and STA to A2 on Arduino uno board.


#3

Hi, tank you for your help.

I’m using the Me-infrared V2.0

Here the picture.

If I connect DAT to A3 on arduino and S1 to A2, I have to modify the sketch no ?

Thanks :wink:


#4

Hi Xawaks,

Yes, the S1 is same with the STA, you can connect S1 to A2 have a check.


#5

Ok and I modify the sketch like this ? But where did I put the A2 port ? I miss something I think :wink:

MeInfraredReceiver infraredReceiverDecode(A3);


#6

Hi Xawaks,

There is no need to change the sketch your pasted before.
Leave it as the MeInfraredReceiver infraredReceiverDecode(PORT_6); Since the A2, A3 corresponding to the Port 6 on our Orion board.


#7

Cool ! Thanks a lot ! It’s work fine like this.

I’m really appreciate your help :wink:

There is this thing on the monitor, but I think it is normal. The buttonState information…

InfraredReceiverDecode Start!
buttonState 0x1
Press 5.
buttonState 0x0
buttonState 0x1
Press 5.
buttonState 0x0
buttonState 0x1
Press 6.
buttonState 0x0
buttonState 0x1
Press 9.
buttonState 0x0
buttonState 0x1
Press 8.

Thank you so much


#8