Hello ,
i have problem with my IR receiver . I'm trying to construct project which can control motor through remote DVD control . I found this libraby for IR remote A Multi-Protocol Infrared Remote Library for the Arduino but I'm trying to "tune" with my remote DVD control. I found similar type of it ( i have Philips DVP5140 but the remote control of Philips DVP-5982 looks like equally ). But the bigest problem with library is that when I try to send signals to IR receiver (connect with arduino) I receive zero ("0") ( I receive this for all remote control which I have :
I have this IR receiver http://catalog.osram-os.com/catalogue/catalogue.do?favOid=00000002000246c8001c0023&act=showBookmark
/*
* 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);
decode_results results;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
}
void loop() {
if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);
irrecv.resume(); // Receive the next value
}
}
If the IRRemote library doesn't recognize the encoding scheme it will provide only the raw pulse times. Here is an article about using unknown remotes:
Some remotes send the same code repeatedly. Some send a "repeat" code to indicate that the same button is held down. You write your code to do what you want with the information you get.
I did it and I have some "number of button" and I also know which button was pressed .
unsigned long hash = decodeHash(&results);
Serial.print(hash); //additions for control
if(hash == 3398190446) // this is number for button 1
{
digitalWrite(3,HIGH);
}else if ( hash == 3717434288 ) // this is number for button 2
{
digitalWrite(3,HIGH);
}
else {
digitalWrite(3,LOW);
}
But I need know how I can recongnize that the button is still pressed (the problem is that then remote control send different "number" and I dont know how I "keep the light on"). Can you suggest any solution.
but I still don't know where I should place digitalWrite(3,LOW) . I tried a few possibilities but no one work as I want . Idea is simply = when the button is pushed - LED turn on and when the button is not pushed - LED off .
United121:
Idea is simply = when the button is pushed - LED turn on and when the button is not pushed - LED off .
Unfortunately the remote doesn't send a message for "The button is not pushed". Perhaps you should restart a timer each time you get the "Button is pressed" message and, if the time runs out, turn off the LED.
unsigned long LastTimeButtonWasPressed;
void loop()
{
if (received a button pressed message)
{
turn on LED;
buttonIsPressed = true;
LastTimeButtonWasPressed = millis();
}
if (buttonIsPressed && millis() - LastTimeButtonWasPressed > 100)
{
turn off LED;
buttonIsPressed = false;
}
}
WOW it works. Although when the LED should turn on then LED blinks but it doesn't matter ( it may be caused complexity of code ). For my purpose is it sufficient , at least I think.Thank you for your time and your very important advice .