You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Me and my friend are working on an IR project with an arduino. Our goal is to be able to use it as a remote, with rebindable buttons. So far, we are using an lcd and Serial Monitor to track stuff, but we are facing an issue when it comes to the waitForIRSignal command. We want the lcd to display the new hex code when it is recieved, and then to store that hex code to apply later in the loop (we haven't gotten here yet we are still debugging). Instead of this, the LCD either skips printing the code recieved message or clears everything and the Serial Monitor starts freaking out, and both stop working when I try to bind a new hex code by using our remote. Can somebody help me troubleshoot? Here is our code:
#include<IRremote.h>
#include<LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 4, 5, 6, 7);
// Create IR transmitter objectunsignedlong hexCode1;
int buttonPin1 = A0;
int buttonValue1 = 0;
int buttonPin2 = A1;
int buttonValue2 = 0;
constint IR_LED_PIN = 3;
IRsend irSender;
IRsend irsend(IR_LED_PIN);
int IR_RECV_PIN = 2;
IRrecv irrecv(IR_RECV_PIN);
decode_results results;
voidsetup()
{
pinMode(3, OUTPUT);
lcd.clear();
Serial.begin(9600);
lcd.begin(16, 2);
digitalWrite(3, LOW);
irSender.begin(3);
irrecv.enableIRIn();
}
voidwaitForIRSignal() {
unsignedlong startMillis = millis(); // Start a timer to track timebool receivedSignal = false; // To track if the signal is receivedwhile (!irrecv.decode(&results)) {
if (millis() - startMillis > 5000) { // Timeout after 5 seconds
Serial.println("Timeout: No IR signal received.");
lcd.clear();
lcd.print("Timeout");
delay(1000); // Display timeout message for a moment
lcd.clear(); // Clear the screen after timeout messagereturn; // Exit the function if no signal is received within timeout
}
delay(10); // Short delay to avoid overwhelming the processor
}
// Once a valid signal is received
Serial.print("IR code received: ");
Serial.println(results.value, HEX); // Print the decoded IR code in HEX format
hexCode1 = results.value; // Store the received IR code
lcd.clear();
lcd.print("Code Bound");
delay(1000); // Display the "Code Bound" message for 1 second
lcd.clear(); // Clear the screen after the message
irrecv.resume(); // Prepare for the next signal
}
voidloop()
{
buttonValue2 = analogRead(buttonPin2);
if(buttonValue2 > 1000){
lcd.clear();
lcd.print("Bind New Code: 1");
waitForIRSignal();
}
buttonValue1 = analogRead(buttonPin1);
if(buttonValue1 > 1000){
Serial.println("Sending Code");
lcd.clear();
lcd.print("Sending...");
irsend.sendNECRaw(0xED12BF40);
delay(1000); // Wait 1 seconds before sending again
}else{
lcd.clear();
lcd.print("Not Pressed");
delay(100);
}
}
The text was updated successfully, but these errors were encountered:
Hi @Deadmeme112. Thanks for your interest in this open source project. This issue tracker is only to be used to report bugs or feature requests specific to the project. This is not an appropriate place to request assistance with your Arduino projects. The appropriate place to request assistance is on the Arduino Forum. I'm sure we will be able to help you out over there:
Me and my friend are working on an IR project with an arduino. Our goal is to be able to use it as a remote, with rebindable buttons. So far, we are using an lcd and Serial Monitor to track stuff, but we are facing an issue when it comes to the waitForIRSignal command. We want the lcd to display the new hex code when it is recieved, and then to store that hex code to apply later in the loop (we haven't gotten here yet we are still debugging). Instead of this, the LCD either skips printing the code recieved message or clears everything and the Serial Monitor starts freaking out, and both stop working when I try to bind a new hex code by using our remote. Can somebody help me troubleshoot? Here is our code:
The text was updated successfully, but these errors were encountered: