A few errors which I don't understand.

I'm having some compile-problems with my program for the chipKIT MAX32. I'm using the mpide compiler.

First of all, the errors lines , as stated below, I'm getting don't give the right line numbers, to my knowledge.
But nonetheless I can suppose wich lines are meant by the errors.

Second, I do'nt understand why these kind of errors where given.

Can somebody help me out?

PS: the line numbers start with the first bar of code.

Thanks in advance.

sketch_oct27b.cpp:53:15: error: expected unqualified-id before numeric constant
sketch_oct27b.cpp:53:15: error: expected ')' before numeric constant
sketch_oct27b.cpp: In function 'void setup()':
sketch_oct27b.cpp:71:3: error: 'lcd' was not declared in this scope
sketch_oct27b.cpp: In function 'void loop()':
sketch_oct27b.cpp:120:27: error: lvalue required as left operand of assignment
sketch_oct27b.cpp:121:28: error: lvalue required as left operand of assignment

#include <LiquidCrystal.h>


const int  vtnr1 = 1;                      
const int  vtnr2 = 2;                      
const int  vtnr3 = 4;                     
const int  vtnr4 = 8;                      
const int  vtnr5 = 16;                     

const int  vnr1  = 1+32;                   
const int  vnr2  = 2+32;                  
const int  vnr3  = 4+32;                   
const int  vnr4  = 8+32;                   
const int  vnr5  = 16+32;

int vtnr1Toestand = 0;                     
int vtnr2Toestand = 0;                    
int vtnr3Toestand = 0;
int vtnr4Toestand = 0;
int vtnr5Toestand = 0;

int vnr1Toestand = 0;
int vnr2Toestand = 0;
int vnr3Toestand = 0;
int vnr4Toestand = 0;
int vnr5Toestand = 0;

byte hkvtnrToestand = B00000000;   
byte hkvnrToestand = B00100000;                     

int ahkvnrToestand;                                                                                    
int ahkvtnrToestand;                                              



const int vtnr1Pin = 40;
const int vtnr2Pin = 41;
const int vtnr3Pin = 42;
const int vtnr4Pin = 43;
const int vtnr5Pin = 44;

const int vnr1Pin = 45;
const int vnr2Pin = 46;
const int vnr3Pin = 47;
const int vnr4Pin = 48;
const int vnr5Pin = 49;

const int ledpin1 = 13;

LiquidCrystal(12, 11, 10, 9, 8, 7, 6);

void setup()                              
{
  pinMode(vtnr1Pin, INPUT);
  pinMode(vtnr2Pin, INPUT);
  pinMode(vtnr3Pin, INPUT);
  pinMode(vtnr4Pin, INPUT);
  pinMode(vtnr5Pin, INPUT);
  
  pinMode(vnr1Pin, INPUT);
  pinMode(vnr2Pin, INPUT);
  pinMode(vnr3Pin, INPUT);
  pinMode(vnr4Pin, INPUT);
  pinMode(vnr5Pin, INPUT);
  
  pinMode(ledpin1, OUTPUT);
  
  lcd.begin(16,2);
}
void loop()                               
                                          
