system
June 13, 2012, 6:05pm
1
I am modifying a function that scrolls text on an LED Matrix. Originally it set the text to scroll inside the function, like so
void AlphabetSoup()
{
char msg[] = "THE OBLIGATORY ARDUINO LED MATRIX PROJECT ";
(code that scrolls msg)
}
I want to be able to call it like this
AlphabetSoup('text to display');
So how do you pass in an array of chars with no predefined number of chars in the array?
Any help is appreciated
ematson5897
system
June 13, 2012, 6:07pm
2
Well, for a start you surround it with "" not ''
And the parameter format is "char *"
void AlphabetSoup(char *msg)
{
(code that scrolls msg)
}
AlphabetSoup("THE OBLIGATORY ARDUINO LED MATRIX PROJECT ");
system
June 13, 2012, 6:13pm
3
Ok, I changed that and now this line in the scrolling code gives me an error
int alphabetIndex = msg[charIndex] - '@';
Error:
sketch_jun13a.cpp: In function 'void AlphabetSoup(char)':
sketch_jun13a:167: error: invalid types 'char[int]' for array subscript
system
June 13, 2012, 6:14pm
4
sketch_jun13a.cpp: In function 'void AlphabetSoup(char)':
You missed the * didn't you?
void AlphabetSoup(char __*__msg)
system
June 13, 2012, 6:19pm
5
Wow I could swear i put that there. Well it should work now. My dad does some programming in C and he told me the same thing except he also told me to define it globally too. So that didn't work