Hello, im new user to arduino. I started playing with, using an online arduino simulator ( i dont know if its apropriate to refer here site name). The reason i use simulator is that i have arduino nano but not some parts i would like to use.
So, i thought to make a simple watering programmer with 4 outputs (for start). I think that the basic part list is arduino, lcd, keypad or pushbutton, rtc.
After testing 2x16 lcd and tft i make use of tft because its bigger.
Ok now im playing with the graphics but there is a small problem. The time is displayed TT:MM:SS but seconds from 1 to 9 are not showing as 01,02... but 1,2... and every new second displayed on the previus without "reseting". After some secs passing the only you can see is a rectangle of pixels. This happens to minutes to and i suppose when hour change.
When testing 2x16 i had found a solution but in tft does not work. I tried to find some kind of code like cls before next sec printed without success.
I dont know if its a bug of the simulator because there were some while using lcd.
Why not use a real screen so as to test it better? Its because as i said i am testing which of 2 type of screen will be better for the project.
Do you have any suggestion to solve the problem?
thank you very much.
Sorry, i forgot the code,
#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
#include "RTClib.h"
RTC_DS1307 RTC;
char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
#define TFT_DC 9
#define TFT_CS 10
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
void setup(){
pinMode(5, OUTPUT);
RTC.begin();
if (!RTC.isrunning())
{
RTC.adjust(DateTime(__DATE__, __TIME__));
}
tft.begin();
for (uint16_t a=0; a<3; a++)
{
tft.drawLine(0,20+a,240,20+a,ILI9341_WHITE); //draw horizontal line under time
}
tft.setCursor(3, 35);
tft.setTextColor(ILI9341_WHITE);
tft.setTextSize(2);
tft.println("Out");
tft.setCursor(50, 35);
tft.setTextColor(ILI9341_WHITE);
tft.setTextSize(2);
tft.println("Strt");
tft.setCursor(125, 35);
tft.setTextColor(ILI9341_WHITE);
tft.setTextSize(2);
tft.println("Drt");
tft.setCursor(200, 35);
tft.setTextColor(ILI9341_WHITE);
tft.setTextSize(2);
tft.println("Rpt");
for (uint16_t a=0; a<3; a++)
{
tft.drawLine(0,55+a,240,55+a,ILI9341_WHITE); //draw horizontal line under valve settings
}
for (uint16_t a=0; a<2; a++)
{
tft.drawLine(43+a,20,43+a,310,ILI9341_WHITE); //draw a vertical line for OUT
}
for (uint16_t a=0; a<2; a++)
{
tft.drawLine(110+a,20,110+a,310,ILI9341_WHITE); //draw a vertical line for START
}
for (uint16_t a=0; a<2; a++)
{
tft.drawLine(180+a,20,180+a,310,ILI9341_WHITE); //draw a vertical line for DURATION
}
tft.setCursor(3, 62);
tft.setTextColor(ILI9341_RED);
tft.setTextSize(2);
tft.println("V1");
for (uint16_t a=0; a<3; a++)
{
tft.drawLine(0,118+a,240,118+a,ILI9341_WHITE); //draw horizontal line under v1 settings
}
tft.setCursor(3, 122);
tft.setTextColor(ILI9341_RED);
tft.setTextSize(2);
tft.println("V2");
for (uint16_t a=0; a<3; a++)
{
tft.drawLine(0,180+a,240,180+a,ILI9341_WHITE); //draw horizontal line under v2 settings
}
tft.setCursor(3, 184);
tft.setTextColor(ILI9341_RED);
tft.setTextSize(2);
tft.println("V3");
for (uint16_t a=0; a<3; a++)
{
tft.drawLine(0,242+a,240,242+a,ILI9341_WHITE); //draw horizontal line under v3 settings
}
tft.setCursor(3, 246);
tft.setTextColor(ILI9341_RED);
tft.setTextSize(2);
tft.println("V4");
for (uint16_t a=0; a<3; a++)
{
tft.drawLine(0,308+a,240,308+a,ILI9341_WHITE); //draw horizontal line under v4 settings
}
}
void loop(){
DateTime now = RTC.now();
tft.begin();
tft.setTextColor(ILI9341_WHITE);
tft.setTextSize(2);
tft.setCursor(3,3);
tft.print(now.hour(), DEC);
tft.print(':');
tft.print(now.minute(), DEC);
tft.print(':');
tft.print(now.second(), DEC);
tft.println();
tft.setTextColor(ILI9341_WHITE);
tft.setTextSize(2);
tft.setCursor(130,3);
tft.print(now.day(), DEC);
tft.print('/');
tft.print(now.month(), DEC);
tft.print('/');
tft.print(now.year(), DEC);
tft.println();
tft.println();
delay(500);
}