Skip to content

Commit

Permalink
Clean code
Browse files Browse the repository at this point in the history
Clean code and complete readme
  • Loading branch information
Susensio committed Jan 29, 2018
1 parent d386030 commit dc2acde
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 40 deletions.
63 changes: 26 additions & 37 deletions IR-remote-translator.ino
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,16 @@ decode_results irIn;

unsigned long lastCode;

//unsigned int onOff[67] = {4400,4450, 550,1650, 550,1650, 600,500, 550,550, 550,550, 600,500, 550,1650, 550,550, 550,1650, 550,1650, 600,500, 550,550, 600,1600, 600,500, 550,1700, 550,500, 550,1700, 550,550, 600,500, 550,550, 600,500, 550,550, 600,500, 550,550, 550,550, 600,1600, 550,1650, 550,1650, 550,1650, 550,1650, 550,1650, 550,1650, 550}; // SAMSUNG C2CA807F
//unsigned int volUp[67] = {4450,4400, 600,1650, 550,1650, 550,550, 550,550, 550,550, 550,550, 550,1650, 550,550, 550,1650, 550,1650, 550,550, 550,550, 550,1650, 600,500, 550,1650, 600,500, 550,1650, 550,1650, 550,550, 600,500, 550,1650, 600,1600, 600,550, 550,550, 550,550, 550,500, 600,1650, 550,1650, 550,550, 550,550, 550,1650, 550,1650, 550}; // SAMSUNG C2CACC33
//unsigned int volDown[67] = {4450,4400, 600,1650, 550,1650, 550,550, 550,550, 550,550, 550,550, 550,1650, 600,500, 550,1650, 550,1650, 550,550, 550,550, 550,1650, 600,500, 550,1600, 650,500, 550,1650, 550,1650, 550,550, 550,1650, 550,1650, 550,1650, 600,500, 600,500, 600,500, 600,500, 550,1700, 550,550, 550,550, 550,500, 600,1650, 550,1600, 600}; // SAMSUNG C2CADC23


void setup() {
// Serial.begin(115200);
irDetect.enableIRIn(); // Start the Receiver

pinMode(LED_BUILTIN ,OUTPUT);

// IR receiver power pins
pinMode(IR_VCC_PIN, OUTPUT);
digitalWrite(IR_VCC_PIN, HIGH);

pinMode(IR_GND_PIN, OUTPUT);
digitalWrite(IR_GND_PIN, LOW);
}
Expand All @@ -41,52 +38,44 @@ void loop() {
}


void decodeIR() { // Indicate what key is pressed
void decodeIR() { // Indicate what key is pressed
static unsigned long lastCode;
unsigned long code = 0;

switch(irIn.value) {
case 0x20DF10EF: // ON/OFF
digitalWrite(LED_BUILTIN, HIGH);
// Serial.println("On/off");
lastCode = 0xC2CA807F;
irsend.sendSAMSUNG(lastCode, 32);
case 0x20DF10EF: // ON/OFF
code = 0xC2CA807F;
break;

case 0x20DF40BF: // Vol+
digitalWrite(LED_BUILTIN, HIGH);
// Serial.println("Vol up");
lastCode = 0xC2CACC33;
irsend.sendSAMSUNG(lastCode, 32);
case 0x20DF40BF: // Vol+
code = 0xC2CACC33;
break;

case 0x20DFC03F: // Vol-
digitalWrite(LED_BUILTIN, HIGH);
// Serial.println("Vol down");
lastCode = 0xC2CADC23;
irsend.sendSAMSUNG(lastCode, 32);
case 0x20DFC03F: // Vol-
code = 0xC2CADC23;
break;

case 0x20DF906F: // Mute
digitalWrite(LED_BUILTIN, HIGH);
// Serial.println("Mute");
lastCode = 0xC2CA9C63;
irsend.sendSAMSUNG(lastCode, 32);
case 0x20DF906F: // Mute
code = 0xC2CA9C63;
break;

case 0xFFFFFFFF:
// Serial.println("Repeat");
if (lastCode != 0){
digitalWrite(LED_BUILTIN, HIGH);
irsend.sendSAMSUNG(lastCode, 32);
}
case 0xFFFFFFFF: // Repeat
code = lastCode;
break;

default:
// Serial.println("Other");
lastCode = 0;
default: // Not a valid key
code = 0;
break;
}

if (code != 0){
digitalWrite(LED_BUILTIN, HIGH);
irsend.sendSAMSUNG(code, 32);

}

lastCode = code;

delay(10);
digitalWrite(LED_BUILTIN, LOW);

// Serial.println(lastCode,HEX);
}
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# IR remote translator
Translates IR basic commands from LG remote to Samsung home cinema

Translates IR basic commands from LG remote to Samsung home cinema. This allows volume control of digital audio signal with one single remote.

| Command | LG ==> | Samsung |
| -------- | -------- | -------- |
Expand All @@ -9,14 +10,18 @@ Translates IR basic commands from LG remote to Samsung home cinema
| Mute | 20DF906F | C2CA9C63 |


## Prerequisites
## Dependencies

Arduino libraries used in this project:

- [IRremote](https://github.com/z3t0/Arduino-IRremote)

## Usage

Connect IR receiver to pin 11 and IR led to pin 3
Connect IR receiver to pin 4 and IR led to pin 3

![alt text](schematic.png "Schematic")


## Credits

Expand Down
Binary file added schematic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit dc2acde

Please sign in to comment.