Pages: [1]   Go Down
Author Topic: INFRARED REMOTE CONTROL HELP  (Read 4639 times)
0 Members and 1 Guest are viewing this topic.
HK
Offline Offline
Jr. Member
**
Karma: 0
Posts: 69
Micro
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I need Help :- I am working on project of Infrared Remote control for controlling 2 relay Board. I am using TV Tuner Cards remote for Controlling the Relay , I have done all things like Extracting raw code for Remote Controller, coding the ARDUINO UNO , wiring the sensor on breadboard and tested project for working,   it's working but the problem is when i shutdown the arduino and restart it's power the two relays goes ON automatically when i press specific key on Remote Controller it's toggles ON / OFF as expected but when reboot or Cold start ';; the relay get ON automatic.. Please tell why this getting happened. Below is the Code i am using .

//---------------------------------------CODE FROM HERE -----------------------------------------------------------------------------------------------

#include <IRremote.h>

int RECV_PIN = 11;
int relay1 = 2;
int relay2 = 3;
int relay3 = 4;
int relay4 = 5;

int on = 1;
int on1 = 0;
int on2 = 0;
int on3 = 0;

IRrecv irrecv(RECV_PIN);
decode_results results;

void setup()
{
  pinMode(relay4, OUTPUT);
  pinMode(relay3, OUTPUT);
  pinMode(relay2, OUTPUT);
  pinMode(relay1, OUTPUT);
  pinMode(13, OUTPUT);
  irrecv.enableIRIn(); // Start the receiver
}

unsigned long last = millis();

void loop() {
  if (irrecv.decode(&results))
  {
    if (results.value == 0x61D648B7)
    { // Remote Control Power Code
      // If it's been at least 1/4 second since the last
      // IR received, toggle the relay
      if (millis() - last > 250)
      {
        on = !on;
        digitalWrite(relay1, on ? HIGH : LOW);
      }
      last = millis();
    }   

 else if (results.value == 0x61D638C7)
    {
      if (millis() - last > 250)
      {
        on1 = !on1;
        digitalWrite(relay1, on1 ? HIGH : LOW);
      }
      last = millis();
    }


    else if (results.value == 0x40BD28D7 )
    {
      if (millis() - last > 250)
      {
        on2 = !on2;
        digitalWrite(relay1, on2 ? HIGH : LOW);
      }
      last = millis();
}

 else if (results.value == 0x61D6609F)
    {
      if (millis() - last > 250)
      {
        on3 = !on3;
        digitalWrite(relay4, on3 ? HIGH : LOW);
      }
      last = millis();

    }
    irrecv.resume(); // Receive the next value
  }
}

//---------------------------------------------------CODE END ---------------------------------------------------------------------
Logged

Peter.

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 514
Posts: 31550
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Please read the how to use this forum post and add code tags to this post.

We need to know how you have wired up the relays.
Logged

HK
Offline Offline
Jr. Member
**
Karma: 0
Posts: 69
Micro
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i am using this 2 relay board with my project.


https://www.box.com/s/lp8u6f319cmlmhzr5sje
Logged

Peter.

HK
Offline Offline
Jr. Member
**
Karma: 0
Posts: 69
Micro
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

how to attach images in reply ???
Logged

Peter.

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 514
Posts: 31550
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Please read the how to use this forum post and add code tags to this post.

Oddly enough it tells you about attaching images as well.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 27
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

My guess is you are using active LOW relays. That means they are on when you output a LOW and off when you output a HIGH. Try adding
Code:
digitalWrite(relayX, HIGH);
before every
Code:
pinMode(relayX, OUTPUT);
line in setup().
Logged

HK
Offline Offline
Jr. Member
**
Karma: 0
Posts: 69
Micro
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I Need help in another project : i am using LDR and arduino uno and 2 relay module when LDR detects low light it trigger the relay my problem is when slight change in LDR value the relay gets flickering like fast on/ off how to get steady on or steady off ?? the relay module pin is connected to pin 12 on arduino uno...  i am using the code below ..

--------------------------------------------------------------------------------------------------------------------------
void setup() {
pinMode(4, OUTPUT);
pinMode(12, OUTPUT);
//Serial.begin(9600);
}

void loop(){
digitalWrite(4, HIGH);
if(analogRead(0) < 600){
digitalWrite(12, LOW);
} else{
digitalWrite(12, HIGH);
//Serial.println(analogRead(0));
}
}
-----------------------------------------------------------------------------------------------------------------------
Logged

Peter.

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 514
Posts: 31550
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I Need help in another project
So you still haven't read the sticky. Let me help here is the link
http://arduino.cc/forum/index.php/topic,149037.0.html

Anyway if you don't post the code correctly next time this is the last help you get from me because you are showing a great discurtsy to the board by ignoring our simple requests.

Quote
my problem is when slight change in LDR value the relay gets flickering like fast on/ off
You will do when the value is around the threshold mark of 600. You can get round this in code by introducing a hysteresis, that is a different threshold for the turn on to the turn off. You need a variable to see what state you are currently in and then compare it with say 600 if it is on or 620 if it is off.
Logged

HK
Offline Offline
Jr. Member
**
Karma: 0
Posts: 69
Micro
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hi i am very sorry for broking the rules but i am new to this forum and i tried to get help from forum help pages but when i first log-in to this forum from that time the help page is not showing and only says " DUDE, WE ARE POPULATING OUR HELP SERVER "  and   "come back in a minute we will be done, for sure!. "   now tell me what can i do ? if any other help page is there please tell me ..
Logged

Peter.

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 240
Posts: 24457
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well, there's this one, and the ones it links to, but you know that because you've just reported it to the moderators.

Why didn't you read it instead?
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

HK
Offline Offline
Jr. Member
**
Karma: 0
Posts: 69
Micro
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

ok i now get the access when i clicked on that image of forum ok thanks.
Logged

Peter.

HK
Offline Offline
Jr. Member
**
Karma: 0
Posts: 69
Micro
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi, gapan You given perfect answer that line of code ,
Code:
digitalWrite(relay1, HIGH);
actually worked for me thanks and my problem solved ..Bye.
Logged

Peter.

Pages: [1]   Go Up
Jump to: