Simple latch for Infrared Remote

Can someone point me at a simple bit of code that will read the HEX code from an IR remote; recognize when this is a valid code; and set a latch for a set number of seconds even though the HEX code from the remote is no longer available?

What do you mean, "even though the HEX code from the remote is no longer available"? Why would than be necessary?

Hi aarg
The problem I am having is that the remote control sends a HEX code stops sending it for a fraction of a second and then sends the same code again assuming you still have your finger on the same button. In this off state when it stops sending the HEX code this is seen as a "false" condition and the program stops doing what is require of it. What I need is a form of latch to match the frequency of the repeating HEX code so it maintains a "true" state while the same HEX code is being transmitted.

Hope this explains what I am trying to do.

Code requirments.pdf (90.8 KB)

Are you saying you want to hold in a state of "button press" or "transmission in progress" until a timeout occurs (i.e. no subsequent transmission of the same signal was sent)?

Hi Bulldoglowell
I want to constantly read the state of the HEX input and for each iteration of the loop between the first identification of a valid state and the next the the output is held in a "true" condition once the button is released the HEX code will no longer be present the latch will time out and the output will become "false". Each IR remote has probably got a small time difference between when it sends one output and the next so some adjustment to the code will be required if a different remote is used.

Code requirments.pdf (90.8 KB)

BulldogLowell:
Are you saying you want to hold in a state of "button press" or "transmission in progress" until a timeout occurs (i.e. no subsequent transmission of the same signal was sent)?

Thanks BulldogLower
In answer to you question now I have had time think about it. Yes. The PDF I have attached in the 3rd post should clarify the requirement.

So, you want to:

Timeout on no next char
Change state if next char != last char
maintain state if char = lastChar

Do you need help working out a basic program, or can you go with that?

Hi Bulldog
Your succinct description is exactly what I need.

I have only been learning coding for a few weeks so understand the basics but tend to get lost on more complicated code.

So any help would be appreciated.

Thanks

Do you have an example of what the arduino receives from the remote?

BulldogLowell:
Do you have an example of what the arduino receives from the remote?

Hi BulldogLowell

Yes the HEX codes from Lenovo remote are shown below.

The remote first sends one code on the first press of a button then if you press the same button again it sends a second different code and on the third press it sends the first code again.

Fast Clockwise (this is what I hope to make the stepper motor do)
431E009D
7A33ACF3

Fast Counter Clockwise
421DFF0A
7933AB60

Slow Clockwise
1C1B84A3
EB3B1A99

Slow Counter Clockwise
6EBDA732
B81F4EBC

Sleep Mode
6B2D5A2E
9E571580

Thanks Ken

You may be missing something in your timing diagram.
Your output starts on any edge not a valid receive code and ends after a retriggerable timeout period.

The second code is probably a verification code like a CRC to prove the first code was received correctly or came from a particular remote, do you have a part # or link to the remote?
Do you get the same set of numbers if you press the same button? If so you could code something like:

if(firstcode == 431E009D && secondcode == 7A33ACF3)
do Fast Clockwise;

outsider:
The second code is probably a verification code like a CRC to prove the first code was received correctly or came from a particular remote, do you have a part # or link to the remote?
Do you get the same set of numbers if you press the same button? If so you could code something like:

if(firstcode == 431E009D && secondcode == 7A33ACF3)
do Fast Clockwise;

Hi Outsider

You only get two codes for each button. If you press and hold a button you continual get the same code. If you release and re-press the same button you get the second code. If you re-press the same button again you get the first code again.

The part number is "RC2604315" and the make is Lenovo.

THanks Ken

LarryD:
You may be missing something in your timing diagram.
Your output starts on any edge not a valid receive code and ends after a retriggerable timeout period.

Hi LarryD

The timing diagram is more an indication of the problem I was having and how to visualize it rather than an exact replica of when things were happening.

I may be able to make exact measurements if I can get an Oscilloscope.

Thanks Ken

LarryD:
You may be missing something in your timing diagram.
Your output starts on any edge not a valid receive code and ends after a retriggerable timeout period.

Hi again LarryD
I should add you are of course correct the code would not be acted on until it was complete and only then would the state change.

Thanks for the clarification.

Ken

LarryD:
You may be missing something in your timing diagram.
Your output starts on any edge not a valid receive code and ends after a retriggerable timeout period.

LarryD:
You may be missing something in your timing diagram.
Your output starts on any edge not a valid receive code and ends after a retriggerable timeout period.

outsider:
The second code is probably a verification code like a CRC to prove the first code was received correctly or came from a particular remote, do you have a part # or link to the remote?
Do you get the same set of numbers if you press the same button? If so you could code something like:

if(firstcode == 431E009D && secondcode == 7A33ACF3)
do Fast Clockwise;

Thanks for the suggestion LarryD. I did implement your code but the motor did not respond at all.
I have added part of the code I have tried, but as you can probably see the state is only true for a short time. This is just enough time to nudge the motor a bit and then it stops and waits for the next valid code.

  if (irrecv.decode(&results)) {
    if (results.value == 0x431E009D || results.value == 0x7A33ACF3) {
      digitalWrite(Enable, LOW);
      digitalWrite(Dir, LOW);
      blinking_1 = true; // start blinking_1
      Serial.write("Fast Clockwise\n");

Any more suggestion appreciated.
Thanks Ken

Solved
I used Bluetooth instead and that worked fine. Thanks for looking.
Ken