Hi arduino lovers.
Im trying to get my project to write out some things on the LCD.
If i dont use the bits with lcd.lcdWrite("…"); the code runs fine and works on the serial monitor.
But when i try to write it out on the display the troubles start.
The code:
#include <LCD16x2.h>
#include <Wire.h>
LCD16x2 lcd;
int buttons;
const int OUTPIN1 = 5; // Gas inlet
const int OUTPIN2 = 4; // Gas outlet
const int OUTPIN3 = 3; // Liquid inlet
double AMOUNT;
volatile unsigned long isrCounter;
unsigned long pulseCount;
unsigned long stopCount = 1400;
void setup() {
Serial.begin(9600);
Wire.begin();
attachInterrupt(0, countP, RISING);
lcd.lcdClear();
// initialize Outpins as output:
pinMode(OUTPIN1, OUTPUT);
pinMode(OUTPIN2, OUTPUT);
pinMode(OUTPIN3, OUTPUT);
}
void loop() {
buttons = lcd.readButtons();
if(buttons & 0x01)
{
// turn LED on:
digitalWrite(OUTPIN1, HIGH); //Opens gas inlet
delay(2000);
digitalWrite(OUTPIN1, LOW); //Closes gas inlet
delay(1000);
digitalWrite (OUTPIN2, HIGH); //Opens gas outlet
delay(2000);
digitalWrite (OUTPIN2, LOW); //Closes gas outlet
delay(1000);
digitalWrite(OUTPIN1, HIGH); //Opens gas inlet
delay(2000);
digitalWrite(OUTPIN1, LOW); //Closes gas outlet
delay(1000);
digitalWrite(OUTPIN3, HIGH); //Opens liquid inlet.
Serial.print("Volym :");
Serial.print(AMOUNT);
Serial.println("ml");
lcd.lcdGoToXY(2,1);
lcd.lcdWrite("Volym");
lcd.lcdGoToXY(9,1);
lcd.lcdWrite(AMOUNT);
lcd.lcdGoToXY(12,1);
lcd.lcdWrite("ml");
noInterrupts();
long pulseCount = isrCounter;
interrupts();
if (pulseCount > stopCount)
digitalWrite(OUTPIN3, LOW); // Closes liquid outlet
while(true) {} // endless loop here to stop program
AMOUNT = (pulseCount * 2.25);
} else {
//Sets all outpins as LOW
digitalWrite(OUTPIN1, LOW);
digitalWrite(OUTPIN2, LOW);
digitalWrite(OUTPIN3, LOW);
}
}
void countP()
{
isrCounter++;
}
The error :
C:\Users\Marcus\Documents\Arduino\sketch_jul17a\sketch_jul17a.ino: In function 'void loop()':
C:\Users\Marcus\Documents\Arduino\sketch_jul17a\sketch_jul17a.ino:61:21: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
lcd.lcdWrite("Volym");
^
sketch_jul17a:63: error: no matching function for call to 'LCD16x2::lcdWrite(double&)'
lcd.lcdWrite(AMOUNT);
^
C:\Users\Marcus\Documents\Arduino\sketch_jul17a\sketch_jul17a.ino:63:20: note: candidate is:
In file included from C:\Users\Marcus\Documents\Arduino\sketch_jul17a\sketch_jul17a.ino:1:0:
C:\Users\Marcus\Documents\Arduino\libraries\LCD16x2/LCD16x2.h:46:14: note: void LCD16x2::lcdWrite(char*)
void lcdWrite(char *string);
^
C:\Users\Marcus\Documents\Arduino\libraries\LCD16x2/LCD16x2.h:46:14: note: no known conversion for argument 1 from 'double' to 'char*'
C:\Users\Marcus\Documents\Arduino\sketch_jul17a\sketch_jul17a.ino:65:18: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
lcd.lcdWrite("ml");
^
exit status 1
no matching function for call to 'LCD16x2::lcdWrite(double&)'
If i comment away the part where i try to print out AMOUNT i get this kin of error instead:
C:\Users\Marcus\Documents\Arduino\sketch_jul17a\sketch_jul17a.ino: In function 'void loop()':
C:\Users\Marcus\Documents\Arduino\sketch_jul17a\sketch_jul17a.ino:61:21: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
lcd.lcdWrite("Volym");
^
C:\Users\Marcus\Documents\Arduino\sketch_jul17a\sketch_jul17a.ino:65:18: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
lcd.lcdWrite("ml");
^
Sketch uses 6 968 bytes (21%) of program storage space. Maximum is 32 256 bytes.
Global variables use 444 bytes (21%) of dynamic memory, leaving 1 604 bytes for local variables. Maximum is 2 048 bytes.
I would love to get some help on thin, because I cant figure out how to solve this.
Also I´m new to C so i it gets kinda hard trouble shooting.
The bits with lcd.lcdWrite("…"); i got from the example code that the supplier of the Olimexino shield handed out to its customers.
Kind reegards