{
 
vtnr1Toestand = digitalRead(vtnr1Pin);    
if(vtnr1Toestand == HIGH){                
bitWrite(hkvtnrToestand, 0, 1);           
}                                         
vtnr2Toestand = digitalRead(vtnr2Pin);   
if(vtnr1Toestand == HIGH){
bitWrite(hkvtnrToestand, 1, 1);
}
vtnr3Toestand = digitalRead(vtnr3Pin);
if(vtnr1Toestand == HIGH){
bitWrite(hkvtnrToestand, 2, 1);
}
vtnr4Toestand = digitalRead(vtnr4Pin);
if(vtnr1Toestand == HIGH){
bitWrite(hkvtnrToestand, 3, 1);
}
vtnr5Toestand = digitalRead(vtnr5Pin);
if(vtnr1Toestand == HIGH){
bitWrite(hkvtnrToestand, 4, 1);
}


vnr1Toestand = digitalRead(vnr1Pin);
if(vnr1Toestand == HIGH){
bitWrite(hkvnrToestand, 0, 1);
}
vnr2Toestand = digitalRead(vnr2Pin);
if(vnr2Toestand == HIGH){
bitWrite(hkvnrToestand, 1, 1);
}
vnr3Toestand = digitalRead(vnr3Pin);
if(vnr3Toestand == HIGH){
bitWrite(hkvnrToestand, 2, 1);
}
vnr4Toestand = digitalRead(vnr4Pin);
if(vnr4Toestand == HIGH){
bitWrite(hkvnrToestand, 3, 1);
}
vnr5Toestand = digitalRead(vnr5Pin);
if(vnr5Toestand == HIGH){
bitWrite(hkvnrToestand, 4, 1);
}

int(hkvnrToestand) + 15 = ahkvnrToestand;                    
int(hkvtnrToestand) + 96 = ahkvtnrToestand;         


int(hkvtnrToestand) = 0;                               
int(hkvnrToestand) = 0;                               
 
}

Mod edit; Code put into code box. AWOL

You haven't declared anything called lcd

Of course, how stupid of me! But the real errors that are bothering me are:

sketch_oct27b.cpp:53:15: error: expected unqualified-id before numeric constant
sketch_oct27b.cpp:53:15: error: expected ')' before numeric constant
sketch_oct27b.cpp: In function 'void loop()':
sketch_oct27b.cpp:120:27: error: lvalue required as left operand of assignment
sketch_oct27b.cpp:121:28: error: lvalue required as left operand of assignment

Thanks for the previous reply AWOL.

int(hkvnrToestand) + 15 = ahkvnrToestand;

Don't know what you're trying to do here, but the compiler highlighted it quite clearly.
How can you assign anything to the constant 15?

I've got it down to two errors now:
sketch_oct27b.cpp: In function 'void loop()':
sketch_oct27b.cpp:125:26: error: lvalue required as left operand of assignment
sketch_oct27b.cpp:126:27: error: lvalue required as left operand of assignment

What I'm trying to do: making a new variable (=ahkvnrToestand) that is increased by 15 as suppose to int(hkvnrToestand).
So just creating a new variable that has a new value.

LiquidCrystal(12, 11, 10, 9, 8, 7, 6);

This is missing a variable name, presumably the lcd name that the compiler is saying that you are using but not defining.

Yes, I've already fixed that one by naming the variable lcd. But thanks anyway.
So with that having fixed I still have the two above posted errors.

Did you read reply #3?

An lvalue is something that can appear on the left of an = sign. 15 can not appear on the left of an equal sign.

What I'm trying to do: making a new variable (=ahkvnrToestand) that is increased by 15 as suppose to int(hkvnrToestand).

int ahkvnrToestand = hkvnrToestand + 15;

I got it fixed.
Thanks very much for the help.

Hey guys,

For starters, I appreciated the help that was given the last time. I now bumped in to another problem. I don't understand the error that was given: because the lines don't correspond corect with the actual error line. And thus I couldn't quite point out the error.

Could someone take a look at it?

Thanks in advance,

ATIP

Alternatieve_ti_project1_2.cpp: In function 'void loop()':
Alternatieve_ti_project1_2.cpp:286:6: error: expected primary-expression before ';' token

#include <LiquidCrystal.h>


const int  vtnr1 = 1;                      // vtnr(vingertopnummer+nummer)
const int  vtnr2 = 2;                      // De toegewezen waarde correspondeert
const int  vtnr3 = 4;                      // met zijn bit-waarde. De eerste vinger
const int  vtnr4 = 8;                      // heeft, mits aan, de waarde 2 tot de
const int  vtnr5 = 16;                     // 0de en de vijfde vinger 2 tot de 4de. 

const int  vnr1  = 1+32;                   // vnr(vingerkokkelnummer+nummer)
const int  vnr2  = 2+32;                   // De "+32" slaat op de (theoretisch) 
const int  vnr3  = 4+32;                   // ingeschakelde zesde bit. Om alle 
const int  vnr4  = 8+32;                   // knokkelaanslagen goed te registreren.
const int  vnr5  = 16+32;

