Basically I'm writing some code for a TFT screen. In the program I have made buttons (a numberpad) and as the buttons for the numbers are pressed they are stored in an array. I plan on having the numbers update and display on the screen as they are pressed but am for now sending them to the serial monitor for debugging. I am aware that serial monitor prints chars in ASCii, but the chars im getting are not the ascii of what I am storing as the buttons are pressed.
The picture attached below shows what is happening in the serial monitor... I press a 1 and get an O, press a 2 and get a Q, etc. I tried printing to the TFT screen as well, the same strange characters are printed instead of the numbers stored so its not a serial thing and more a my usage or misunderstanding of how to use char arrays. What am I missing here that numbers are being stored weird and returned as strange chars?
Thanks in advance
Relevant code:
char POarray[11] = "***********";
int k = 0;
void PO()
{
while(k<=10)
{
retrieveTouch();
if (Z > MINPRESSURE && Z < MAXPRESSURE)
{
//Check if element clicked is in left column
if (Y > (leftColPositionX - BOXSIZE) && Y < (leftColPositionX - 5))
{
//Serial.println("LEFT");
//Check if element clicked is in row 1
if (X > topbot && X < toptop)
{
Serial.println("1");
POarray[k] = "1";
Serial.println(POarray);
k++;
delay(400);
tft.setCursor(100, 10);
tft.setTextColor(RED);
tft.setTextSize(3);
tft.print(POarray);
}
//Check if element clicked is in row 2
else if (X > mid && X < topbot)
{
Serial.println("4");
POarray[k] = "4";
Serial.println(POarray);
k++;
delay(400);
}
//Check if element clicked is in row 3
else if (X < mid && X > bottop)
{
Serial.println("7");
POarray[k] = "7";
Serial.println(POarray);
k++;
delay(400);
}
//Check if element clicked is in row 4
else if (X < bottop && X > botbot)
{
Serial.println("0");
POarray[k] = "0";
Serial.println(POarray);
k++;
delay(400);
}
}
//Check if element clicked is in mid column
else if (Y > (midColPositionX - 6 - BOXSIZE) && Y < (midColPositionX - 10))
{
//Check if element clicked is in row 1
if (X > topbot && X < toptop)
{
Serial.println("2");
POarray[k] = "2";
Serial.println(POarray);
k++;
delay(400);
}
//Check if element clicked is in row 2
else if (X > mid && X < topbot)
{
Serial.println("5");
POarray[k] = "5";
Serial.println(POarray);
k++;
delay(400);
}
//Check if element clicked is in row 3
else if (X < mid && X > bottop)
{
Serial.println("8");
POarray[k] = "8";
Serial.println(POarray);
k++;
delay(400);
}
//Check if element clicked is in row 4
else if (X < bottop && X > botbot)
{
Serial.println("0");
POarray[k] = "0";
Serial.println(POarray);
k++;
delay(400);
}
}
else if (Y > (rightColPositionX - 14 - BOXSIZE) && Y < (rightColPositionX - 20))
{
//Check if element clicked is in row 1
if (X > topbot && X < toptop)
{
Serial.println("3");
POarray[k] = "3";
Serial.println(POarray);
k++;
delay(400);
}
//Check if element clicked is in row 2
else if (X > mid && X < topbot)
{
Serial.println("6");
POarray[k] = "6";
Serial.println(POarray);
k++;
delay(400);
}
//Check if element clicked is in row 3
else if (X < mid && X > bottop)
{
Serial.println("9");
POarray[k] = "9";
Serial.println(POarray);
k++;
delay(400);
}
//Check if element clicked is in row 4
else if (X < bottop && X > botbot)
{
Serial.println(".");
}
}
}
}
}