Hey There, first thing I'd like to say is thank you to everyone who is willing to read/Help me out with this.
Anyways, I've been trying to make a "Smart garden" Cause i personally thought it would be really interesting doing this as my first project with arduino(Nano).
All the wiring is properly connected, and all sensors work as intended to do so. I've tested each sensors individually and thankfully , they all give accurate data results.
Now to get to the issue(s), i've been attempting to display all 3 sensor Data to my 2" IPS LCD Screen, but for the life of me, i cant figure out how to do it. I will post the code that im currently using to display(Test) Each sensor individually. i have fiddle farted with the code multiple times, and tried to come up with something that will make all 3 sensors show the data on the LCD Screen (Instead of One at a time), but i have had no luck. So now i am coming here to ask for guidance! ![]()
#include <TFT.h> // Arduino LCD library
#include <SPI.h>
// pin definition for the Uno
#define cs 10
#define dc 9
#define rst -1
#define LR A0 //Photo-Resistor Sensor
#define TE A1 //Temperature Sensor
#define MO A2 //Moisture Sensor
// create an instance of the library
TFT TFTscreen = TFT(cs, dc, rst);
// char array to print to the screen
char sensorPrintout[4];
void setup() {
// Put this line at the beginning of every sketch that uses the GLCD:
TFTscreen.begin();
// clear the screen with a black background
TFTscreen.background(0, 0, 0);
// write the static text to the screen
// set the font color to white
TFTscreen.stroke(255, 255, 255);
// set the font size
TFTscreen.setTextSize(2);
// write the text to the top left corner of the screen
TFTscreen.text("Sensor Value :\n ", 0, 0);
// ste the font size very large for the loop
TFTscreen.setTextSize(5);
}
void loop() {
// Read the value of the sensor on A0
String sensorVal = String(analogRead(A0));
// convert the reading to a char array
sensorVal.toCharArray(sensorPrintout, 4);
// set the font color
TFTscreen.stroke(255, 255, 255);
// print the sensor value
TFTscreen.text(sensorPrintout, 0, 20);
// wait for a moment
delay(250);
// erase the text you just wrote
TFTscreen.stroke(0, 0, 0);
TFTscreen.text(sensorPrintout, 0, 20);
}