This is how I converted a number to an ASCII code. 0 though 9 in hex code is 0x30-0x39. 6 would be 0x36.
unsigned int temp = 6;
or you can use unsigned char temp = 6;
unsigned char num;
num = 0x30| temp;
this will give you the ASCII value for 6. You do the same for 0 - 9
to convert ASCII to a numeric value I came up with this code.
unsigned char num,code;
code = 0x39; // ASCII Code for 9 in Hex
num = 0&0F & code;