INHOUDSOPGAWE:

DS1307 -klok met CloudX: 4 stappe
DS1307 -klok met CloudX: 4 stappe

Video: DS1307 -klok met CloudX: 4 stappe

Video: DS1307 -klok met CloudX: 4 stappe
Video: TWI and RTC DS1307 (I2C) 🔴 ATmega328P Programming #11 AVR microcontroller with Atmel Studio 2024, Julie
Anonim
DS1307 -klok met CloudX
DS1307 -klok met CloudX
DS1307 -klok met CloudX
DS1307 -klok met CloudX

Stel u ooit voor dat u u eie horlosie of horlosie wil maak. die samesmelting van 'n DS1307 en CloudX kan u strewe sonder probleme veroorsaak

Stap 1: Maak u CloudX IDE oop

Maak u CloudX IDE oop
Maak u CloudX IDE oop
Maak u CloudX IDE oop
Maak u CloudX IDE oop

Ek is jammer, maar ek weet nie wat die Real Time Clock -projekte betref nie, CloudX het u gedek.

Eenvoudige stappe

1. voer die hoofbiblioteek van cloudX in met die bordmodel

2. voer die DS1307 en ander funksionele biblioteek in

3. geniet en speel met die DS1307 -funksies uit die biblioteek

Stap 2: KODE !, KODE !!, KODE !

/*

* Lêer: main.c * Skrywer: Ogboye Godwin * * Geskep op 24 April 2018, 11:02 */

#insluit

#insluit

#insluit

ongetekende kort tydjie [9], Mdate [11];

ongetekende kort maand, Dday, jr, uur, min, sek;

getDateTime ();

loadLcd ();

resetClock ();

int stel = 16;

int inc = 15;

int dec = 14;

stel op(){

pinMode (stel, INVOER);

pinMode (inc, INPUT);

pinMode (dec, INPUT);

pinMode (1, INVOER);

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

Ds1307_init ();

lus () {

terwyl (readPin (stel) == 0) {

getDateTime ();

loadLcd ();

vertragings (500);

}

as (readPin (stel) == 1)

resetClock ();

}

}

getDateTime () {

hr = Ds1307_lees (uur); // uur

tyd [0] = BCD2UpperCh (uur);

tyd [1] = BCD2LowerCh (uur);

tyd [2] = ':';

min = Ds1307_lees (minuut); // min

tyd [3] = BCD2UpperCh (min);

tyd [4] = BCD2LowerCh (min);

tyd [5] = ':';

sek = Ds1307_lees (tweede); // sek

tyd [6] = BCD2UpperCh (sek);

tyd [7] = BCD2LowerCh (sek);

mth = Ds1307_lees (maand); // maand

Mdate [0] = BCD2UpperCh (mde);

Mdate [1] = BCD2LowerCh (mde);

Mdate [2] = ':';

Dday = Ds1307_read (datum); // dag

Mdate [3] = BCD2UpperCh (Dday);

Mdate [4] = BCD2LowerCh (Dday);

Mdate [5] = ':';

jr = Ds1307_lees (jaar); //jaar

Mdate [6] = '2';

Mdate [7] = '0';

Mdate [8] = BCD2UpperCh (jr);

Mdate [9] = BCD2LowerCh (jr);

}

loadLcd () {

int cx;

Lcd_cmd (duidelik);

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

// lcdWriteTextCP (Mdate);

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

Lcd_writeCP (Mdate [cx]);

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

// lcdWriteTextCP (tyd);

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

Lcd_writeCP (tyd [cx]);

}

resetClock () {

Ds1307_write (tweede, Binary2BCD (0)); // skryf 0 sekondes

Ds1307_write (minuut, Binary2BCD (12)); // skryf 12 minute

Ds1307_write (uur, Binary2BCD (12)); // skryf 12 uur

Ds1307_write (dag, Binary2BCD (3)); // skryf dag dinsdag

Ds1307_write (datum, Binary2BCD (24)); // skryf datum 24

Ds1307_write (maand, Binary2BCD (4)); // skryf maand tot April

Ds1307_write (jaar, Binary2BCD (18)); // skryf jaar 18, dit wil sê 2018

Ds1307_write (SQWE, Binary2BCD (frekwensie)); // stel SQWE -uitset op 1 Hz

Ds1307_write (tweede, Binary2BCD (startOscilator)); // stel die tweede na 0sek terug en begin met die ossilator

terwyl (readPin (stel) == 1);

}

Stap 3: Ontwerp in Proteus

Ontwerp in Proteus
Ontwerp in Proteus

tik in proteus isis hierdie vereistes

1. wolkX

2. DS1307

3. 4.7k weerstand

4. knoppie

5. lm016 LCD

6. kristal van 32khz

en of, natuurlik, moenie vergeet van jou positiewe en gemoed nie.

maak u konneksies soos myne.

Aanbeveel: