Trouble programming IR buttons in 3.2


#1

I’m probably overlooking something obvious, but I thought I’d ask rather than spending the next day or two trying to sort this out on my own. I downloaded 3.2 (after not being able to get a program to work in the previous version. I wrote a basic “move forward, stop, move backward” program in mBlock, and I have that working. My problem is that I can’t figure out how to program the IR remote.

In the past version, I could use the tags for "if key (up arrow) pressed, then (move both motors forward). Currently, I can only find a way to program for keys 1-4 (if port 6 key 1 pressed, then…), and none of them work. Am I missing something?

I’m working with the IR Starter robot (Me Orion). Current extensions are Arduino, Makeblock, and Communication. Firmware is up-to-date.


Help with orion
Makeblock You are about to lose a customer
Makeblock You are about to lose a customer
#2

In mBlock 3.2, there is a block that says ir remote [Av] pressed that has all of the arrow keys, letter keys, etc.


#3

@amethyst,

Make user that the Me Orion is selected under the Boards menu. Look for the “infrared receiver (Port6)” under the Script tab, Makeblock section. Here is a some code (untested) that might help point you in the right direction.

I have to go to work, but I will be back this evening to work on this some more.

Note: I am using the 7-segment display to show what is returned from the IR Sensor, I suspect it may be ACSII, but I’m not sure.

Mike


#4

@chuckmcknight Thanks for taking the time to help. I’m not seeing that block. The closest I can find is the one I showed in my screenshot that has key1-key4. Am I missing it somewhere? Is it in with the robot category or somewhere else?


#5

@chuckmcknight
The <ir remote [A v] pressed> block only seems to appear in the Robots blocks when “Boards” is set to “mBot”.
I would guess that the IR sensor on the Me Orion would be able to decode the IR codes also, but it doesn’t look like the block to do this is built in.

@amethyst
I don’t have an Me Orion so I don’t know if this code will work, but this is the underlying Arduino code that is created by mBlock for the mBot using the ir sensor blocks. You could change the “MeMCore.h” to “MeOrion.h” (or some such) and try it? I’m sure the ports for the LEDs are wrong too. This code is looking for the “A” button to be pressed.

#include 
#include 
#include 
#include 

#include 

double angle_rad = PI/180.0;
double angle_deg = 180.0/PI;
MeIR ir;
MeRGBLed rgbled_7(7, 7==7?2:4);



void setup(){
    ir.begin();
    
}

void loop(){
    
    if(ir.keyPressed(69)){
        rgbled_7.setColor(0,150,0,0);
        rgbled_7.show();
    }
    ir.loop();
    
    
}

Programming Starter Robot Kit with Robotic Arm
#6

Thanks, @mddickey. I appreciate you taking the time. I have that part changed. I’ll keep working on it, and browse through the forum a bit more to see if anyone else has figured it out in the mean time, too.


#7

Awesome! Thanks, @Lentil. I’ll give that a try and report back.


#8

@amethyst: I took a quick look at the Orion default firmware and it looks like @mddickey is on the right track. Perhaps the standalone IR receiver boards have the IR decoder built in and return a code as mddickey suggested.

The mBot has the IR receiver built into the mainboard so it may behave differently.


Restored Starter tank (mblock 3.4.1.1) to factory and now it drives automatically
#9

I figured it out!!

There’s a thread in the Starter Kit forum that pointed to this. I had to read it a few times before I put it all together. So, just in case anyone else needs it…

For the 3.2 version, you need to use hex code decimals to program the buttons. Everything is listed under NEC Code Table here: https://github.com/Makeblock-official/Makeblock-Libraries/blob/master/makeblock/src/MeInfraredReceiver.h

Once you have the code for the key you want (up = 0x40, for example), swing over to Google and type in the equation followed by “in decimal”, so in this case, "0x40 in decimal). Google pulls up a calculator and gives you 64. That’s the number you’re going to use to ‘say’ up in mBlock.

I ended up with something like this. Right now, I’m using the A button (60) to stop both motors.

I’ll add in the ultrasonic sensor in the next few days, and maybe a couple other small changes, and post back if anyone is interested. I’m sure there are other beginners out there who are just as confused as me. :grin:

Thank you again for all of your help!


IR-Control for mbot ranger (Auriga Board)
Can't reprogram remote control
FAQ for Starter: How to program the IR remote in order to control the add-on Robotic Arm for starter
Having multiple programs
#10

@amethyst,

Excellent work, here are the other codes that I found that are returned when the different buttons are pressed on the remote control.

Mike


Motors stopping when turining
#11

Super Job! I was infuriated with this device until I realized that this device was based on an Orion.
Out of the box every indication was that it would work with Mbot specs. This company needs
some English speaking help in the worst way.


#12

I’m a complete beginner at this, I had a problem with the IR remote (now resolved) but have been following your progress.
I’m now trying to programme the Ultrasonic sensor and have spent ages been trying to find examples to give me an idea, so will be interested to see how you progress.
Good luck :slightly_smiling:


#13

I have exactly the same issue. I want to copy the code you posted but I can’t find the SET command. Any chance you could send me a screenshot of it?
Thanks


#14

The set command is found in the Data&Blocks area. Select “Make a Variable” and enter a variable name ‘KeyPressed’ and click OK. Some blocks will appear that are related to the variable.


#15

Worked absolutely brilliantly!
Thanks very much for your help, I cannot tell you how relieved I am that I haven’t permanently bricked my sons new favorite toy!


#16

I have the same thing copied down on my mblock, and it works, but only when it is connected the computer. Any Ideas?


#17

Thank you Amethyst, and all who replied. I’m gonna piggy back:

The wait time is 1/10 of a second. That way it will stop when you lift your finger off the button. =)


#18

I have been trying to write a code to use the ir controller to control the starter kit robotic arm. This is what I have started with based on what everyone has said above.

When I click on “Edit with Arduino” and then “Open, Libraries, Makeblock, Firmware for Starter, IR_Ultrasonic”, I am able to compile a sketch and complete the upload, but it doesn’t work.

I have also read that I should be choosing “Firmware_for_mBlock, orion_firmware”, but that tells me that my sketch is too big when I verify it. Does anyone have any advice?


#19

Hi
You may try the program below?


Programming Starter Robot Kit with Robotic Arm
#20

Yay!
Thank you @amethyst and everybody for chiming in! Very helpful.