Introduction: DS1307 Clock With CloudX

Ever imagine you want to make your own custom watch or clock. merging a DS1307 and CloudX can make your aspiration trouble-free

Step 1: Open Your CloudX IDE

Sorry am not much of a talker, but i know when it comes to Real Time Clock projects, cloudX has got you covered.

Simple steps

1. import cloudX main library with slash its board model

2. import the DS1307 and other functional library needed

3. enjoy and play with the DS1307 funtions from its library

Step 2: CODE!, CODE!!, CODE!!!

/*

* File: main.c * Author: Ogboye Godwin * * Created on April 24, 2018, 11:02 AM */

#include <CloudX/M633.h >

#include<CloudX/DS1307.h>

#include<CloudX/Lcd.h>

unsigned short time[9],Mdate[11];

unsigned short mth,Dday,yr,hr,min,sec;

getDateTime();

loadLcd();

resetClock();

int set=16;

int inc=15;

int dec=14;

setup(){

pinMode(set,INPUT);

pinMode(inc,INPUT);

pinMode(dec,INPUT);

pinMode(1,INPUT);

Lcd_setting(2,3,4,5,6,7);

Ds1307_init();

loop(){

while(readPin(set)==0){

getDateTime();

loadLcd();

delayms(500);

}

if(readPin(set)==1)

resetClock();

}

}

getDateTime(){

hr=Ds1307_read(hour); //hr

time[0] = BCD2UpperCh(hr);

time[1] = BCD2LowerCh(hr);

time[2] = ':';

min=Ds1307_read(minute); //min

time[3] = BCD2UpperCh(min);

time[4] = BCD2LowerCh(min);

time[5] = ':';

sec=Ds1307_read(second); //sec

time[6] = BCD2UpperCh(sec);

time[7] = BCD2LowerCh(sec);

mth=Ds1307_read(month); //month

Mdate[0] = BCD2UpperCh(mth);

Mdate[1] = BCD2LowerCh(mth);

Mdate[2] = ':';

Dday=Ds1307_read(date); //day

Mdate[3] = BCD2UpperCh(Dday);

Mdate[4] = BCD2LowerCh(Dday);

Mdate[5] = ':';

yr=Ds1307_read(year); //year

Mdate[6] = '2';

Mdate[7] = '0';

Mdate[8] = BCD2UpperCh(yr);

Mdate[9] = BCD2LowerCh(yr);

}

loadLcd(){

int cx;

Lcd_cmd(clear);

Lcd_writeText(1,1,"Date: " );

//lcdWriteTextCP(Mdate);

for(cx=0;cx<11; cx++)

Lcd_writeCP(Mdate[cx]);

Lcd_writeText(2,1,"Time: " );

//lcdWriteTextCP(time);

for(cx=0;cx<9; cx++)

Lcd_writeCP(time[cx]);

}

resetClock(){

Ds1307_write(second,Binary2BCD(0)); //write 0 second

Ds1307_write(minute,Binary2BCD(12));//write 12 minute

Ds1307_write(hour,Binary2BCD(12)); // write 12hrs

Ds1307_write(day,Binary2BCD(3)); //write day tuesday

Ds1307_write(date,Binary2BCD(24)); // write date 24th

Ds1307_write(month,Binary2BCD(4)); // write month to april

Ds1307_write(year,Binary2BCD(18)); // write year 18 i.e 2018

Ds1307_write(SQWE,Binary2BCD(frequency)); // set SQWE output to 1hz

Ds1307_write(second,Binary2BCD(startOscilator)); // reset second to 0sec and start oscilator

while(readPin(set)==1);

}

Step 3: Design in Proteus

type in proteus isis these requirements

1. cloudX

2. DS1307

3. 4.7k resistor

4. button

5. lm016 LCD

6. crystal of 32khz

and or course don't forget your positive and ground.

make your connections like mine.

Step 4: FILES