Illumination Controller
Automate house lights and control them with infrared remote.
Components and supplies
3
Resistor 220 ohm
3
LED (generic)
1
9V battery (generic)
1
Infrared Receiver, 38 kHz
1
Jumper wires (generic)
1
Ky-005 Infrared transmitter module
1
Rotary potentiometer (generic)
3
Ky-004 Key Switch Module
1
Gravity: Analog Ambient Light Sensor TEMT6000
2
Arduino UNO
Tools and machines
1
3D Printer (generic)
Apps and platforms
1
Solidworks
1
Arduino IDE
Project description
Code
Remote sketch
c_cpp
1#include <IRremote.h> 2 3IRsend irsend; 4int puls1 = 2; 5int puls2 = 7; 6int ir_emitter = 3; 7void setup() 8{ 9 Serial.begin(9600); 10 pinMode(puls2, INPUT); 11 pinMode(puls1, INPUT); 12 pinMode(ir_emitter, OUTPUT); 13 14} 15void loop() { 16 int puls = 0; 17 int Puls = 0; 18 19 puls = digitalRead(puls2); 20 21 Puls = digitalRead(puls1); 22 23 24 25 26 if (puls == 1) { 27 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}; 28 irsend.sendRaw(on, 68, 38); 29 delay(1000); 30 31 } 32 if (Puls == 1) { 33 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}; 34 irsend.sendRaw(off, 68, 38); 35 delay(1000); 36 37 } 38 39} 40
Controller sketch
c_cpp
1#include <IRremote.h> 2int out = 9; 3int H = 0; 4int N = 0; 5int puls = 2; 6int aut = 4; 7int man = 5; 8int luc_pin = A1; 9int luc = 0; 10int pot = 0; 11int pot_pin = A5; 12int R = 0; 13int ir_ricev = 11; 14IRrecv irrecv (ir_ricev); 15decode_results results; 16void setup () 17{ 18 Serial.begin (9600); 19 pinMode(out, OUTPUT); 20 pinMode(aut, OUTPUT); 21 pinMode(man, OUTPUT); 22 pinMode(puls, INPUT); 23 attachInterrupt(0, Pulsante, CHANGE); 24 pinMode(pot, INPUT); 25 irrecv.enableIRIn (); 26} 27void loop () { 28 if (irrecv.decode (& results)) { 29 30 Serial.println (results.value, HEX); 31 32 33 irrecv.resume (); 34 Serial.println(results.value); 35 } if (results.value == 0xE0E020DF || results.value == 0xE0E040BF ) { 36 R = (results.value); 37 } 38 else { 39 (results.value) = R; 40 } 41 if (results.value == 0XE0E020DF ) { 42 digitalWrite(aut, HIGH); 43 digitalWrite(man, LOW); 44 pot = analogRead(pot_pin); 45 Serial.print("Pot"); 46 Serial.println (pot); 47 luc = analogRead(luc_pin); 48 int L = map(luc, 0, 40, 170, 85); 49 int P = map(pot, 0, 1023, 0, 85); 50 Serial.print("Luc"); 51 Serial.println(luc); 52 if (luc <= 40) { 53 analogWrite(out, (L + P)); 54 delay(2000); 55 } 56 if (luc > 40) { 57 digitalWrite(out, LOW); 58 delay(1000); 59 } 60 61 } 62 if ( results.value == 0XE0E040BF) { 63 digitalWrite(aut, LOW); 64 digitalWrite(man, HIGH); 65 66 67 if (N == 1) { 68 digitalWrite(out, HIGH); 69 delay (500); 70 } 71 if (N == 0) { 72 digitalWrite(out, LOW); 73 delay(500); 74 } 75 } 76} 77 78 79void Pulsante() { 80 H = digitalRead(puls); 81 if (N == 0 && H == 1) { 82 N = 1; 83 H = 0; 84 delay (200); 85 } 86 87 if (N == 1 && H == 1) { 88 N = 0; 89 H = 0; 90 delay (200); 91 } 92} 93
Remote sketch
c_cpp
1#include <IRremote.h> 2 3IRsend irsend; 4int puls1 = 2; 5int puls2 6 = 7; 7int ir_emitter = 3; 8void setup() 9{ 10 Serial.begin(9600); 11 pinMode(puls2, 12 INPUT); 13 pinMode(puls1, INPUT); 14 pinMode(ir_emitter, OUTPUT); 15 16} 17void 18 loop() { 19 int puls = 0; 20 int Puls = 0; 21 22 puls = digitalRead(puls2); 23 24 25 Puls = digitalRead(puls1); 26 27 28 29 30 if (puls == 1) { 31 const 32 unsigned int on[68] = {4600, 4350, 700, 1550, 650, 1550, 650, 1600, 650, 450, 650, 33 450, 650, 450, 650, 450, 700, 400, 700, 1550, 650, 1550, 650, 1600, 650, 450, 650, 34 450, 650, 450, 700, 450, 650, 450, 650, 450, 650, 1550, 700, 450, 650, 450, 650, 35 450, 650, 450, 650, 450, 700, 400, 650, 1600, 650, 450, 650, 1550, 650, 1600, 650, 36 1550, 650, 1550, 700, 1550, 650, 1550, 650}; 37 irsend.sendRaw(on, 68, 38); 38 39 delay(1000); 40 41 } 42 if (Puls == 1) { 43 const unsigned int off[68] 44 = {4650, 4300, 700, 1550, 700, 1550, 650, 1550, 700, 400, 700, 400, 700, 400, 700, 45 450, 700, 400, 700, 1500, 700, 1500, 700, 1550, 700, 450, 650, 400, 700, 450, 650, 46 450, 700, 400, 700, 400, 700, 450, 650, 1550, 700, 400, 700, 400, 700, 400, 700, 47 450, 650, 450, 650, 1550, 700, 1500, 700, 450, 650, 1550, 700, 1550, 650, 1550, 48 700, 1500, 700, 1550, 650}; 49 irsend.sendRaw(off, 68, 38); 50 delay(1000); 51 52 53 } 54 55} 56
Controller sketch
c_cpp
1#include <IRremote.h> 2int out = 9; 3int H = 0; 4int N = 0; 5int 6 puls = 2; 7int aut = 4; 8int man = 5; 9int luc_pin = A1; 10int luc = 0; 11int 12 pot = 0; 13int pot_pin = A5; 14int R = 0; 15int ir_ricev = 11; 16IRrecv irrecv 17 (ir_ricev); 18decode_results results; 19void setup () 20{ 21 Serial.begin (9600); 22 23 pinMode(out, OUTPUT); 24 pinMode(aut, OUTPUT); 25 pinMode(man, OUTPUT); 26 27 pinMode(puls, INPUT); 28 attachInterrupt(0, Pulsante, CHANGE); 29 pinMode(pot, 30 INPUT); 31 irrecv.enableIRIn (); 32} 33void loop () { 34 if (irrecv.decode 35 (& results)) { 36 37 Serial.println (results.value, HEX); 38 39 40 irrecv.resume 41 (); 42 Serial.println(results.value); 43 } if (results.value == 0xE0E020DF 44 || results.value == 0xE0E040BF ) { 45 R = (results.value); 46 } 47 else 48 { 49 (results.value) = R; 50 } 51 if (results.value == 0XE0E020DF ) { 52 53 digitalWrite(aut, HIGH); 54 digitalWrite(man, LOW); 55 pot = analogRead(pot_pin); 56 57 Serial.print("Pot"); 58 Serial.println (pot); 59 luc = analogRead(luc_pin); 60 61 int L = map(luc, 0, 40, 170, 85); 62 int P = map(pot, 0, 1023, 0, 85); 63 64 Serial.print("Luc"); 65 Serial.println(luc); 66 if (luc <= 40) { 67 68 analogWrite(out, (L + P)); 69 delay(2000); 70 } 71 if (luc > 72 40) { 73 digitalWrite(out, LOW); 74 delay(1000); 75 } 76 77 } 78 79 if ( results.value == 0XE0E040BF) { 80 digitalWrite(aut, LOW); 81 digitalWrite(man, 82 HIGH); 83 84 85 if (N == 1) { 86 digitalWrite(out, HIGH); 87 delay 88 (500); 89 } 90 if (N == 0) { 91 digitalWrite(out, LOW); 92 delay(500); 93 94 } 95 } 96} 97 98 99void Pulsante() { 100 H = digitalRead(puls); 101 if 102 (N == 0 && H == 1) { 103 N = 1; 104 H = 0; 105 delay (200); 106 } 107 108 109 if (N == 1 && H == 1) { 110 N = 0; 111 H = 0; 112 delay (200); 113 } 114} 115
Downloadable files
Electric diagram
Electric diagram

Electric diagram
Electric diagram

Documentation
remote body
remote body
remote cover
remote cover
remote body
remote body
Comments
Only logged in users can leave comments