Cov txheej txheem:

Precision Moos: 3 Kauj Ruam
Precision Moos: 3 Kauj Ruam

Video: Precision Moos: 3 Kauj Ruam

Video: Precision Moos: 3 Kauj Ruam
Video: Maroon 5 - Girls Like You ft. Cardi B (Official Music Video) 2024, Kaum ib hlis
Anonim
Precision Moos
Precision Moos

Peb txhua tus xav tau lub moos yog li vim li cas ho tsis ua koj tus kheej hauv phau ntawv qhia no Kuv yuav qhia koj yuav ua li cas thiaj ua tau lub Caij Nyoog Precision thaum koj teeb tsa yuav cia li taug qab lub sijhawm tam sim no hauv keeb kwm yav dhau los ntawm txhua yam. Thaum tseem tsuas xav tau cov khoom siv me me thiab xoom solderings.

Khoom siv

Ua ntej, koj yuav xav tau Arduino tab sis ib qho Arduino yuav ua haujlwm

Tom ntej no, koj yuav xav tau ntau yam ntawm cov xov hluav taws xob dav dav.

2 12mm Sparkfun Pushbutton Hloov

Ib txwm Breadboard

thiab LCD 1602 16 tus pin zaub

Kauj ruam 1: Kev thaiv kab

Thaiv
Thaiv

Txhawm rau lub moos no ua haujlwm koj yuav tsum tau xaim qhov no tshwj xeeb lossis lwm yam koj yuav tau txais cov lej ntawm cov lej tsis raug ntawm lub vijtsam ntau dua li lub sijhawm.

Kauj ruam 2: Txoj Cai

Txij li thaum peb tsis siv RTC peb cov cai yuav mus ntev me ntsis tab sis ua tsaug kuv tau ua txhua yam haujlwm nyuaj rau koj thiab muab rau ntawm no.

Tsuas yog Luam thiab Paste qhov no rau hauv Arduino IDE lossis lub vev xaib Editor.

#suav nrog "LiquidCrystal.h"

// Qhov no piav qhia LCD txuas rau DIGITALpins const rs = 2, en = 3, d4 = 4, d5 = 5, d6 = 6, d7 = 7; LiquidCrystal lcd (rs, en, d4, d5, d6, d7);

// Digital LCD Constrast setting int cs = 9; // pin 9 for contrast PWM const int contrast = 100; // default contrast

// Thawj Lub Sijhawm Qhia Tawm yog 12:59:45 PM int h = 12; tus m = 59; sis = 45; tus chij = 1; // TS. PM

// Lub Sijhawm Teev Khawm int int button1; int khawm 2;

// Pins lub ntsiab lus rau Lub Sijhawm Teem Khawm int hs = 0; // pin 0 rau Teev Sijhawm teeb tsa int ms = 1; // pin 1 rau feeb Teeb

// Backlight Time Out const int Time_light = 150; int bl_TO = Time_light; // Backlight Time-Out int bl = 10; // Backlight pin const int backlight = 120; // tsis muaj ntau dua 7mA !!!

// Rau lub sijhawm nyeem ntawv raug, siv Arduino Lub Sijhawm Tiag thiab tsis yog ncua sijhawm () zoo li qub uint32_t last_time, tam sim no = 0; // RTC ib

