Hi peoples,
I am using a 2.4 inch TFT LCD SPFD5408 with Arduino Uno directly connected, so the TFT LCD shield is on top of it. I added a time clock module to display it on the bottom of the monitor of my project. My project is a weather station with a dht11 and a soil hygrometer, I made a whole new interface for this screen. But the only thing that isn't working is the clock. I know this code was originally for a mega, and that should be no problem, there is a problem with setting the pins i think.
Now i connected the pins for the clock the following way:
VCC on clock --> 3v on arduino uno
GND on clock --> GND next to pin 13 on arduino uno
CLK on clock --> PIN D8 on arduino
DAT on clock --> PIN D9 on arduino
RST on clock --> PIN D10 on arduino
I know this part of the script is not right there are not that many pins on the UNO.. but
when you look at fritzing and hold your mouse at the GND pin on Digital pwm, you will see a number 58, when holding your mouse over the 3v3 pin you will see a number 87. So that is why these pins are set, my GND and VCC are connected to those.
#define DS1302_GND_PIN 58
#define DS1302_VCC_PIN 87
Here are some detailed pictures i added to imgur.
here is a part of the code with setting for the pin etc.
//Author Danny van den brande.
#include "DHT.h"
#include <SPFD5408_Adafruit_GFX.h> // Core graphics library
#include <SPFD5408_Adafruit_TFTLCD.h> // Hardware-specific library
#include <SPFD5408_TouchScreen.h>
// BEGIN CLOCK
#include <DS1302RTC.h>//clock module DS1302
#include <Time.h>//Need for clock module
// Init the DS1302
// Set pins: CE, IO,CLK
DS1302RTC RTC(8, 9, 10);
// Optional connection for RTC module
#define DS1302_GND_PIN 58
#define DS1302_VCC_PIN 87
// END CLOCK++++++++
#define DHTPIN 13 // what pin we're connected to
#define DHTTYPE DHT11 // DHT 11
#define LCD_CS A3 // Chip Select goes to Analog 3
#define LCD_CD A2 // Command/Data goes to Analog 2
#define LCD_WR A1 // LCD Write goes to Analog 1
#define LCD_RD A0 // LCD Read goes to Analog 0
#define LCD_RESET A4 // Can alternately just connect to Arduino's reset pin
// Assign human-readable names to some common 16-bit color values:
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
// OBJECTS LCD ET DHT
Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);
DHT dht(DHTPIN, DHTTYPE);
float hprev, tprev, hicprev;
int moisture = 0;
int sensorValue;
void setup() {
// CLOCK MODULE BEGIN
digitalWrite(DS1302_GND_PIN, LOW);
pinMode(DS1302_GND_PIN, OUTPUT);
digitalWrite(DS1302_VCC_PIN, HIGH);
pinMode(DS1302_VCC_PIN, OUTPUT);
tft.print("RTC activated");
delay(500);
////////////////////////////////////////////////////////////////
///////STel tijd voor clock hier in /////
///////////////////////////////////////////////////////////////
//ZET TIJD HIER BENEDEN+++++++++++++++++++++++++++++++++
setTime(6,10,0,28,01,2016);
time_t t = now();
RTC.set(t);
//ZET TIJD HIER BOVEN+++++++++++++++++++++++++++++++++++
// Check clock oscillation
if (RTC.haltRTC())
tft.print("Clock stopped!");
else
tft.print("Clock working.");
// Check write-protection
tft.setCursor(0,1);
if (RTC.writeEN())
tft.print("Write allowed.");
else
tft.print("Write protected.");
delay ( 2000 );
// Setup Time library
tft.print("RTC Sync");
setSyncProvider(RTC.get); // the function to get the time from the RTC
if(timeStatus() == timeSet)
tft.print(" Ok!");
else
tft.print(" FAIL!");
delay ( 2000 );
{
}