expected unqualified-id before numeric constant error and I don't understand why

Hello!
I’m trying to make my program translate a string into a morse code and display it with the LED flashing. But whenever I try to play my code it gives me errors that I do not understand. Here’s the full code (sorry for it being messy xD):

int WhtLed1 = 13;
void setup()
{
  
  pinMode(WhtLed1, OUTPUT);
  
  // Nustatom šviesos diodus į LOW.
  digitalWrite(WhtLed1, LOW);

  //Nustatom morzes abecele
int charlist[] = {65, 66};
int 65[] = {1000, 3000};
int 66[] = {3000, 1000, 1000, 1000}
int wlet = -1;
int k = -1;
}
void loop()
{ 
char text = "AA"
text.toCharArray(letters[],length(text));
for (i = 0;i < length(text);i + 1) {
  int tcs = char letter[wlet+1]
  for (j = 0;j< charlist[currentcharlist];j + 1) {
    if (tcs == charlist[k+1]) {
      for (l = 0; l < sifeof(tcs[]); l + 1) {
        digitalWrite(WhtLed1, HIGH);
        int h = 0;
        delay(tsc[h+1]);
        digitalWrite(WhtLed1, LOW);
        delay(1000);
        
      }
      
    }
  }
  }
}

And here’s the error:

Arduino: 1.8.0 (Windows 10), Board: "Arduino/Genuino Uno"

C:\Users\Tech_Mokinys6\Desktop\Kristijono morzes kodo vertejas\morzes_kodo_vertejas\morzes_kodo_vertejas.ino: In function 'void setup()':

morzes_kodo_vertejas:12: error: expected unqualified-id before numeric constant

 int 65[] = {1000, 3000};

     ^

morzes_kodo_vertejas:13: error: expected unqualified-id before numeric constant

 int 66[] = {3000, 1000, 1000, 1000};

     ^

C:\Users\Tech_Mokinys6\Desktop\Kristijono morzes kodo vertejas\morzes_kodo_vertejas\morzes_kodo_vertejas.ino: In function 'void loop()':

C:\Users\Tech_Mokinys6\Desktop\Kristijono morzes kodo vertejas\morzes_kodo_vertejas\morzes_kodo_vertejas.ino:19:13: warning: invalid conversion from 'const char*' to 'char' [-fpermissive]

 char text = "AA"

             ^

morzes_kodo_vertejas:20: error: expected ',' or ';' before 'text'

 text.toCharArray(letters[],length(text));

 ^

morzes_kodo_vertejas:21: error: 'i' was not declared in this scope

 for (i = 0;i < length(text);i + 1) {

      ^

morzes_kodo_vertejas:21: error: 'length' was not declared in this scope

 for (i = 0;i < length(text);i + 1) {

                           ^

morzes_kodo_vertejas:22: error: expected primary-expression before 'char'

   int tcs = char letter[wlet+1]

             ^

morzes_kodo_vertejas:23: error: 'j' was not declared in this scope

   for (j = 0;j< charlist[currentcharlist];j + 1) {

              ^

morzes_kodo_vertejas:23: error: 'charlist' was not declared in this scope

   for (j = 0;j< charlist[currentcharlist];j + 1) {

                 ^

morzes_kodo_vertejas:23: error: 'currentcharlist' was not declared in this scope

   for (j = 0;j< charlist[currentcharlist];j + 1) {

                          ^

exit status 1
expected unqualified-id before numeric constant

Thanks! :3

int 65[] = {1000, 3000};

Variable names can not start with a number, and certainly can not consist of nothing but numbers.

A variable name CANNOT start with a number. Think about it, how would the compiler ever be able to tell if you were talking about the number 65 or the array 65?

Hmm.. Then do you have any idea how should I make the code work? This was the only way I figured. Unless I can make the arrays called by their letters and then take the array name and access it as a letter....

The morse code thing has been done so many times and so many ways. I’m certainly not going to rehash it all here. Go have a look at some of the examples around.

As the other guys pointed out array name cant start with a number.

I did a morse code a while ago so if you need ideas check it out.

https://github.com/Krsma/Morse-code-manual

Thanks for this one.

I got the same error when I used

int PIND2; instead of pinD2;

1 Like