Hello all, I'm currently building a controller with a touchpad interface using a Dwin display. without boring you with all the details i have minimised some test code as an example to show my issue.
I have a touch button output from the touchpad that is sending 9 bytes of data ( have confirmed this is working through serial monitor and i get the following hex data:
5A A5 06 83 11 02 01 00 01
i have sent hex data from the mega to the dwin display with no issues ( the display reacts to an analog read that i updated in hex) but i cant get any serial coming back to the arduino from this button press.
I was using serial1 initially but thought that may have an issue so then used software serial for the same pins on my pcb and same thing.
Then i thought maybe its something to do with the case scenario so decided to check if i could get any serial available and blink the built in led
Hoping someone can briefly check my code to make sure its not something small i have done or missed. Otherwise i'm assuming its a faulty wire between etc as touchpad is fine still works if i go direct to pc over serial using the HDL662B converter to check serial over usb ?
Please find the code below, Thanks for your time
// Library Inclusions
#include <SoftwareSerial.h>
// Data Receiving and sending parameters
unsigned char Buffer[9];
const byte rxPin = 19;
const byte txPin =18;
SoftwareSerial TouchpadSerial(rxPin, txPin);
void setup() {
// put your setup code here, to run once:
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
RecvData();
}
void RecvData(){
if(TouchpadSerial.available() )
{
//debug if serial is being received
digitalWrite(LED_BUILTIN,HIGH);
delay(1000);
digitalWrite(LED_BUILTIN,LOW);
// end debug
for(int i=0;i<=8;i++) //TO store whole frame in buffer array. (5A A5 06 83 11 02 01 00 01)
{
Buffer[i]= TouchpadSerial.read();
}
if(Buffer[0]== 0x5A)
{
digitalWrite(LED_BUILTIN,HIGH);
switch(Buffer[4])
{
case 0x11: //Change Settings
if(Buffer[8] == 1) // Handbrake (5A A5 06 83 11 02 01 00 01)
{
Serial.println("Handbrake Mode Activated");
digitalWrite(LED_BUILTIN,HIGH);
}
else
{
Serial.println("Handbrake Mode Deactivated");
digitalWrite(LED_BUILTIN,LOW);
}
break;
default:
Serial.println("No Data");
break;
}
}
}
}