I took this example (Arduino Playground - SparkFunSerLCD) and placed it inside my code (which really doesn't have anything in it except global variables), but it gives me the "error: expected constructor, destructor, or type conversion before '-' token" error on compile. I tried a few things with no luck, and if this is posted on the Playground I would think it should work, but maybe I've done something obvious that I missed.
I didn't include the setup{} because the only thing is the serial.begin, and some routines that don't yet function and don't reflect on the LCD issue.
void loop()
{
BtnDbnc = millis(); //reset button debounce timer
if ((millis() - BtnDbnc) > 100){ //digital debounce
// button debounce
}
selectLineOne();
Serial.print(analogRead(0)); // read scale and display
delay(50);
}
// ~~ LCD Display Commands ~~ \\
void selectLineOne(){ //puts the cursor at line 0 char 0.
Serial.print(0xFE, BYTE); //command flag
Serial.print(128, BYTE); //position
delay(10);
}
void selectLineTwo(){ //puts the cursor at line 0 char 0.
Serial.print(0xFE, BYTE); //command flag
Serial.print(192, BYTE); //position
delay(10);
}
void goTo(int position) { //position = line 1: 0-15, line 2: 16-31, 31+ defaults back to 0
if (position<16){ Serial.print(0xFE, BYTE); //command flag
Serial.print((position+128), BYTE); //position
}else if (position<32){Serial.print(0xFE, BYTE); //command flag
Serial.print((position+48+128), BYTE); //position
} else { goTo(0); }
delay(10);
}
void clearLCD(){
Serial.print(0xFE, BYTE); //command flag
Serial.print(0x01, BYTE); //clear command.
delay(10);
}
void backlightOn(){ //turns on the backlight
Serial.print(0x7C, BYTE); //command flag for backlight stuff
Serial.print(157, BYTE); //light level.
delay(10);
}
void backlightOff(){ //turns off the backlight
Serial.print(0x7C, BYTE); //command flag for backlight stuff
Serial.print(128, BYTE); //light level for off.
delay(10);
}
void serCommand(){ //a general function to call the command flag for issuing all other commands
Serial.print(0xFE, BYTE);
}