Serial in, decimal to ASCII, and other problems

I am stuck and have no idea how to proceed.

I have a touch screen controller that outputs UART. When using a bus pirate, the data output per touch is in this format...

XXXX XXXX

So a few touches looks like this

0830 2019
3102 1209
2019 2209

I am trying to use an Arduino Uno to take the serial data and make it display the same in serial monitor. I can get it to communicate, but have no idea how to convert the data into ASCII and have it display in the same format.

Using this example code...

int incomingByte = 0;

void setup() {

Serial.begin(2400); // opens serial port, sets data rate to 2400 bps

}

void loop() {

if (Serial.available() > 0) {

incomingByte = Serial.read(); // read the incoming byte:

Serial.print(" I received:");

Serial.println(incomingByte);

}

}

Per touch, I get something like this...

I received:0
I received:121
I received:189
I received:150
I received:214
I received:153
I received:191
I received:157
I received:149
I received:153
I received:141
I received:0

If I can just get past this hurdle I can handle the rest, I'm just not sure how to go about it. I've been reading for six hours and my head wants to explode. Electrically I have it, I just cant it to format it the way I need.

This is frustrating.

The ever famous Serial Input Basics thread would be a great place to start.

Wait, are you saying you're trying to convert 0830 2019 into the character string "0830 2019"?

Convert from decimal to ascii by doing this:

byte num = 4;
char asciiNum = num + '0';

Delta_G:
The ever famous Serial Input Basics thread would be a great place to start.

I have read it so many times I can recite it. I am on 39 hours of no sleep so im sure that is half my battle at this point.

Basically, if I read the serial from the TS controller, I am getting serial data that is in an ASCII format and it displays like XXXX XXXX.

If I feed the data burst into a duino, I get...

XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
0

Im assuming it is in decimal. Just trying to get that to convert into the same ASCII format. I know the incoming serial data is in ASCII, I'm just making it difficult.

I think I'm fighting myself here, coffee is starting to kick in. Looks like I need to put it into a string, then convert to ASCII. Right now, I'm just throwing data at it and hoping it will stick.

Part of the issue is putting incomingByte into an int.

When you call print with an int it will print that decimal value as a default. But if you use a char it will assume the value is ascii. It may be as simple as:

Serial.println((char)incomingByte);

CST123:
Im assuming it is in decimal. Just trying to get that to convert into the same ASCII format. I know the incoming serial data is in ASCII, I’m just making it difficult.

Converting between ASCII and decimal is really easy, to convert from decimal numbers to ASCII numbers, add ‘0’. Going from ASCII numbers to decimals, just subtract ‘0’.

Now, if the numbers in ASCII are more than one digit long, it gets more complicated…