Hello all,
I am trying to make a library for the DFRobot LCD shield. After reading the tutorial on the Arduino site I came up with this code:
/*
LCDShield.cpp
*/
#include "LCDShield.h"
LCDShield::LCDShield() : LiquidCrystal(8, 9, 4, 5, 6, 7){
; // nothing to construct
}
char LCDShield::button(){
uint16_t inputVal=analogRead(A0);
delay(2);
char c='0';
switch(inputVal){
case 1023:
c= -1;
break;
case 742:
case 741:
case 743:
c= 's';
break;
case 141:
case 142:
case 143:
c= 'u';
break;
case 328:
case 327:
case 326:
c= 'd';
break;
case 503:
case 504:
case 505:
c= 'l';
break;
case 0:
case 1:
c= 'r';
break;
default:
c= '0';
break;
}
return c;
}
/*
LCDShield.h
*/
#include "Arduino.h"
#include <LiquidCrystal.h>
#ifndef LCDShield_h
#define LCDShield_h
class LCDShield : public LiquidCrystal{
public:
LCDShield();
char button();
};
#endif
And a very quick program to test it:
#include <LCDShield.h>
LCDShield lcd();
void setup(){
Serial.begin(9600);
}
void loop(){
char input = lcd.button();
Serial.println(input);
delay(200);
}
But when I try to compile, this error came up:
In file included from test1.ino:1:
/Users/Pelle/Dropbox/Electronics/Microcontrollers/Arduino Projects/libraries/LCDShield/LCDShield.h:10: error: expected class-name before '{' token
test1.ino: In function 'void loop()':
test1:13: error: request for member 'button' in 'lcd', which is of non-class type 'LCDShield ()()'
I searched the web but never got a resounding solution for this problem. I guess it is something with me trying to include the liquid crystal class and something going wrong there. Or it is just a stupid beginners error
Can anyone lend me a hand with this issue?
Im using an Arduino Uno if it matters.
Thank you