int vtnr1Toestand = 0;                     // Toestand: ingedrukt(hoog signaal), dan 
int vtnr2Toestand = 0;                     // wel oningdrukt/onaangeslagen(laag signaal).
int vtnr3Toestand = 0;
int vtnr4Toestand = 0;
int vtnr5Toestand = 0;

int vnr1Toestand = 0;
int vnr2Toestand = 0;
int vnr3Toestand = 0;
int vnr4Toestand = 0;
int vnr5Toestand = 0;

byte hkvtnrToestand = B00000000;                     // De huidige karakter-toestand.
                                           // I.e. de huidige decimale
                                           // representatie van de huidige
                                           // karakter.
                                           // Betreffende de vingertoppen

byte hkvnrToestand = B00100000;                     // Idem als hierboven.
                                           // Betreffende de vingerknokkels   
                                                      // De zesde bit in B00100000   
                                                      // = "+32" is om de
                                                      // zesde bit kunstmatig
                                                      // aan te zetten. Zo is
                                                      // ter herkennen dat het
                                                      // om een vingerknokkel-
                                                      // operatie gaat. 

int ahkvnrToestand;                              // (= ASCII-hkvnrToestand)                                                      
int ahkvtnrToestand;                             //  Idem.                   

char lk;                                           // (= letter-karakter)
char ck;                                           // (= cijfer-karakter)


const int vtnr1Pin = 40;
const int vtnr2Pin = 41;
const int vtnr3Pin = 42;
const int vtnr4Pin = 43;
const int vtnr5Pin = 44;

const int vnr1Pin = 45;
const int vnr2Pin = 46;
const int vnr3Pin = 47;
const int vnr4Pin = 48;
const int vnr5Pin = 49;

const int ledpin1 = 13;

LiquidCrystal lcd(12, 11, 10, 9, 8, 7, 6);

void setup()                              // (Nog in ontwikkeling)
{
  pinMode(vtnr1Pin, INPUT);
  pinMode(vtnr2Pin, INPUT);
  pinMode(vtnr3Pin, INPUT);
  pinMode(vtnr4Pin, INPUT);
  pinMode(vtnr5Pin, INPUT);
  
  pinMode(vnr1Pin, INPUT);
  pinMode(vnr2Pin, INPUT);
  pinMode(vnr3Pin, INPUT);
  pinMode(vnr4Pin, INPUT);
  pinMode(vnr5Pin, INPUT);
  
  pinMode(ledpin1, OUTPUT);
  
  lcd.begin(16,2);
  lcd.autoscroll();
 
}
void loop()                               // ( de functies zijn nog
                                          // in aanmaak)
{
  begin:

int v;
if(hkvnrToestand != B00100000)
{v = 1;}
if(hkvtnrToestand != B00000000)
{v = ;}

switch(v)
{
case 1:

vtnr1Toestand = digitalRead(vtnr1Pin);    // Deze functie is gedefinieerd
if(vtnr1Toestand == HIGH){                // als bitWrite(x, n, p);
bitWrite(hkvtnrToestand, 0, 1);           // x = "variabele", n = "bitnummer"
}                                         // begonnen bij de meest rechtse bit.
else {bitWrite(hkvtnrToestand, 0, 0);}    // p = "0" of "1" : ofwel uit of aan.

vtnr2Toestand = digitalRead(vtnr2Pin);    
if(vtnr1Toestand == HIGH){
bitWrite(hkvtnrToestand, 1, 1);
}
else {bitWrite(hkvtnrToestand, 1, 0);}

vtnr3Toestand = digitalRead(vtnr3Pin);
if(vtnr1Toestand == HIGH){
bitWrite(hkvtnrToestand, 2, 1);
}
else {bitWrite(hkvtnrToestand, 2, 0);}

vtnr4Toestand = digitalRead(vtnr4Pin);
if(vtnr1Toestand == HIGH){
bitWrite(hkvtnrToestand, 3, 1);
}
else {bitWrite(hkvtnrToestand, 4, 0);}

vtnr5Toestand = digitalRead(vtnr5Pin);
if(vtnr1Toestand == HIGH){
bitWrite(hkvtnrToestand, 4, 1);
}
else {bitWrite(hkvtnrToestand, 5, 0);}
break;

case 2:

vnr1Toestand = digitalRead(vnr1Pin);
if(vnr1Toestand == HIGH){
bitWrite(hkvnrToestand, 0, 1);
}
else {bitWrite(hkvtnrToestand, 0, 0);}

vnr2Toestand = digitalRead(vnr2Pin);
if(vnr2Toestand == HIGH){
bitWrite(hkvnrToestand, 1, 1);
}
else {bitWrite(hkvtnrToestand, 1, 0);}

vnr3Toestand = digitalRead(vnr3Pin);
if(vnr3Toestand == HIGH){
bitWrite(hkvnrToestand, 2, 1);
}
else {bitWrite(hkvtnrToestand, 2, 0);}

vnr4Toestand = digitalRead(vnr4Pin);
if(vnr4Toestand == HIGH){
bitWrite(hkvnrToestand, 3, 1);
}
else {bitWrite(hkvtnrToestand, 3, 0);}

vnr5Toestand = digitalRead(vnr5Pin);
if(vnr5Toestand == HIGH){
bitWrite(hkvnrToestand, 4, 1);
}
else {bitWrite(hkvtnrToestand, 4, 0);}
break;
}
  
int ahkvnrToestand = int(hkvnrToestand) + 15;                  
int ahkvtnrToestand = int(hkvtnrToestand) + 96;     

char lk = char(ahkvnrToestand);                             // (= letter-karakter)
char ck = char(ahkvtnrToestand);                            // (= cijfer-karakter)

if(ahkvnrToestand == 47){
goto begin;
}
if (ahkvtnrToestand == 96) {
goto begin;
}


lcd.print(lk);
lcd.print(ck);



int(hkvtnrToestand) = 0;                               // Oftewel: volgende
int(hkvnrToestand) = 0;                                // karakter.

}
{v = ;}

