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.
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.
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;
}
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?