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

How do I make two servo's move in opposite directions?
Sparkfun CAN BUS sheild with arduino UNO
Using Arduino and Motor Shield
AT+CSQ? returns error
Array accessing in arduino and for loop
Bluetooth module won't function when working with leapmotion
switch on or off the motor based on the reply of the user
IS my Modulo usage incorrect? What can
Use analog output as digital in relay pins
Arduino Uno and ESP8266-01
Power supply for raspberry and arduino
Arduino UNO and MPU 6050
Understanding timer choices/options
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?

Categories

HOME
reflection
plone
lodash
malloc
amazon-ecs
sqlite3
dxl
webpack-2
ravendb
mvvmcross
convolution
cross-validation
cloudkit
vifm
floating-action-button
postgres-xl
carthage
pc
sylius
claims-based-identity
emgucv
android-widget
fopen
gitignore
objectanimator
madlib
uisplitview
ioio
column-family
typed.js
windows-dev-center
uiswipegesturerecognizer
accelerate-framework
tasker
trim
eclipse-gef
cubic-spline
auto-update
pnotify
winscp-net
mu
hittest
azure-sdk
infix-notation
player
moveit
superstack
yaws
bluegiga
jms2
kcachegrind
emailrelay
ibaction
remobjects
e10s
directoryservices
javax.mail
modalpopup
camanjs
zend-route
uitouch
valueconverter
kgdb
bundles
datagridviewcolumn
floating-point-precision
oam
dotnetnuke-5
jplaton
buster.js
django-nonrel
clipper
referrer
path-separator
javaspaces
errai
dbproviderfactories
bigcouch
adk
fireworks
f#-powerpack
yetanotherforum
krl
remember-me
ncqrs
project-hosting
aquaticprime
caching-application-block

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App