Project tutorial

Using Android Smart Phone to Remote Controller © GPL3+

Do not worry about finding a remote that does not know where you are at home. This project allows you to tune your TV with your smartphone.

  • 1,209 views
  • 1 comment
  • 3 respects

Components and supplies

Necessary tools and machines

Lasercutter
Laser cutter (generic)

Apps and online services

About this project

We often do not know where the TV remote control is located. Every time I go under the sofa or under the bed or even in the refrigerator, I find myself in a niche of the sofa cushions. So I thought. Is there any way I can adjust my TV with my smartphone, which is always in my hands? So I decided to make it by using Arduino and Bluetooth module infrared LED, and finally I succeeded.

Code

MW_Remote.inoArduino
/* Remote Shield Ver 1.0 2016.5.3 Jason Lee */

#include <SoftwareSerial.h>
#include <IRremote.h>
#include <IRremoteInt.h>
#include <EEPROM.h>


#define RECORD_MODE   1
#define DONGLE_MODE   0

const int IR_SIG_PIN = 2;   //     
const int BLUE_LED = 4;       //     LED (Blue Color)
const int GREEN_LED = 5;    //     LED (Green Color)
const int RED_LED = 6;      //      LED (RED Color)
const int bluetoothTx = 7;
const int bluetoothRx = 8;

const int MEM_ADDR_START = 0;
int mode = DONGLE_MODE;
char curKey = '\0';

struct RemoteKeyValue {
  int key;
  unsigned long val;
  int type;
};

SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);
IRrecv irrecv(IR_SIG_PIN);
IRsend irsend;
decode_results decodedSignal;

void setup() {
  Serial.begin(9600);
  while (!Serial) {}
  bluetooth.begin(9600);
  bluetooth.write("AT+NAMEMW-Remote");
  irsend.enableIROut(38);
  irrecv.enableIRIn();
  pinMode(GREEN_LED, OUTPUT);
  pinMode(BLUE_LED, OUTPUT);
  pinMode(RED_LED, OUTPUT);
  Serial.println("I'm ready. yo man!");
  blinkLEDColor(255,0,0,100);
  blinkLEDColor(0,0,0,50);
  blinkLEDColor(255,0,0,100);
  blinkLEDColor(0,0,0,200);
  blinkLEDColor(0,255,0,100);
  blinkLEDColor(0,0,0,50);
  blinkLEDColor(0,255,0,100);
  blinkLEDColor(0,0,0,200);
  blinkLEDColor(0,0,255,200);
  blinkLEDColor(0,0,0,50);
  blinkLEDColor(0,0,255,200);
  offLED();
  mode = DONGLE_MODE;
}

void loop() {
  btProc();
  if (mode == RECORD_MODE)
    irRecProc();
}

unsigned long last = millis();

void irRecProc() {
  struct RemoteKeyValue RetSig;

  if (irrecv.decode(&decodedSignal) == true) {
    Serial.print("IR Signal Received. [KEY=");
    Serial.print(curKey);
    Serial.println("]");
    offLED();
    blinkLEDColor(255,0,0,500);  
    blinkLEDColor(0,0,0,50);
    blinkLEDColor(255,0,0,500);  
    if (millis() - last > 250) {
      RetSig.key =  1;
      RetSig.val = decodedSignal.value;
      RetSig.type = decodedSignal.decode_type;
      
      EEPROM.put(MEM_ADDR_START+sizeof(struct RemoteKeyValue)*(curKey-'1'), RetSig);
      Serial.print("Saving IR Signal value=[");
      Serial.print(decodedSignal.value, HEX);
      Serial.print("], IR Signal TYPE=[");
      Serial.print(decodedSignal.decode_type);
      Serial.println("]. Remote signal completely copied.\n\r");
      mode = DONGLE_MODE;  
      offLED();
    }
    last=millis();
    irrecv.resume();
  }
}

