[SOLVED] Invalid Header Error on Tinkercad

I'm aware of this topic relating the same error, but it does not gave me any solution. I have no idea why this is happening and at the moment I can't test on an Arduino.

Here is the code

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Keypad.h>

LiquidCrystal_I2C lcd(0x27, 16, 2);

const byte ROWS = 4;
const byte COLS = 4;

char hexaKeys[ROWS][COLS] = {
  {'1', '2', '3', 'A'},
  {'4', '5', '6', 'B'},
  {'7', '8', '9', 'C'},
  {'*', '0', '#', 'D'}
};

byte rowPins[ROWS] = {9, 8, 7, 6};
byte colPins[COLS] = {5, 4, 3, 2};

Keypad customKeypad = Keypad(makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);

char select;
int valornum;
unsigned long valor[100];
unsigned long soma;
int result;

void setup() {
  Serial.begin(9600);
  lcd.init();
  lcd.backlight();
  lcd.clear();

  valornum = 0;
  result = 0;
  soma = 0;
}

void loop() {
  char keyP = customKeypad.getKey();

  if (keyP != 'A' && keyP != 'B' && keyP != 'C' && keyP != 'D') {
    lcd.setCursor(0, 0);
    lcd.print("A, B, C ou D: ");
  }

  if (keyP == 'A') {
    select = 'a';
    lcd.clear();
  }

  if (keyP == 'B') {
    select = 'b';
    lcd.clear();
  }

  if (keyP == 'C') {
    select = 'c';
    lcd.clear();
  }

  if (keyP == 'D') {
    select = 'd';
    lcd.clear();
  }

  if (keyP == '#') {
    result = 1;
  }

  switch (select) {
    case 'a':
      if (result != 1) {
        lcd.setCursor(0, 0);
        lcd.print("Valor ");
        lcd.print(valornum);
        lcd.print(":");
      }

      if (keyP != 'A' && keyP != 'B' && keyP != 'C' && keyP != 'D' && keyP != '*' && keyP != '#') {
        valor[valornum] += valornum * 10 + (keyP - '0');
      } else if (keyP == '*') {
        valornum++;
        lcd.clear();
      }

      if (result == 1) {
        for (int i = 0; i < valornum; i++) {
          soma += valor[i];
        }

        lcd.clear();
        lcd.setCursor(0, 0);
        lcd.print(valor);
      }

      break;
  }
}

sometimes i mix languages when coding so you can transate valor to value and soma to sum

Please post the full error message

image

Not very informative

I am not familiar with TinkerCAD. Does it use its own collection of libraries or do you provide them ?

What happens if you try to compile a sketch with only setup(), loop() and the library #includes in it ?

Can you show us the file name

It worked fine until some point on the code, Idk why and it's very weird. Tinkercad do have its own collection of libraries due to it being a online app. It's basically a simpler version of Wowkwi, which seems to run most projects perfectly.

I checked for all possible errors and even tried using ChatGPT for it cuz it does recognize arduino code but didn't work, which I think it's an issue from Tinkercad.

this isn't an error with you're code at least I don't think because I'm pretty sure most coding applications would tell you the line and specific parameter that you have over used in the error but it has not so I think that it's an error with the .ino file or .h file so if you could show me all the sketches that are useed in this code that would be helpful

an also by the way welcome @icaro1447

Well I don't actually have access to any file in Tinkercad, only the boards, sensors and modules. If I download the code from the project page it just gives me a .ino file which does not come with a header file. The only thing I could do is running a remade project in Wowkwi which gives an error output (same code):

sketch.ino: In function 'void loop()':
sketch.ino:98:24: error: no matching function for call to 'print(long unsigned int [100])'
         lcd.print(valor);
                        ^
In file included from /arduino/hardware/avr/1.8.6/cores/arduino/Stream.h:26:0,
                 from /arduino/hardware/avr/1.8.6/cores/arduino/HardwareSerial.h:29,
                 from /arduino/hardware/avr/1.8.6/cores/arduino/Arduino.h:233,
                 from sketch.ino.cpp:1:
/arduino/hardware/avr/1.8.6/cores/arduino/Print.h:68:12: note: candidate: size_t Print::print(char) <near match>
     size_t print(char);
            ^~~~~
/arduino/hardware/avr/1.8.6/cores/arduino/Print.h:68:12: note:   conversion of argument 1 would be ill-formed:
/arduino/hardware/avr/1.8.6/cores/arduino/Print.h:69:12: note: candidate: size_t Print::print(unsigned char, int) <near match>
     size_t print(unsigned char, int = DEC);
            ^~~~~
/arduino/hardware/avr/1.8.6/cores/arduino/Print.h:69:12: note:   conversion of argument 1 would be ill-formed:
/arduino/hardware/avr/1.8.6/cores/arduino/Print.h:70:12: note: candidate: size_t Print::print(int, int) <near match>
     size_t print(int, int = DEC);
            ^~~~~
/arduino/hardware/avr/1.8.6/cores/arduino/Print.h:70:12: note:   conversion of argument 1 would be ill-formed:
/arduino/hardware/avr/1.8.6/cores/arduino/Print.h:71:12: note: candidate: size_t Print::print(unsigned int, int) <near match>
     size_t print(unsigned int, int = DEC);
            ^~~~~
/arduino/hardware/avr/1.8.6/cores/arduino/Print.h:71:12: note:   conversion of argument 1 would be ill-formed:
/arduino/hardware/avr/1.8.6/cores/arduino/Print.h:72:12: note: candidate: size_t Print::print(long int, int) <near match>
     size_t print(long, int = DEC);
            ^~~~~
/arduino/hardware/avr/1.8.6/cores/arduino/Print.h:72:12: note:   conversion of argument 1 would be ill-formed:
/arduino/hardware/avr/1.8.6/cores/arduino/Print.h:73:12: note: candidate: size_t Print::print(long unsigned int, int) <near match>
     size_t print(unsigned long, int = DEC);
            ^~~~~
/arduino/hardware/avr/1.8.6/cores/arduino/Print.h:73:12: note:   conversion of argument 1 would be ill-formed:

Error during build: exit status 1
lcd.print(valor);

valor is an array so you can't print it like that

What exactly are you trying to print ?

oh ok got it, thanks.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.