Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Arduino Uno IR Project #12050

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Deadmeme112 opened this issue May 5, 2025 · 1 comment
Closed

Arduino Uno IR Project #12050

Deadmeme112 opened this issue May 5, 2025 · 1 comment
Assignees
Labels
Type: Invalid Off topic for this repository, or a bug report determined to not actually represent a bug

Comments

@Deadmeme112
Copy link

Deadmeme112 commented May 5, 2025

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 object

unsigned long hexCode1;
int buttonPin1 = A0;
int buttonValue1 = 0;
int buttonPin2 = A1;
int buttonValue2 = 0;
const int IR_LED_PIN = 3;
IRsend irSender;
IRsend irsend(IR_LED_PIN);
int IR_RECV_PIN = 2;
IRrecv irrecv(IR_RECV_PIN);
decode_results results;

void setup()
{
  pinMode(3, OUTPUT);
  lcd.clear();
  Serial.begin(9600);
  lcd.begin(16, 2);
  digitalWrite(3, LOW);
  irSender.begin(3);
  irrecv.enableIRIn();
  }
void waitForIRSignal() {
  unsigned long startMillis = millis();  // Start a timer to track time
  bool receivedSignal = false;  // To track if the signal is received
  
  while (!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 message
      return;  // 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 
}
void loop()
{
  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);
  }
}
@per1234 per1234 self-assigned this May 5, 2025
@per1234
Copy link
Collaborator

per1234 commented May 5, 2025

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:

https://forum.arduino.cc/

@per1234 per1234 closed this as not planned Won't fix, can't repro, duplicate, stale May 5, 2025
@per1234 per1234 added the Type: Invalid Off topic for this repository, or a bug report determined to not actually represent a bug label May 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Invalid Off topic for this repository, or a bug report determined to not actually represent a bug
Projects
None yet
Development

No branches or pull requests

2 participants