V equals what?

int(hkvtnrToestand) = 0;                               // Oftewel: volgende
int(hkvnrToestand) = 0;                                // karakter.

You were told before that this wouldn't work. Why aren't you listening?

Your gotos are completely unnecessary. Get rid of them. A simple change in the program logic will cause the rest of the code in loop to be skipped, accomplishing the same goal of going back to the start of loop.

Thanks PaulS. I got it fixed.
But why can't

int(hkvtnrToestand) = 0;                               // Oftewel: volgende
int(hkvnrToestand) = 0;                                // karakter.

work?(This wasn't told before. Before, I was told that int x + 3 = int y; couldn't work.(I now know why.))

But why can't
i

nt(hkvtnrToestand) = 0;                               // Oftewel: volgende

int(hkvnrToestand) = 0;                                // karakter.



work?

What does int() do? You can't assign a value to a function call. You really need to understand lvalues and rvalues.

Int(..) plays the role of converting byte hkvtnrToestand = B00000000; and byte hkvnrToestand = B00100000; to an int-value.
These are one of the very first declared variabales.

If you want to have them be ints, declare them as ints at the start rather than bytes.

For the incorrect line numbers, that is because the arduino language adds some stuff to the beginning before it ships it off to gcc (the compiler). Usually it manages to get the line numbers correct (I have no idea how), but if it says the error is in *.cpp, it'll get them wrong.

If you press shift while compiling (not uploading), you can see where it puts the files. If you go there and open up .cpp, you can see what it does. You could also use a "#line 10" (replacing 10 with the real line number) at about the beginning of setup() (that's where it adds the extra lines). Play around with it if you care.

Int(..) plays the role of converting byte...

Yes, it does. This means that int() has an input (the value in the parentheses) and an output, which you discard. It also means that it is an rvalue (can only appear on the right side of an equals sign), so you can not use at as an lvalue (something that can appear on the left of an equals sign).

Okay,

I'll look in to your advise WizenedEE. It seems very helpful.
And PaulS, I understand what you are saying now. Sometimes I don't (completely) get it the first time.

Thanks so far,

ATIP