I'm trying to figure out how to send the ASCII value of a char to a function.
Basically I have a 2D array of the following structure:
asciitable[asciivalue][5x7ledbin]
void sendtodisplay(char character){
for(int i = 0; i<5; i++){
lc1.setRow(0,i,asciitable[character][i]);}}
I know I can declare
char whatever = 'a';
but how can I handle that more generally within functions.
Any good reference, I'm missing the keywords to do a relevant search in google. I feel like I'm struggling to handle the logic behind strings and char and numbers and how it's handled
DuzMontana:
Basically I have a 2D array of the following structure:
If you compare your original post with your actual code you'll understand why the Sticky posts in this section ask you to enclose your code in code tags. You can add them now by editing your first post, selecting your code and clicking the # button in the edit window.
DuzMontana:
Yes, the numerical value of a given character. Ex. 'A' = 65
I'm not sure I get what the following line does.
char c = Serial.read();
First read this...
Then read this...
how to send the ASCII value of a char to a function
.. is the same as
how to send a char to a function
If a char variable is used to represent a character, then it contains the ASCII code for that character. You don't need to do anything special to pass the ASCII code to a function, just pass the variable. It already contains the ASCII code.
int n = 1;
char m = 'a';
//array of binaries values for 5x7 display to send to MAX7219 ordered in increasing decimal ASCII value
long asciitable[asciivalue][5x7ledBin];
String character1 = String(n);
String character2 = String(m);
void sendtodisplay(int character){ //can I declare character as an int? I'll need an int in the array?
for(int i = 0; i<5; i++){
lc1.setRow(0,i,asciitable[character][i]);
}
}
void loop(){
sendtodisplay(character1);
delay(1000);
sendtodisplay(character2);
delay(1000);
}