I use an Arduino uno in combination with this display: https://www.amazon.de/dp/B07Y6179LG?psc=1&ref=ppx_yo2ov_dt_b_product_details and the Real Time Clock DS3231. I want to show the time on the display, but there is a problem when I merge the code from the display and the clock. Individually, both codes work perfectly. Here is the code that doesn't work:
//blog.berrybase.de
#include <Adafruit_GFX.h>
#include <MCUFRIEND_kbv.h>
#include <DS3231.h>
// Init the DS3231 using the hardware interface
DS3231 rtc(SDA, SCL);
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
MCUFRIEND_kbv tft;
void setup()
{
// Reading TFT ID:
uint16_t ID=tft.readID();
Serial.begin(115200);
Serial.println(ID);
//Initializing TFT display:
tft.begin(ID);
rtc.begin();
rtc.setDOW(WEDNESDAY); // Set Day-of-Week to SUNDAY
rtc.setTime(12, 0, 0); // Set the time to 12:00:00 (24hr format)
rtc.setDate(1, 1, 2014); // Set the date to January 1st, 2014
// Send Day-of-Week
Serial.print(rtc.getDOWStr());
Serial.print(" ");
// Send date
Serial.print(rtc.getDateStr());
Serial.print(" -- ");
// Send time
Serial.println(rtc.getTimeStr());
}
void loop()
{
tft.setRotation(1);
tft.fillScreen(BLACK);
tft.setCursor(65,100); //col , lin
tft.setTextColor(RED);
tft.setTextSize(4);
tft.print("The maker shop");
tft.fillRect(80,200, 321, 60, RED);
tft.setCursor(100,215);
tft.setTextColor(WHITE);
tft.setTextSize(4);
tft.print("berrybase.de");
delay(2000);
//////////////////////////////////////////
tft.fillScreen(RED);
tft.fillScreen(GREEN);
tft.fillScreen(BLUE);
delay(50);
//////////////////////////////////////////
tft.fillScreen(BLACK);
tft.setCursor(30 ,135); //col , lin
tft.setTextColor(RED);
tft.setTextSize(6);
tft.print("TEST");
delay(2000);
//////////////////////////////////////////
tft.fillScreen(RED);
tft.fillScreen(GREEN);
tft.fillScreen(BLUE);
delay(50) ;
}
It must be due to the commands rtc.getDateStr() and rtc.getTimeStr(), because without them it works. With the commands, the screen flashes in different white levels.
Sorry just combining code is not the best way. Start with one, get it working the way you want then add the second code piece by piece and observe the results. Start with the setup code first but be sure the other keeps working. Your link is useless, it has no technical information. Post an annotated schematic exactly as you have wired it include all power, ground, and power sources. Update the link to one that gives technical information.
Thanks for your answer, I checked the code piece by piece and it's because of the lines
Serial.print(rtc.getDateStr());
and
Serial.println(rtc.getTimeStr());
Everything should be correct with the wiring, because the example program of the LCD display and the example program of the clock work separately from each other.
Here are the schematics of how I wired it up:
Sorry your picture does not tell me what I need to know to answer your question. I can say as you picture shows it will not work properly. Not sure what a mechanical drawing for a display is for. You can hand draw the schematic if you want. The frizzy does not even show the display nor the power sources etc. If you want to use a great and free CAD program KiCad is available for a download.
How do you know? Because I strongly suspect it's not a wiring problem, it's a code problem...
The lcd display is a shield that you put on top of the arduino in the first picture you can see the pins of the shield that are connected to the arduino and in the second picture you can see the inputs on the arduino.
If you look at these 2 pictures, you see that LCD_RST is on A4. But A4 is also SCL. There's your conflict. The separate SCL and SDA pins are just duplicates of A4 and A5.
You would need to cut the RST pin of your display for your combination. Some displays will work with RST high, may even have an internal pull-up. And you would need to tell MCUFriend_kbv that you have no RST pin. Don't know if this is easy or not.
ZinggjM answered your question as to one of the problems, I believe there are more but without a schematic I guess we start guessing. Update the link to to the display that gives technical information, I am not in the market to purchase one.