marco_mellanomarcogalletto02
Published

Illumination Controller

Automate house lights and control them with infrared remote.

BeginnerWork in progress717
Illumination Controller

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×2
LED (generic)
LED (generic)
×3
Infrared Receiver, 38 kHz
Infrared Receiver, 38 kHz
×1
Rotary potentiometer (generic)
Rotary potentiometer (generic)
×1
Gravity: Analog Ambient Light Sensor TEMT6000
DFRobot Gravity: Analog Ambient Light Sensor TEMT6000
×1
Ky-004 Key Switch Module
×3
Resistor 220 ohm
Resistor 220 ohm
×3
9V battery (generic)
9V battery (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Ky-005 Infrared transmitter module
×1

Software apps and online services

Solidworks
Arduino IDE
Arduino IDE

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)

Story

Read more

Custom parts and enclosures

remote body

remote cover

Schematics

Electric diagram

Code

Remote sketch

C/C++
#include <IRremote.h>

IRsend irsend;
int puls1 = 2;
int puls2 = 7;
int ir_emitter = 3;
void setup()
{
  Serial.begin(9600);
  pinMode(puls2, INPUT);
  pinMode(puls1, INPUT);
  pinMode(ir_emitter, OUTPUT);

}
void loop() {
  int puls = 0;
  int Puls = 0;

  puls = digitalRead(puls2);

  Puls = digitalRead(puls1);




  if (puls == 1) {
    const unsigned int on[68] = {4600, 4350, 700, 1550, 650, 1550, 650, 1600, 650, 450, 650, 450, 650, 450, 650, 450, 700, 400, 700, 1550, 650, 1550, 650, 1600, 650, 450, 650, 450, 650, 450, 700, 450, 650, 450, 650, 450, 650, 1550, 700, 450, 650, 450, 650, 450, 650, 450, 650, 450, 700, 400, 650, 1600, 650, 450, 650, 1550, 650, 1600, 650, 1550, 650, 1550, 700, 1550, 650, 1550, 650};
    irsend.sendRaw(on, 68, 38);
    delay(1000);

  }
  if (Puls == 1) {
    const unsigned int off[68] = {4650, 4300, 700, 1550, 700, 1550, 650, 1550, 700, 400, 700, 400, 700, 400, 700, 450, 700, 400, 700, 1500, 700, 1500, 700, 1550, 700, 450, 650, 400, 700, 450, 650, 450, 700, 400, 700, 400, 700, 450, 650, 1550, 700, 400, 700, 400, 700, 400, 700, 450, 650, 450, 650, 1550, 700, 1500, 700, 450, 650, 1550, 700, 1550, 650, 1550, 700, 1500, 700, 1550, 650};
    irsend.sendRaw(off, 68, 38);
    delay(1000);

  }

}

Controller sketch

C/C++
#include <IRremote.h>
int out = 9;
int H = 0;
int N = 0;
int puls = 2;
int aut = 4;
int man = 5;
int luc_pin = A1;
int luc = 0;
int pot = 0;
int pot_pin = A5;
int R = 0;
int ir_ricev = 11;
IRrecv irrecv (ir_ricev);
decode_results results;
void setup ()
{
  Serial.begin (9600);
  pinMode(out, OUTPUT);
  pinMode(aut, OUTPUT);
  pinMode(man, OUTPUT);
  pinMode(puls, INPUT);
  attachInterrupt(0, Pulsante, CHANGE);
  pinMode(pot, INPUT);
  irrecv.enableIRIn ();
}
void loop () {
  if (irrecv.decode (& results)) {

    Serial.println (results.value, HEX);


    irrecv.resume ();
    Serial.println(results.value);
  } if (results.value == 0xE0E020DF || results.value == 0xE0E040BF ) {
    R = (results.value);
  }
  else {
    (results.value) = R;
  }
  if (results.value == 0XE0E020DF ) {
    digitalWrite(aut, HIGH);
    digitalWrite(man, LOW);
    pot = analogRead(pot_pin);
    Serial.print("Pot");
    Serial.println (pot);
    luc = analogRead(luc_pin);
    int L = map(luc, 0, 40, 170, 85);
    int P = map(pot, 0, 1023, 0, 85);
    Serial.print("Luc");
    Serial.println(luc);
    if (luc <= 40) {
      analogWrite(out, (L + P));
      delay(2000);
    }
    if (luc > 40) {
      digitalWrite(out, LOW);
      delay(1000);
    }

  }
  if ( results.value == 0XE0E040BF) {
    digitalWrite(aut, LOW);
    digitalWrite(man, HIGH);


    if (N == 1) {
      digitalWrite(out, HIGH);
      delay (500);
    }
    if (N == 0) {
      digitalWrite(out, LOW);
      delay(500);
    }
  }
}


void Pulsante() {
  H = digitalRead(puls);
  if (N == 0 && H == 1) {
    N = 1;
    H = 0;
    delay (200);
  }

  if (N == 1 && H == 1) {
    N = 0;
    H = 0;
    delay (200);
  }
}

Credits

marco_mellano

marco_mellano

1 project • 0 followers
marcogalletto02

marcogalletto02

1 project • 0 followers

Comments