IR- Receiver


#1

I connected the Infrared receiver to port 3 and both M1 and M2 on the base shield, which is stacked onto a mega 2560.
The code is modified so that after pushing the menu button on the IR, the motors will move in a certain pattern.

My problem is:
If I press the button twice the code for the motors will be executed twice in a row.

Is there anyway I can get the base shield to read the IR, execute the code pattern and during that time ignore all sort of other IR input until the pattern is done, THEN listen again for further IR input?

Thanks!


#2

Hi @hauschka1,

It seems that we can figure out the problem by modify the program. Could you copy your code here?


#3

hi,@hauschka1,there is the ir control example for starter-kit,
https://github.com/Makeblock-official/Makeblock-Library/blob/master/makeblock/examples/Makeblock_Robot_Starter_Kit/DualMode_Starter/DualMode_Starter.ino


#4

Hi Hauschka1,

just a simple suggestion … how about simply reading IR keypresses and dropping them when the motor code finished?

Something like:

// ... some motor code
// ... in case someone pressed keys on the IR remote control - accept and drop them:
while (infraredReceiverDecode.available()) {
   infraredReceiverDecode.read();  // just read the value and forget it
}

Kind regards,
Thorsten


#5

Thank you for your replies.

Thorsten, I tried your code and it worked!! Thanks a lot! :slight_smile:


#6