Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Have a look at me 7 SEG 4 digit (not done yet)
series would suck for this. If 1 led went out the whole segment would not work. Hence the parallel.
I wish i knew that before i built this.
char rtc_write(char offset, char data){
char temp;
i2c_start(); //Start
i2c_byte(slave_w); //Slave Byte
i2c_ack(); //ACK
i2c_byte(offset); //Address Offset
i2c_ack(); //ACK
i2c_byte(data); //Slave Byte
i2c_ack(); //ACK
i2c_stop; //Stop
return temp;
}
char rtc_read(char offset){
char temp;
i2c_start(); //Start
i2c_byte(slave_w); //Slave Byte
i2c_ack(); //ACK
i2c_byte(offset); //Address Offset
i2c_ack(); //ACK
i2c_start(); //Start
i2c_byte(slave_r); //Slave Byte
i2c_ack(); //ACK
temp = i2c_input(); //Get Data
i2c_ack(); //ACK
i2c_stop; //Stop
return temp;
}
//========================================
//========================================
// ds1307.c
// 2008
//========================================
//========================================
#device PIC16F628A
#define RTC_SDA 41
#define RTC_SCL 42
#use i2c(master, sda=RTC_SDA, scl=RTC_SCL)
//========================================
// initial DS1307
//========================================
void init_DS1307()
{
output_float(RTC_SCL);
output_float(RTC_SDA);
}
//========================================
// write data one byte to DS1307
//========================================
void write_DS1307(byte address, BYTE data)
{
short int status;
i2c_start();
i2c_write(0xd0);
i2c_write(address);
i2c_write(data);
i2c_stop();
i2c_start();
status=i2c_write(0xd0);
while(status==1)
{
i2c_start();
status=i2c_write(0xd0);
}
}
//========================================
// read data one byte from DS1307
//========================================
BYTE read_DS1307(byte address)
{
BYTE data;
i2c_start();
i2c_write(0xd0);
i2c_write(address);
i2c_start();
i2c_write(0xd1);
data=i2c_read(0);
i2c_stop();
return(data);
}
#include <16F628A.h>
#define RTC_SDA PIN_A2
#define RTC_SCL PIN_A3
#device PIC16F628A
#define RTC_SDA 41
#define RTC_SCL 42
#include <ds1820.c>