arduino-uno


Code is showing multiple object declaration error during multiple file compilation


I want to call functions of LiquidCrystal class from showMenu() which is defined in menu.cc file and all the objects of the classes are defined in myLCD.h and myKey.h header files respectively. When compiling the file, I am getting multiple definition of the lcd object error. I have kept all the files in same folder. I have posted the code. Kindly help me to call the functions of LiquidCrystal class, from showMenu().
thanks
/*Key pad interfacing using 4x3 keypad*/
#include"menu.h"
#include"myKey.h"
#include"myLCD.h"
void setup() {
// put your setup code here, to run once:
/* Keypad Initialization*/
//defining pin type and pin modes
pinMode(A0,OUTPUT);
pinMode(A1,OUTPUT);
pinMode(A2,OUTPUT);
pinMode(A3,OUTPUT);
pinMode(A4,OUTPUT);
pinMode(A5,OUTPUT);
pinMode(6,OUTPUT);
digitalWrite(A0,HIGH);
digitalWrite(A1,HIGH);
digitalWrite(A2,HIGH);
digitalWrite(A3,HIGH);
digitalWrite(A4,HIGH);
digitalWrite(A5,HIGH);
digitalWrite(6,HIGH);
//=========================
// defining command key pad
pinMode(10,OUTPUT);
pinMode(9,OUTPUT);
pinMode(8,OUTPUT);
pinMode(7,OUTPUT);
digitalWrite(10,HIGH);
digitalWrite(9,HIGH);
digitalWrite(8,HIGH);
digitalWrite(7,HIGH);
/* LCD configuration*/
lcd.begin(16,2); // 16 x 2 LCD
lcd.setCursor(1,0); // Set cursor to row 0 and column 1
Serial.begin(9600);
lcd.print("WelCome..Press *");
lcd.setCursor(0,1);
lcd.print("to enter menu..");
}
void loop() {
// put your main code here, to run repeatedly:
char key=kpd.getKey(); // getkey function will get the key pressed
if(key=='*')
{
lcd.setCursor(0,1); // set cursor to column 0 row 1
//lcd.print(key);
showMenu();
}
}
Here is menu.cpp code
#include"menu.h"
#include"myLCD.h"
void showMenu(void)
{
lcd.setCursor(0,0);
lcd.print("Press 0 to exit menu");
}
menu.h code
// List of functions
void showMenu(void);
myKey.h code
#include <Key.h>
#include <Keypad.h>
const byte ROWS = 4; // Defining Number of Rows
const byte COLS = 3; // Defining Number of Columns
const byte CROWS = 2; // Command key row
const byte CCOLS = 2; // Command key columns
// Defining KeyMap
char keys[ROWS][COLS] =
{ {'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'*','0','#'}
};
char ckeys[CROWS][CCOLS] =
{
{'U','D'},
{'G','B'}};
byte crowPins[CROWS]={10,9};
byte ccolPins[CCOLS]={8,7};
byte rowPins[ROWS] = {A0,A1,A2,A3}; // Row pins connected to arduino
byte colPins[COLS] = {A4,A5,6}; // Column pins connected to arduino
Keypad kpd=Keypad(makeKeymap(keys),rowPins,colPins,ROWS,COLS); //Keypad function is mapped to kpd object which is a keypad class object
Keypad ckpd=Keypad(makeKeymap(ckeys),crowPins,ccolPins,CROWS,CCOLS); // command keypad function to map ckpd object
myLCD.h code
#include<LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // LCD pin configuration

Related Links

Programming attiny45 chip and ir remote library
Arduino Uno: Running multiple servos
MPU 6050 SD Writing Frequency Arduino is not constant , how to have a constant writing frequency?
MPU 6050 giving values -1
P10 with Arduino, display negative/all pixels on
Arduino-uno project [closed]
Arduino digitalWrite not working in else
Shift register 74ch595 and Arduino
how to connect arduino ethernet to internet using my laptop's wifi connection
Arduino and motors
Why “fifoBuffer” values of indexes 2,3,6,7,10,11 are not passed in the teapotPacket[] array ?
Sending data from coordinator XBee(API) to router XBee(AT)
how can i add a while statement to this code for my binary game on the arduino uno
Arduino Programming in C: Why output is not the way it supposed to be?
Arduino serial port+delete key+string convert
how to connect wires of step motor 42BYGH403 to driver drv8825 pins

Categories

HOME
ibm-bluemix
date
proxy
server
vmware
octobercms
android-4.4-kitkat
setup-deployment
programming-languages
angular-ui-bootstrap
alpha
multiple-records
autotools
amazon-cloudformation
awesome-wm
etl
fallback
caml
netflix
uitypeeditor
clojurescript
abi
jquery-ajaxq
orleans
core-text
devops
angular2-aot
entitlements
fluentvalidation
gsoap
titanium-mobile
http-get
webtest
phpfreechat
repo
jmonkeyengine
xcode-extension
retina-display
starteam
squib
nxlog
unixodbc
angular2-meteor
datastax-startup
namecoin
gcsfuse
titanium-android
google-feed-api
url-masking
database-optimization
disque
captivenetwork
pagerank
independentsoft
spidermonkey
embedded-code
deis
apache-commons-fileupload
remobjects
pretty-print
streambase
gadt
asp.net-dynamic-data
javafx-webengine
client-side-templating
rdl
eclipse-memory-analyzer
django-nonrel
sharp-repository
robotics-studio
ticoredatasync
netbeans-6.9
pydot
vdsp
imac
digest-authentication
gin
virtual-functions
simpletest
ntvdm.exe

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App