can any one help me please
I have been trying to follow this project and it is working fine on the serial monitor however since I have tried to display on LCD 16 x 2
it just not showing nothing i dont know what i am doing wrong.
please the original code attached below.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
#include <LiquidCrystal.h> //Load Liquid Crystal Library
LiquidCrystal LCD(10, 9, 5, 4, 3, 2); //Create Liquid Crystal Object called LCD
#include <EEPROM.h>
#include <CapacitiveSensor.h>
CapacitiveSensor csSensor = CapacitiveSensor(4,2); // high (50M+) resistor between pins 7 and 8. Sensor attached to pin 8
//variables
long startTime;
word elapsedTime;
word elapsedTimeConstrained;
word CLSLevelRaw;
byte CLSLevelPercentage;
word CLSLevelDistancemm;
word CLSLevelDistancewritemm;
word CLSLowerLimit;
word CLSUpperLimit;
word CLSAveragelevel;
void setup()
{
csSensor.set_CS_Timeout_Millis(5000); //raise timeout to allow for a more accurate reading
Serial.begin(9600);
//fetch high, low and length from EEPROM
CLSLowerLimit = word(EEPROM.read(210), EEPROM.read(211));
CLSUpperLimit = word(EEPROM.read(4800), EEPROM.read(4801));
CLSLevelDistancemm = word(EEPROM.read(65), EEPROM.read(66));
//debug default values
CLSLowerLimit = 50;
CLSUpperLimit = 66;
CLSLevelDistancemm = 65;
CLSAveragelevel = 55;
LCD.begin(16,2); //Tell Arduino to start your 16 column 2 row LCD
LCD.setCursor(0,0); //Set LCD cursor to upper left corner, column 0, row 0
}
void loop()
{
{ long startTime = millis();
long total1 = csSensor.capacitiveSensor(30); //run 30 measure samples
elapsedTime = millis() - startTime; //see how much time has passed (the more time has passed, the higher the capacitance was.
//convert the read value from the array to the byte value, the distance and the capacitance
//check for values too high or low, make the value upper and lower limits if it exceeds the value
elapsedTimeConstrained = constrain(elapsedTime, CLSLowerLimit, CLSUpperLimit);
CLSLevelDistancewritemm = map(elapsedTimeConstrained, CLSLowerLimit, CLSUpperLimit, 0, CLSLevelDistancemm);
//for debug purposes when sensor is directly connected to serial monitor
//Serial.print(elapsedTime); // print the value to serial port
//Serial.print(" mS; "); // print units and carriage return
//Serial.print(" maximum oil level: ");
// print the value to serial port
// print units and carriage return
// Serial.println(total1);
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Serial.println(CLSLevelDistancewritemm);
LCD.clear();
LCD.setCursor(0,0);// write start from the top left
LCD.print("Oil level:");
LCD.print((Serial.println(CLSLevelDistancewritemm)));
delay(1000);
}
//LCD.println("max oil level: ");
//LCD.println("Min oil level: ");
if ((Serial.println(CLSLevelDistancewritemm)) >= CLSAveragelevel)
{
LCD.setCursor(0,1);// write start from in the bottom left
LCD.print("Maximum");
delay(1000);
}
else if ((Serial.println(CLSLevelDistancewritemm)) <= CLSAveragelevel)
{
LCD.setCursor(0,1);//write start from in the bottom left
LCD.print("Minimum");
delay(1000);
}
}
FQN5CICI14XPG2H (1).zip (2.44 KB)