peter_england
Full Member level 4
- Joined
- Jul 24, 2012
- Messages
- 199
- Helped
- 11
- Reputation
- 22
- Reaction score
- 11
- Trophy points
- 1,298
- Activity points
- 2,478
#include <EEPROM.h>
#include <IRremote.h>
int RECV_PIN = 11;
int relay1 = 2;
int relay2 = 3;
int relay3 = 4;
int relay4 = 5;
int on4 = 0; // taking this variables for each relay 1,2,3 & 4
int on1 = 0;
int on2 = 0;
int on3 = 0;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
digitalWrite(relay4,LOW);
pinMode(relay4, OUTPUT);
digitalWrite(relay3, LOW);
pinMode(relay3, OUTPUT);
digitalWrite(relay2, LOW);
pinMode(relay2, OUTPUT);
digitalWrite(relay1, LOW);
pinMode(relay1, OUTPUT);
pinMode(13, HIGH);
if(EEPROM.read(1)==1)
{
on1=1;
digitalWrite(relay1,on1);
}
if(EEPROM.read(2)==1)
{
on2=1;
digitalWrite(relay2,on1);
}
if(EEPROM.read(3)==1)
{
on3=1;
digitalWrite(relay3,on1);
}
if(EEPROM.read(4)==1)
{
on4=1;
digitalWrite(relay4,on4);
}
irrecv.enableIRIn(); // Start the receiver
}
unsigned long last = millis();
void loop() {
if (irrecv.decode(&results))
{
if (results.value == 0x61D6807F)
{ // 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)
{
on1 = !on1;
digitalWrite(relay1, on1 ? HIGH : LOW);
EEPROM.write(1,on1);
}
last = millis();
}
//EXTRA CODE FROM HERE FOR TESTING WITH OTHER REMOTE CONTROLS
if (irrecv.decode(&results))
{
if (results.value == 0x61D640DF)
{ // 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)
{
on1 = !on1;
digitalWrite(relay1, on1 ? HIGH : LOW);
EEPROM.write(1,on1);
}
last = millis();
}
//EXTRA CODE UPTO HERE FOR TESTING WITH OTHER REMOTE CONTROLS
else if (results.value == 0x61D640BF)
{
if (millis() - last > 250)
{
on2 = !on2;
digitalWrite(relay2, on2 ? HIGH : LOW);
EEPROM.write(2,on2);
}
last = millis();
}
else if (results.value == 0x40BD28D7 )
{
if (millis() - last > 250)
{
on1 = !on1;
digitalWrite(relay1, on1 ? HIGH : LOW);
EEPROM.write(1,on1);
}
last = millis();
}
else if (results.value == 0x61D6609F)
{
if (millis() - last > 250)
{
on4 = !on4;
digitalWrite(relay4, on4 ? HIGH : LOW);
EEPROM.write(4,on4);
}
last = millis();
}
irrecv.resume(); // Receive the next value
}
}}
#include <EEPROM.h>
void setup()
{
// write a 0 to all 512 bytes of the EEPROM
for (int i = 0; i < 512; i++)
{
EEPROM.write(i, 1);
}
// turn the LED on when we're done
digitalWrite(13, HIGH);
}
void loop()
{
}
#include <EEPROM.h>
#include <IRremote.h>
int RECV_PIN = 11;
int relay1 = 2;
int relay2 = 3;
int relay3 = 4;
int relay4 = 5;
// taking this variables for each relay 1,2,3 & 4
int on1 = 0;
int on2 = 0;
int on3 = 0;
int on4 = 0;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
digitalWrite(relay4,HIGH);
pinMode(relay4, OUTPUT);
digitalWrite(relay3,HIGH);
pinMode(relay3, OUTPUT);
digitalWrite(relay2,HIGH);
pinMode(relay2, OUTPUT);
digitalWrite(relay1,HIGH);
pinMode(relay1, OUTPUT);
pinMode(13, HIGH);
if(EEPROM.read(1)==0)
{
on1=1;
digitalWrite(relay1,on1);
}
if(EEPROM.read(2)==0)
{
on2=0;
digitalWrite(relay2,on1);
}
if(EEPROM.read(3)==0)
{
on3=0;
digitalWrite(relay3,on1);
}
if(EEPROM.read(4)==0)
{
on4=0;
digitalWrite(relay4,on4);
}
irrecv.enableIRIn(); // Start the receiver
}
unsigned long last = millis();
void loop() {
if (irrecv.decode(&results))
{
if (results.value == 0x61D6807F)
{ // 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)
{
on1 = !on1;
digitalWrite(relay1, on1 ? HIGH : LOW);
EEPROM.write(1,on1);
}
last = millis();
}
//EXTRA CODE FROM HERE FOR TESTING WITH OTHER REMOTE CONTROLS
if (irrecv.decode(&results))
{
if (results.value == 0x61D640DF)
{ // 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)
{
on1 = !on1;
digitalWrite(relay1, on1 ? HIGH : LOW);
EEPROM.write(1,on1);
}
last = millis();
}
//EXTRA CODE UPTO HERE FOR TESTING WITH OTHER REMOTE CONTROLS
else if (results.value == 0x61D640BF)
{
if (millis() - last > 250)
{
on2 = !on2;
digitalWrite(relay2, on2 ? HIGH : LOW);
EEPROM.write(2,on2);
}
last = millis();
}
else if (results.value == 0x40BD28D7 )
{
if (millis() - last > 250)
{
on1 = !on1;
digitalWrite(relay1, on1 ? HIGH : LOW);
EEPROM.write(1,on1);
}
last = millis();
}
else if (results.value == 0x61D6609F)
{
if (millis() - last > 250)
{
on4 = !on4;
digitalWrite(relay4, on4 ? HIGH : LOW);
EEPROM.write(4,on4);
}
last = millis();
}
irrecv.resume(); // Receive the next value
}
}}
digitalWrite(relay1, on ? HIGH : LOW);
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?