I am breaking a project into separate files and I am filing a declaration problem. In the main ino file I declare:
LiquidCrystal lcd(12, 11, 7, 6, 5, 4);
But, in other .cpp files I get
/tmp/arduino_build_455622/sketch/writeTemp.cpp: In function 'void writeTemp(int, byte)':
writeTemp.cpp:11: error: 'lcd' was not declared in this scope
lcd.setCursor(col, 1);
^
extern declaration does not work.
How do I get the lcd object into writeTemp.cpp scope.
#include <LiquidCrystal.h>
#include "somefile.h"
// define a sensible name for when the relay is active
// for most relayboards, writing LOW means that that the relay is activated and writing HIGH means that the relay iss de-activated
#define RELAY_ACTIVE LOW
// lcd pinout
const uint8_t rs = 12;
const uint8_t enable = 11;
const uint8_t d0 = 7;
const uint8_t d1 = 6;
const uint8_t d2 = 5;
const uint8_t d3 = 4;
// lcd number of rows and columns
const uint8_t numCols = 16;
const uint8_t numRows = 2;
// analog buttons
const uint8_t buttonPin = A0;
// relay
const uint8_t relayPin = 10;
// create a LiquidCrystal object
LiquidCrystal lcd(rs, enable, d0, d1, d2, d3);
void setup()
{
// to make sure that the relay will be off, we first make the pin HIGH
digitalWrite(relayPin, HIGH);
// and next switch the pin to output
pinMode(relayPin, OUTPUT);
lcd.begin(numCols, numRows);
lcd.setCursor(2,1);
printIt("Piotr's relay");
}
void loop()
{
}