void btProc() {
  char cmd;
  struct RemoteKeyValue rKey;
  
  if (bluetooth.available()) {
    Serial.println("BT Command Received. ");
    cmd = (char)bluetooth.read();
    Serial.println(mode);
    if (mode == RECORD_MODE) {
      setLEDColor(0,255,0);
    } else {
      blinkLEDColor(255,0,0,500);    
    }
    curKey = cmd;
    if (mode == DONGLE_MODE) {
      Serial.println("DONGLE MODE ");
      EEPROM.get(MEM_ADDR_START+sizeof(struct RemoteKeyValue)*(cmd - '1'), rKey);
      if (cmd != 's') {
        switch (rKey.type) {
          case NEC :
            irsend.sendNEC(rKey.val,32);
            Serial.print("SEND : ["); Serial.print(rKey.val,HEX); Serial.println("], NEC Type\n\r");        
            break;
          case SONY :
            irsend.sendSony(rKey.val,32);
            Serial.print("SEND : ["); Serial.print(rKey.val,HEX); Serial.println("], SONY Type\n\r");        
            break;
          case RC5 :
            irsend.sendRC5(rKey.val,32);
            Serial.print("SEND : ["); Serial.print(rKey.val,HEX); Serial.println("], RC5 Type\n\r");        
            break;
          case RC6 :
            irsend.sendRC6(rKey.val,32);
            Serial.print("SEND : ["); Serial.print(rKey.val,HEX); Serial.println("], RC6 Type\n\r");        
            break;
          case DISH :
            irsend.sendDISH(rKey.val, 32);
            Serial.print("SEND : ["); Serial.print(rKey.val,HEX); Serial.println("], DISH Type\n\r");        
            break;
          case PANASONIC :
            irsend.sendPanasonic(rKey.val, 32);
            Serial.print("SEND : ["); Serial.print(rKey.val,HEX); Serial.println("], Panasonic Type\n\r");        
            break;
          case JVC :
            irsend.sendJVC(rKey.val, 32, 1);
            Serial.print("SEND : ["); Serial.print(rKey.val,HEX); Serial.println("], JVC Type\n\r");        
            break;
          case SAMSUNG :
            irsend.sendSAMSUNG(rKey.val, 32);
            Serial.print("SEND : ["); Serial.print(rKey.val,HEX); Serial.println("], SAMSUNG Type\n\r");        
            break;
          case UNKNOWN:
            Serial.print("SEND : ["); Serial.print(rKey.val,HEX); Serial.println("], UNKNOWN Type");        
            Serial.println("Cannot send unknown signal type.\n\r");        
            break;
          default:
            Serial.println("Undefined Type.\n\r");        
            break;
        }
      } else {
        Serial.println("command s reveived.");
        if (mode == DONGLE_MODE) {
          Serial.println("Setting Mode Start. Select Key index on your phone.\n\r");
          mode = RECORD_MODE;
          setLEDColor(0,0,255);
        } else {
          Serial.println("Setting Mode Terminated.\n\r");
          mode = DONGLE_MODE;
          offLED();                            
        }
      }
    } 
  }  
}

void blinkLEDColor(int r, int g, int b, int d) {
  int tmpR, tmpG, tmpB;
  
  analogWrite(BLUE_LED,b);
  analogWrite(GREEN_LED,g);
  analogWrite(RED_LED,r);
  delay(d);
  offLED();
}

void setLEDColor(int r, int g, int b) {
  analogWrite(BLUE_LED,b);
  analogWrite(GREEN_LED,g);
  analogWrite(RED_LED,r);
}

void offLED() {
  analogWrite(BLUE_LED,0);
  analogWrite(GREEN_LED,0);
  analogWrite(RED_LED,0);
}

Schematics

Dongle4_bb.jpg
Dongle4 bb

Comments

Similar projects you might like

High Precision Scale with Arduino

Project showcase by mPelectronic

  • 3,847 views
  • 11 comments
  • 20 respects

WIZnet S2E Deadbolts

Project tutorial by S2E Lock

  • 1,231 views
  • 2 comments
  • 8 respects

Super-Go: An Industrial IoT bot

Project tutorial by KS

  • 737 views
  • 2 comments
  • 6 respects

Kravox! Wireless, Motion and Touch-Sensing Instrument

Project tutorial by Tim Krahmer

  • 109 views
  • 0 comments
  • 4 respects

GPS Tracking System for Vehicles

Project showcase by Sustainable Living Lab

  • 4,313 views
  • 1 comment
  • 22 respects

Automatic Watering System

Project tutorial by Manson Hau

  • 5,755 views
  • 11 comments
  • 29 respects
Add projectSign up / Login