decimal variable to result ASCII char

Hi,

In the remainder of my keyboard tactil project, I try to return in a variable char or string a character ASCII table starting from its decimal value. The aim being to duminuer code size example:

char DecToASCII (int Val) { char CarASCII = // the code of transformation return CarASCII }

thank in advance

A good bit of thought with an ASCII table right in front of you should reveal what patterns are in the table itself. Forget explanations, just LOOK.

Be sure to find a simple one, 128 characters arranged as 16 x 16 and numbered in hexadecimal.

If you can’t figure it out from the table, and that includes rejecting ideas that’s there’s some overall organization that just spending more time doing nothing will reveal. What is there should be clear in minutes at most, memorizing key characters should take longer but really it’s pretty damned simple.

If you can’t figure that out then why bother coding? Honestly, I have trouble believing that you ever really looked at an ASCII table, as opposed to skimming to find certain codes.

char zeero = ‘0’; // zeero = 48

for ( byte i = 0; i < 10; i++ )
{
print( zeero + i );
}

If I understand the question, you could use your function approach, but it's not necessary. The following code example may help to illustrate:

void setup() {
  int val = 65;
  char ch;
  
  Serial.begin(115200);
  DecToASCII(65);
  
  Serial.println(DecToASCII(65));
  Serial.println( (char) val);           // A cast works
}

char DecToASCII(int num)
{
  return num;
}

void loop() {}

The cast works fine and avoids the overhead of a function call and saves memory, too.

Ok, So I rephrase my question by giving you details: - Accuracy 1 I can not and will not use the type "Serial.println (DecToASCII (65));" gold "print (Zeero + i);" because my need is for the LCD display LIBRARY TLU (C) 2014 Henning Karlsen. - Accuracy 2 The basic idea is to display the keys in the center caracter of the key and all in a loop incremented

Best Regards,

final use is for that http://forum.arduino.cc/index.php?topic=284936.0

So I rephrase my question by giving you details: - Accuracy 1

"Serial.println (DecToASCII (65));" gold

It looks like Google translate is struggling with French idioms.

Would it be easier for you to post your questions in the French section of the forum?

Sorry for next information, my usage is for LIBRARY UTFT (C) 2014 Henning Karlsen.

Thanks AWOL,

for your reflexion "with French idioms."

It's good constat.

Best regards,

It's good constat.

Oui, je le know it.

MDZT: Ok, So I rephrase my question by giving you details: - Accuracy 1 I can not and will not use the type "Serial.println (DecToASCII (65));" gold "print (Zeero + i);" because my need is for the LCD display LIBRARY TLU (C) 2014 Henning Karlsen. - Accuracy 2 The basic idea is to display the keys in the center caracter of the key and all in a loop incremented

Best Regards,

So you don't understand ASCII codes for computer text and you have no desire to study either. You just want to work an LCD library that uses ASCII text without knowing what it is.

Ok GoForSmoke, it's good, I understood so here is my code:

char DecToASCII (int Val, char StartASCII)
{
  char CarASCII = StartASCII + Val;
  return CarASCII;
}

So you don't understand ASCII codes for computer text and you have no desire to study either. You just want to work an LCD library that uses ASCII text without knowing what it is.

I'm generally not suseptible, but between AWOL and you that's a lot ... I recall you the goal of a forum, help others. On this point the best way to do this is to explain not criticize. Finally my problem is resolut, that was the goal thank you,

I sent you a link to the Francais section to help, I am sure that you will go there soon.

You do not need to translate number to ASCII. ASCII is numbers that get turned into text by code of the language or hardware you use.

I do not need to turn 65 into the letter 'A'. [u]'A' -is- 65.[/u] I can print A to Z on serial, LCD is the same except fewer, shorter lines.

char asciiCode; // char is unsigned 8-bit value. The name asciiCode could be x and work the same.

for ( asciiCode = 'A'; asciiCode >= 'Z'; asciiCode++ ) { print( asciiCode ); // Serial print or LCD print, make the code for your use. }

Good point, Actually to simplify code and your treatment method is actually more simple and logical. I had, as you told me looked too far. thank you again

  • Accuracy 1

Accuracy == précision == clarification

(In English, "precision" and "accuracy" are not the same thing)

I'm generally not suseptible

Susceptible == touchy

Spend a few years with a compiler and deadlines and those touchy edges should be worn right off.