License

Public Domain

Recommend Projects

ARDUINO IR HOME AUTOMATION SYSTEM SHEILD

1 year ago 216
  • Description
  • Documents
  • BOM
  • Attachments
  • Members
  • Comments

Description

with this sheild u can controll a 2 relays using an IR remote.BELOW IS THE CODE. AND NOTE,(IF THE REMOTE CORDIATES ARE DIFFERENT COMPARING TO THE ONE IN THE CODE,SIMPLY GO TO EXAMPLES>IR REMOTE>IR RECIV_DUMP. ONCE U GET THE NUMBERS U CAN TYPTE IT IN UR CODE.

____THE CODE____

/*

  • 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

int RECV_PIN = 10; int RELAY_PIN = 6; int RELAY_PIN2 = 8;

IRrecv irrecv(RECV_PIN); decode_results results;

// Dumps out the decode_results structure. // Call this after IRrecv::decode() // void to work around compiler issue //void dump(void v) { // decode_results results = (decode_results )v void dump(decode_results *results) { int count = results->rawlen;

}

void setup() { pinMode(RELAY_PIN, OUTPUT); pinMode(RELAY_PIN2,OUTPUT); pinMode(13, OUTPUT); Serial.begin(9600); irrecv.enableIRIn(); // Start the receiver }

int on = 0; unsigned long last = millis();

define BUTTON_1 0xFF30CF

define BUTTON_2 0xFF18E7

define BUTTON_3 0xFF7A85

define BUTTON_0 0xFF6897

define BUTTON_OK 0xFF629D

void loop() { if (irrecv.decode(&results)) { if (results.value == BUTTON_2) {

  on = !on;
  digitalWrite(RELAY_PIN, on ? HIGH : LOW);
  digitalWrite(13, on ? HIGH : LOW);
  dump(&results);

if (results.value == BUTTON_1)
{

  on = !on;
  digitalWrite(RELAY_PIN2, on ? HIGH : LOW);
  digitalWrite(13, on ? HIGH : LOW);
  dump(&results);
}

 if (results.value == BUTTON_OK)
{

  on = !on;
  digitalWrite(RELAY_PIN2, on ? HIGH : LOW);
  digitalWrite(RELAY_PIN, on ? HIGH : LOW);
  digitalWrite(13, on ? HIGH : LOW);
  dump(&results);
}

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

} }

Documents

Sheet_1

ARDUINO HOME AUTOMATION SYSTEM

BOM

None

Attachments

None
Success
The owner does not allow comments in this project now

Comments (1)

Daniel Avery Reply

THE CODE IS,


/
* 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


include \


int RECV_PIN = 10;
int RELAY_PIN = 6;
int RELAY_PIN2 = 8;


IRrecv irrecv(RECV_PIN);
decode_results results;


// Dumps out the decode_results structure.
// Call this after IRrecv::decode()
// void to work around compiler issue
//void dump(void
v) {
//  decode_results *results = (decode_results *)v
void dump(decode_results *results) {
  int count = results->rawlen;


}


void setup()
{
  pinMode(RELAY_PIN, OUTPUT);
  pinMode(RELAY_PIN2,OUTPUT);
  pinMode(13, OUTPUT);
    Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
}


int on = 0;
unsigned long last = millis();


define BUTTON_1 0xFF30CF


define BUTTON_2 0xFF18E7


define BUTTON_3 0xFF7A85


define BUTTON_0 0xFF6897


define BUTTON_OK 0xFF629D


void loop() {
  if (irrecv.decode(&results)) {
    if (results.value == BUTTON_2)
    {


      on = !on;
      digitalWrite(RELAY_PIN, on ? HIGH : LOW);
      digitalWrite(13, on ? HIGH : LOW);
      dump(&results);


    if (results.value == BUTTON_1)
    {


      on = !on;
      digitalWrite(RELAY_PIN2, on ? HIGH : LOW);
      digitalWrite(13, on ? HIGH : LOW);
      dump(&results);
    }


     if (results.value == BUTTON_OK)
    {


      on = !on;
      digitalWrite(RELAY_PIN2, on ? HIGH : LOW);
      digitalWrite(RELAY_PIN, on ? HIGH : LOW);
      digitalWrite(13, on ? HIGH : LOW);
      dump(&results);
    }


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

goToTop
你现在访问的是EasyEDA海外版,使用建立访问速度更快的国内版 https://lceda.cn(需要重新注册)
如果需要转移工程请在个人中心 - 工程 - 工程高级设置 - 下载工程,下载后在https://lceda.cn/editor 打开保存即可。
有问题联系QQ 3001956291 不再提醒
svg-battery svg-battery-wifi svg-books svg-more svg-paste svg-pencil svg-plant svg-ruler svg-share svg-user svg-logo-cn svg-double-arrow
We use cookies to offer you a better experience. Detailed information on the use of cookies on this website is provided in our Privacy Policy. By using this site, you consent to the use of our cookies.