teeb tsa tsis muaj dab tsi () {lcd.begin (16, 2); pinMode (hs, INPUT_PULLUP); // zam kev rub tawm sab nraud rau khawm 1 pinMode (ms, INPUT_PULLUP); // thiab Khawm 2 analogWrite (cs, sib piv); // Kho qhov sib piv VO analogWrite (bl, teeb pom kev zoo); // Tig ntawm Backlight tam sim no = millis (); // nyeem RTC thawj tus nqi}

void loop () {lcd.begin (16, 2); // every second // Update LCD Display // Print TIME in Hour, Min, Sec + AM/PM lcd.setCursor (0, 0); lcd.print ("Sijhawm"); yog (h <10) lcd.print ("0"); // ib txwm 2 tus lej lcd.print (h); lcd.print (":"); yog (m <10) lcd.print ("0"); lcd.print (m); lcd.print (":"); yog (s <10) lcd.print ("0"); lcd.print (s);

yog (chij == 0) lcd.print ("AM"); yog (chij == 1) lcd.print ("PM"); lcd.setCursor (0, 1); // rau Kab 2 lcd.print ("Precision moos");

// txhim kho kev hloov pauv ncua (1000) // Zoo dua qhov tseeb, tsis muaj kev vam khom ntau dua ntawm lub sijhawm ua haujlwm

rau (int i = 0; i <5; i ++) // ua 5 zaug 200ms lub voj, kom nrawm khawm teb {

thaum ((tam sim no-sijhawm kawg) <200) // ncua 200ms {tam sim no = millis (); } // puab 200ms voj kawg_time = tam sim no; // npaj rau lub voj tom ntej

// nyeem Teeb Nyem khawm 1 = digitalRead (hs); // Nyem Nyem khawm 2 = digitalRead (ms);

// Backlight lub sij hawm tawm bl_TO--; yog (bl_TO == 0) {analogWrite (bl, 0); // Backlight OFF bl_TO ++; } // Ntaus ib qho kom qhib Backlight yog (((button1 == 0) | (button2 == 0)) & (bl_TO == 1)) {bl_TO = Time_light; analogWrite (bl, teeb pom kev zoo); // tos kom txog thaum khawm tso thaum ((button1 == 0) | (button2 == 0)) {button1 = digitalRead (hs); // Nyeem Buttonons2 = digitalRead (ms); }} lwm qhov // Txheej Txheem Khawm 1 lossis Khawm 2 thaum ntaus thaum Backlight ntawm {yog (button1 == 0) {h = h+1; bl_TO = Lub sij hawm_ teeb; analogWrite (bl, teeb pom kev zoo); }

yog (khawm 2 == 0) {s = 0; m = m+1; bl_TO = Lub sij hawm_ teeb; analogWrite (bl, teeb pom kev zoo); }

/* ---- tswj vib nas this, feeb, teev sawv ntxov/yav tsaus ntuj ----*/yog (s == 60) {s = 0; m = m+1; } yog (m == 60) {m = 0; h = h+1; } yog (h == 13) {h = 1; chij = chij+1; yog (chij == 2) chij = 0; }

yog ((button1 == 0) | (button2 == 0)) // Hloov tshiab yog tias lub sijhawm teeb tsa khawm nias {// Hloov Kho LCD Zaub Zaub // Luam Lub Sijhawm Teev Hauv Teev, Min, Sec + AM/PM lcd.setCursor (0, 0); lcd.print ("Sijhawm"); yog (h <10) lcd.print ("0"); // ib txwm 2 tus lej lcd.print (h); lcd.print (":"); yog (m <10) lcd.print ("0"); lcd.print (m); lcd.print (":"); yog (s <10) lcd.print ("0"); lcd.print (s);

yog (chij == 0) lcd.print ("AM"); yog (chij == 1) lcd.print ("PM"); lcd.setCursor (0, 1); // rau Kab 2 lcd.print ("Precision moos"); }

} // kawg yog lwm qhov} // xaus rau

// txheej sab nraud 1000ms

s = s+1; // nce sec. suav // ---- tswj vib nas this, feeb, teev sawv ntxov/yav tsaus ntuj ---- yog (s == 60) {s = 0; m = m+1; } yog (m == 60) {m = 0; h = h+1; } yog (h == 13) {h = 1; chij = chij+1; yog (chij == 2) chij = 0; }

// Loop kawg}

Kauj Ruam 3: Schematic (Qhov No Tsis Yog Ib Kauj Ruam tiag)

Schematic (Qhov no Tsis Yog Ib Kauj Ruam tiag)
Schematic (Qhov no Tsis Yog Ib Kauj Ruam tiag)

Yog leej twg nyeem qhov no yog thev naus laus zis nerd ntawm no kuj yog cov txheej txheem koj tuaj yeem saib nws mus vwm.

Txaus siab thiab muaj kev lom zem thiab feem ntau ntawm txhua yam nyob tshiab.

Pom zoo: