(HELP) Trying to use an IR remote instead of a keypad

I am working on this project.

http://www.liming.org/millindex/

The issue I'm having is that I do not have a LCD shield with a button keypad for my Uno, and due to the state of things I am unable to get one soon enough. I have succesfully wired an LCD1602 module instead of the LCD shield screen but I don't have anything that uses the one A0 pin for button functionality besides an IR reciever and remote.

This is the reciever.

and the remote.

I'll attach the code, but I was wondering how difficult it will be to use the remote instead of the buttons? Can anyone help me? I am only a beginner. Thanks in advance.

StepIndex23.ino (18.9 KB)

So inserted some IR code I found into to base code I had, but now the LCD screen is blank when uploaded and it's not working. Any advice?

Updated code attached.

Anything added by me is given
//IR

This feels like it's really difficult and I'm super confused.

StepIndex23_experimental_ir_remote.ino (21.4 KB)

Test the IR code BEFORE you insert it so you know it works and how it works. Seems like you are working blind.

Paul

Paul_KD7HB:
Test the IR code BEFORE you insert it so you know it works and how it works. Seems like you are working blind.

Paul

I will not argue with you there, that is good advice and I will try that. I am kind of stabbing in the dark.

So, after stumbling around I have found this at the end of the loop.

int read_LCD_button() // routine to read the LCD's buttons
{
int key_in;
delay(ADSettleTime); // wait to settle
key_in = analogRead(0); // read ADC once
delay(ADSettleTime); // wait to settle
// average values for my board were: 0, 144, 324, 505, 742
// add approx 100 to those values to set range
if (key_in > 850) return NO_KEY;
if (key_in < 70) return RIGHT_KEY;
if (key_in < 250) return UP_KEY;
if (key_in < 450) return DOWN_KEY;
if (key_in < 650) return LEFT_KEY;
if (key_in < 850) return SELECT_KEY;
}

I'm going to try:

#include <IRremote.h>

int RECV_PIN = A0;

IRrecv irrecv(RECV_PIN);

decode_results results;

at the beginning then try to get key_in to return the HEX decoded from a table or something along those lines.

Wish me luck.

Flame_half:
So, after stumbling around I have found this at the end of the loop.

int read_LCD_button() // routine to read the LCD's buttons
{
int key_in;
delay(ADSettleTime); // wait to settle
key_in = analogRead(0); // read ADC once
delay(ADSettleTime); // wait to settle
// average values for my board were: 0, 144, 324, 505, 742
// add approx 100 to those values to set range
if (key_in > 850) return NO_KEY;
if (key_in < 70) return RIGHT_KEY;
if (key_in < 250) return UP_KEY;
if (key_in < 450) return DOWN_KEY;
if (key_in < 650) return LEFT_KEY;
if (key_in < 850) return SELECT_KEY;
}

I'm going to try:

#include <IRremote.h>

int RECV_PIN = A0;

IRrecv irrecv(RECV_PIN);

decode_results results;

at the beginning then try to get key_in to return the HEX decoded from a table or something along those lines.

Wish me luck.

So I changed this to

int read_LCD_button() // routine to read the LCD's buttons
{
int key_in;
delay(ADSettleTime); // wait to settle
key_in = (results.value, HEX); // read ADC once
delay(ADSettleTime); // wait to settle
// average values for my board were: 0, 144, 324, 505, 742
// add approx 100 to those values to set range
if (key_in > 850) return NO_KEY;
if (key_in = 0xFFC23D) return RIGHT_KEY;
if (key_in = 0xFF629D) return UP_KEY;
if (key_in = 0xFFA857) return DOWN_KEY;
if (key_in = 0xFF22DD) return LEFT_KEY;
if (key_in = 0xFF02FD) return SELECT_KEY;
}

But I am still not getting a read on the buttons.

StepIndex23irremotetest2.ino (19.7 KB)

I don't see anything relating to your IR code in the snippet you posted.

Paul

Currently reading the button pushes now with this code.

int read_LCD_button() // routine to read the LCD's buttons
{
int key_in;
delay(ADSettleTime); // wait to settle
key_in = (results.value, HEX); // read ADC once
delay(ADSettleTime); // wait to settle

if (irrecv.decode(&results))
switch (results.value)
{
case 0xFF629D: return RIGHT_KEY; break;
case 0xFF22DD: return LEFT_KEY; break;
case 0xFF02FD: return SELECT_KEY; break;
case 0xFFC23D: return RIGHT_KEY; break;
case 0xFFA857: return DOWN_KEY; break;
irrecv.resume();
}
delay(100);
}

But now it only reads the first button pushed and reads it over and over. Any way to make it not to that?

I think it needs to be debounced. I'll try and figure that out.

You are telling the compiler that this function returns an int, but your code NEVER returns anything.

int read_LCD_button() // routine to read the LCD's buttons

Paul

Paul_KD7HB:
You are telling the compiler that this function returns an int, but your code NEVER returns anything.

int read_LCD_button() // routine to read the LCD's buttons

Paul

This isn't the full code, just a subroutine for the buttons. Or the remote in this case.

StepIndex23irremotetest2.ino (20.4 KB)