Hi,
Could some one help me with correct syntax for this. I am sure there are better ways to do this but I am just looking to look up a single Char in a list of them.
I started by declaring all it as Char* and this works, but I wanted to try it via strings
but then i get this error message
" In function 'void getmorse(String)':
76:42: error: cannot convert 'String' to 'const char*' for argument '1' to 'int strcmp(const char*, const char*)'"
Code below.
Thank you.
void setup()
{
Serial.begin(9600);
pinMode(13, OUTPUT);
}
//define the structure of the mapping between letters and morse
typedef struct
{
String letter;
int code;
}morse;
// Populate morse array that we can use as a look up.
morse Temp[40] = {
{"a", 01},
{"b", 1000},
{"c", 1010},
{"d", 100},
{"e", 0},
{"f", 0010},
{"g", 110},
{"h", 0000},
{"i", 00},
{"j", 0111},
{"k", 101},
{"l", 0100},
{"m", 11},
{"n", 10},
{"o", 111},
{"p", 0110},
{"q", 1101},
{"r", 010},
{"s", 000},
{"t", 1},
{"u", 001},
{"v", 0001},
{"w", 011},
{"x", 1001},
{"y", 1011},
{"z", 1100},
{"1", 01111},
{"2", 00111},
{"3", 00011},
{"4", 00001},
{"5", 00000},
{"6", 10000},
{"7", 11000},
{"8", 11100},
{"9", 11110},
{"10", 11111}
};
void loop()
{
getmorse ("b");
}
void getmorse(String let)
{
//char* let;
int i;
let.toLowerCase();
//let = "c";
while(let)
{
for(i=0; i<40; ++i)
{
if (!strcmp(let, Temp*.letter))*
- {*
_ Serial.println(Temp*.code);_
_ }_
_ }_
_ let = strtok(NULL, " ");_
_ }*_
delay(1000);
}