stegabetti
Published © GPL3+

Battery Powered TV Remote Control with 3D-Printed Case

Make your own TV remote!

IntermediateFull instructions provided9,330
Battery Powered TV Remote Control with 3D-Printed Case

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
9V battery (generic)
9V battery (generic)
×1
9V to Barrel Jack Connector
9V to Barrel Jack Connector
×1
IR transmitter (generic)
×1
Machine Screw, M3
Machine Screw, M3
×4
Machine Screw, M2.5
Machine Screw, M2.5
×3
M3 nut
×4
M2.5 nut
×3
Through Hole Resistor, 47 ohm
Through Hole Resistor, 47 ohm
×2
Prototyping board, 2.54 mm
×1
PCB push button
×6
Male-Header 36 Position 1 Row- Long (0.1")
Male-Header 36 Position 1 Row- Long (0.1")
×1

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)
Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free
PLA filament, diameter 1.75 mm

Story

Read more

Custom parts and enclosures

base_stl_AlV48IAapv.STL

coperchio_stl_TjKnGcR3uQ.STL

Schematics

remote_zhQ3qUiq1W.pdf

Breadboard view

Fritzing diagram

Code

TV_remote.ino

Arduino
#include <IRremote.h>
#include <avr/sleep.h>
#include <avr/power.h>
// Pin definition
// An IR LED must be connected to Arduino PWM pin 3
#define OnOff 1
#define Source 0
#define CH_plus 4
#define CH_minus 5
#define Vol_plus 6
#define Vol_minus 7
#define Interrupt_Pin 2 //Only pin 2 or 3 on Arduino Uno
// TV model definition
//#define LG_TV
//#define SAMSUNG_TV
#define SONY_TV
// Codes definition
#ifdef LG_TV
  unsigned long on_off_code = 551489775; // HEX 20DF10EF
  unsigned long vol_plus_code = 551502015; //HEX 20DF40BF
  unsigned long vol_minus_code = 551534655; //HEX 20DFC03F
  unsigned long ch_plus_code = 551485695; //HEX 20DF00FF
  unsigned long ch_minus_code = 551518335; //HEX 20DF807F
  unsigned long source_code = 551538735; //HEX 20DFD02F
#endif
#ifdef SAMSUNG_TV
  unsigned long on_off_code = 3772793023; // HEX E0E040BF
  unsigned long vol_plus_code = 3772833823; //HEX E0E0E01F
  unsigned long vol_minus_code = 3772829743; //HEX E0E0D02F
  unsigned long ch_plus_code = 3772795063; //HEX E0E048B7
  unsigned long ch_minus_code = 3772778743; //HEX E0E008F7
  unsigned long source_code = 3772809343; //HEX E0E0807F
#endif
#ifdef SONY_TV
  unsigned long on_off_code = 2704; //HEX A90
  unsigned long vol_plus_code = 1168; //HEX 490
  unsigned long vol_minus_code = 3216; //HEX C90
  unsigned long ch_plus_code = 144; //HEX 090
  unsigned long ch_minus_code = 2192; //HEX 890
  unsigned long source_code = 2640; //HEX A50
#endif
//Enable Debug
//#define DEBUG
//
IRsend irsend; //Create IR object
unsigned long debounce_time;
unsigned long last_time;

void setup() {
  analogWrite(13,0); //turn of builtin led
  //noInterrupts(); //disable interrupts
  //CLKPR = _BV(CLKPCE); //enable clock prescaler settings
  //CLKPR = _BV(CLKPS0); //set clock prescaler = 2 --> 8 MHz
  //interrupts();
  pinMode(OnOff,INPUT_PULLUP);
  pinMode(Source,INPUT_PULLUP);
  pinMode(CH_plus,INPUT_PULLUP);
  pinMode(CH_minus,INPUT_PULLUP);
  pinMode(Vol_plus,INPUT_PULLUP);
  pinMode(Vol_minus,INPUT_PULLUP);
  pinMode(Interrupt_Pin,INPUT_PULLUP);
  //power saving
  power_adc_disable(); //disable all ADCs
  power_spi_disable(); //disable SPI
  power_timer1_disable(); //disbale timer 1 (0 is for millis(), 2 is for irremote.h)
  power_usart0_disable(); //disable serial
  power_twi_disable(); //disable TWI
  #ifdef DEBUG
    Serial.begin(9600);
  #endif
}

void loop() {
 //check OnOff
 if (!digitalRead(OnOff)) {
  debounce_time = millis();
  while (millis() - debounce_time < 40 ) {
    ;
  }
  if (!digitalRead(OnOff)) {
    #ifdef LG_TV
      irsend.sendNEC(on_off_code, 32);
    #endif
    #ifdef SAMSUNG_TV
      irsend.sendSAMSUNG(on_off_code, 32);
    #endif
    #ifdef SONY_TV
      irsend.sendSony(on_off_code, 12);
    #endif
    last_time = millis(); //last time a button was pressed
    #ifdef DEBUG
      Serial.println("OnOff");
    #endif
  }
 }
 //check Source
 if (!digitalRead(Source)) {
  debounce_time = millis();
  while (millis() - debounce_time < 40 ) {
    ;
  }
  if (!digitalRead(Source)) {
    #ifdef LG_TV
      irsend.sendNEC(source_code, 32);
    #endif
    #ifdef SAMSUNG_TV
      irsend.sendSAMSUNG(source_code, 32);
    #endif
    #ifdef SONY_TV
      irsend.sendSony(source_code, 12);
    #endif
    last_time = millis(); //last time a button was pressed
    #ifdef DEBUG
      Serial.println("Source");
    #endif
  }
 }
 //check CH_plus
 if (!digitalRead(CH_plus)) {
  debounce_time = millis();
  while (millis() - debounce_time < 40 ) {
    ;
  }
  if (!digitalRead(CH_plus)) {
    #ifdef LG_TV
      irsend.sendNEC(ch_plus_code, 32);
    #endif
    #ifdef SAMSUNG_TV
      irsend.sendSAMSUNG(ch_plus_code, 32);
    #endif
    #ifdef SONY_TV
      irsend.sendSony(ch_plus_code, 12);
    #endif
    last_time = millis(); //last time a button was pressed
    #ifdef DEBUG
      Serial.println("CH+");
    #endif
  }
 }
 //check CH_minus
 if (!digitalRead(CH_minus)) {
  debounce_time = millis();
  while (millis() - debounce_time < 40 ) {
    ;
  }
  if (!digitalRead(CH_minus)) {
    #ifdef LG_TV
      irsend.sendNEC(ch_minus_code, 32);
    #endif
    #ifdef SAMSUNG_TV
      irsend.sendSAMSUNG(ch_minus_code, 32);
    #endif
    #ifdef SONY_TV
      irsend.sendSony(ch_minus_code, 12);
    #endif
    last_time = millis(); //last time a button was pressed
    #ifdef DEBUG
      Serial.println("CH-");
    #endif
  }
 }
 //check Vol_plus
 if (!digitalRead(Vol_plus)) {
  debounce_time = millis();
  while (millis() - debounce_time < 40 ) {
    ;
  }
  if (!digitalRead(Vol_plus)) {
    #ifdef LG_TV
      irsend.sendNEC(vol_plus_code, 32);
    #endif
    #ifdef SAMSUNG_TV
      irsend.sendSAMSUNG(vol_plus_code, 32);
    #endif
    #ifdef SONY_TV
      irsend.sendSony(vol_plus_code, 12);
    #endif
    last_time = millis(); //last time a button was pressed
    #ifdef DEBUG
      Serial.println("Vol+");
    #endif
  }
 }
 //check Vol_minus
 if (!digitalRead(Vol_minus)) {
  debounce_time = millis();
  while (millis() - debounce_time < 40 ) {
    ;
  }
  if (!digitalRead(Vol_minus)) {
    #ifdef LG_TV
      irsend.sendNEC(vol_minus_code, 32);
    #endif
    #ifdef SAMSUNG_TV
      irsend.sendSAMSUNG(vol_minus_code, 32);
    #endif
    #ifdef SONY_TV
      irsend.sendSony(vol_minus_code, 12);
    #endif
    last_time = millis(); //last time a button was pressed
    #ifdef DEBUG
      Serial.println("Vol-");
    #endif
  }
 }
 if (millis()-last_time > 5000) { //a button has not been pressed for 10 s
  #ifdef DEBUG
      Serial.println("Going to sleep...");
  #endif
  going_to_sleep(); //enter sleep mode
  #ifdef DEBUG
      Serial.println("Waking up...");
  #endif
 }
}

//Sleep Mode function
void going_to_sleep() {
  sleep_enable(); //enable sleep mode
  attachInterrupt(digitalPinToInterrupt(Interrupt_Pin), wake_up, LOW); //interrupt for waking up --> configure Interrupt Pin as a WIRED NOR!!!
  set_sleep_mode(SLEEP_MODE_PWR_DOWN); //full sleep mode
  sleep_cpu(); //activate sleep mode
}

//Wake Up function
void wake_up() {
  sleep_disable(); //disable sleep mode
  detachInterrupt(digitalPinToInterrupt(Interrupt_Pin)); //remove the interrupt
}

Credits

stegabetti

stegabetti

1 project • 2 followers

Comments