Infrared receiver generated C code doesn't work?


#1

Hello,

When using the mBlock firmware, I’m able to get IR codes from the IR Receiver, but when I try to upload my program to the board, it seems that the generated C code does not work. I’m always getting 0.

Here is the generated code :

#include <Arduino.h>
#include <Wire.h>
#include <Servo.h>

#include "MeDCMotor.h"
#include "MeInfraredReceiver.h"
#include "MeSerial.h"

double angle_rad = PI/180.0;
double angle_deg = 180.0/PI;
MeDCMotor motor_9(9);
MeDCMotor motor_10(10);
MeInfraredReceiver ir_6(6);
MeSerial se;



void setup(){
    Serial.begin(115200);
    delay(1000*0.2);  
}

void loop(){
    
    if(((0)==(ir_6.getCode()))){
        motor_9.run(0);
        motor_10.run(0);
    }
    if(((64)==(ir_6.getCode()))){
        motor_9.run(100);
        motor_10.run(100);
    }
    Serial.println(String("IR : ")+ir_6.getCode());
    delay(1000*0.2);
    ir_6.loop();
    
    
}

How can I solve this issue ?

Thx.


#2

The lastest release of mBlock now generates C code that works :smile: