0

I have the following script which checks if the user has pressed the numbers "770" or "769" continuously in the remote. The script works fine and displays all numbers. When I press the buttons "770" or "769" continuously the function powerOff() is called and I get no serial input.

/*
 * IRremote: IRrecvDemo - demonstrates receiving IR codes with IRrecv
 * An IR detector/demodulator must be connected to the input RECV_PIN.
 * Version 0.1 July, 2009
 * Copyright 2009 Ken Shirriff
 * http://arcfn.com
 */
#include <IRremote.h>
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
IRsend irsend;
decode_results results;
int intValue;
String strValue;
String str3;
void setup()
{
 Serial.begin(9600);
 irrecv.enableIRIn(); // Start the receiver
}
void loop() {
 if (irrecv.decode(&results)) {
 intValue = results.value;
 Serial.print("Integer value : ");
 Serial.println(intValue);
 strValue = String(intValue);
 Serial.print("String str : ");
 Serial.println(strValue);
 Serial.print("Length : ");
 Serial.print(strValue.length());
 Serial.println();
 if(strValue.length() <= 1){
 str3 += strValue;
 Serial.println(str3);
 // Receive the next value
 }
 delay(200);
 irrecv.resume();
 }
 //Serial.println(str3);
 if(str3.endsWith("770")){
 powerOff();
 str3 = "";
 }
 else if(str3.endsWith("769")){
 powerOff();
 str3 = "";
 }
 else{}
 //powerOff();
}
void powerOff(){
 irsend.sendRC6( 0xC0000C, 24);
 irrecv.resume(); // Receive the next value
}
asked Dec 7, 2015 at 14:49

1 Answer 1

3

Apparently you should be calling irrecv.enableIRIn() after sending, not irrecv.resume(). Sorry for suggesting the wrong thing on IRC before :-)

answered Dec 7, 2015 at 14:57

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.