hecey
Publish time 2-12-2019 03:16:05
My code in arduino, volume and power functionalities.
Code: #include #include // Define sensor pinconst int RECV_PIN = 4; byte incomingByte;byte msgTurnOff[] ={0xA6,0x01,0x00,0x00,0x00,0x04,0x01,0x18,0x01,0xBB}; //10byte msgTurnOn[] ={0xA6,0x01,0x00,0x00,0x00,0x04,0x01,0x18,0x02,0xB8}; //10byte getVolume[] ={0xA6,0x01,0x00,0x00,0x00,0x03,0x01,0x45,0xE0}; //9byte setVolume[] ={0xA6,0x01,0x00,0x00,0x00,0x04,0x01,0x44,0x01,0xE7}; //10byte inputSourceHDMI ={{0xA6,0x01,0x00,0x00,0x00,0x07,0x01,0xAC,0x06,0x02,0x00,0x00,0x09},//hdmi {0xA6,0x01,0x00,0x00,0x00,0x07,0x01,0xAC,0x06,0x03,0x00,0x00,0x08}};//MHL-hdmi byte PIP = {{0xA6,0x01,0x00,0x00,0x00,0x07,0x01,0x3C,0x00,0x00,0x00,0x00,0x9D},//off {0xA6,0x01,0x00,0x00,0x00,0x07,0x01,0x3C,0x01,0x00,0x00,0x00,0x9C}};//on byte PIPPosition = {{0xA6,0x01,0x00,0x00,0x00,0x07,0x01,0x3C,0x01,0x00,0x00,0x00,0x9C},//bottom left {0xA6,0x01,0x00,0x00,0x00,0x07,0x01,0x3C,0x01,0x01,0x00,0x00,0x9D},//top left {0xA6,0x01,0x00,0x00,0x00,0x07,0x01,0x3C,0x01,0x02,0x00,0x00,0x9E},//topright {0xA6,0x01,0x00,0x00,0x00,0x07,0x01,0x3C,0x01,0x03,0x00,0x00,0x9F} //bottom roght }; byte PIPSource = {{0xA6,0x01,0x00,0x00,0x00,0x07,0x01,0x84,0xFD,0x02,0x00,0x00,0xDA},//hdmi {0xA6,0x01,0x00,0x00,0x00,0x07,0x01,0x84,0xFD,0x03,0x00,0x00,0xDB}};//mhd-hdmiint currentInputSource = 0;int PIPstate = 0;int PIPPositionState=0;int PIPSourceState=0; bool powerState=true;int volume;int eIndex; #define MAX_MILLIS_TO_WAIT 1000//or whateverunsigned long starttime;byte read_bytes;// Define IR Receiver and Results ObjectsIRrecv irrecv(RECV_PIN);decode_results results;SoftwareSerial gtSerial(7, 8); // Arduino RX, Arduino TXvoid setup(){// Serial Monitor @ 9600 baudSerial.begin(9600,SERIAL_8N1);gtSerial.begin(9600);// Enable the IR Receiverirrecv.enableIRIn(); // initialize digital pin LED_BUILTIN as an output.//pinMode(LED_BUILTIN, OUTPUT); gtSerial.write(getVolume, sizeof(getVolume)); while ( (gtSerial.available() 0) { // read the incoming byte: incomingByte = Serial.read(); // say what you got: // Serial.print(incomingByte, HEX); gtSerial.write(incomingByte); } if (gtSerial.available() > 0) { // read the incoming byte: incomingByte = gtSerial.read(); // say what you got: // Serial.print(incomingByte, HEX); Serial.write(incomingByte); }*/ if (irrecv.decode(&results)){ // Print Code in HEX Serial.println(results.value, HEX); switch(results.value){ case 0x34347887: // power // Turn on LED for 2 Seconds // digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) //gtSerial.write(msg, sizeof(msg)); if(powerState){ msgTurnOff = CheckSum(msgTurnOff,10); gtSerial.write(msgTurnOff, sizeof(msgTurnOff)); powerState=false; }else{ msgTurnOn = CheckSum(msgTurnOn,10); gtSerial.write(msgTurnOn, sizeof(msgTurnOn)); powerState=true; } delay(500); // wait for a second //digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW break; case 0x3434E817: // volume up // Turn on LED for 2 Seconds // digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) if(eIndex!=-1){ // Serial.println(e); if(volume9) volume=volume-10; setVolume=(byte)volume; Serial.println(volume); setVolume = CheckSum(setVolume,10); gtSerial.write(setVolume, sizeof(setVolume)); delay(500); // wait for a second //digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW break; case 0x343459A6: // inputsource // Turn on LED for 2 Seconds //digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) gtSerial.write(inputSourceHDMI, sizeof(inputSourceHDMI)); if(currentInputSource==0) currentInputSource=1; else currentInputSource=0; delay(500); // wait for a second //digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW break; case 0x3434D52A: // PIP On Off gtSerial.write(PIP, sizeof(PIP)); PIPstate; if(PIPstate==2) PIPstate=0; delay(500); // wait for a second break; case 0x343445BA: // PIP Position gtSerial.write(PIPPosition, sizeof(PIPPosition)); PIPPositionState; if(PIPPositionState==4) PIPPositionState=0; delay(500); // wait for a second break; case 0x3434FD02: // PIP source gtSerial.write(PIPSource, sizeof(PIPSource)); PIPSourceState; if(PIPSourceState==2) PIPSourceState=0; delay(500); // wait for a second break; } irrecv.resume(); }}
hecey
Publish time 2-12-2019 03:16:07
I just did it with an arduino. I was wondering how to get the rs232 command to change the audio source. I coulnt find it in the phillips manual.
veitk
Publish time 2-12-2019 03:16:07
i need a ttl/rs232 converter to use it with an arduino right?
i just copied the arduino code and modified it to only switch some stuff as a demo but it doesn't work...
hecey
Publish time 2-12-2019 03:16:08
Yes , you need something like this one:
RS232 Serial Port to TTL Converter Module https://www.amazon.com/dp/B01JYNHNW6/ref=cm_sw_r_cp_apa_i_sreDCbXZH6Q5D