|
I will add some images, of what I tried and have success, btw Andy's app work like a charm, I used a ugreen cable and a selfmade serial to 2.5mm cable.
After a while I wanted to move Andy's code to arduino, I have tested my arduino code with a simple command, changing the source port to DisplayPort. I have proved that the bytes sender are correct, my monitor is responding correctly. If something don't work just change rx and tx
Code: #include #include // Define sensor pinconst int RECV_PIN = 4; byte incomingByte; //byte msg[] ={0xA6, 0x01, 0x00, 0x00, 0x00, 0x07, 0x01, 0xAC, 0x09, 0x04, 0x01, 0x00, 0x01}; byte msg[] ={166, 1, 0, 0, 0, 7, 1, 172, 9, 4, 1, 0, 1}; // Define IR Receiver and Results ObjectsIRrecv irrecv(RECV_PIN);decode_results results;SoftwareSerial gtSerial(7, 8); // Arduino RX, Arduino TXvoid setup(){ // Serial Monitor @ 9600 baud Serial.begin(9600,SERIAL_8N1); gtSerial.begin(9600); // Enable the IR Receiver irrecv.enableIRIn(); // initialize digital pin LED_BUILTIN as an output. pinMode(LED_BUILTIN, OUTPUT);/* while (!Serial) { ; // wait for serial port to connect. Needed for native USB port only } */}void loop(){ 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 0xFFA25D: // power // Turn on LED for 2 Seconds digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) //msg[13] = CheckSum(); gtSerial.write(msg, sizeof(msg)); delay(1000); // wait for a second digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW break; } irrecv.resume(); }} |
|