Cov txheej txheem:

Alarmclock: 9 Kauj ruam
Alarmclock: 9 Kauj ruam

Video: Alarmclock: 9 Kauj ruam

Video: Alarmclock: 9 Kauj ruam
Video: Сказка о потерянном времени (сказка, реж. Александр Птушко, 1964 г.) 2024, Kaum ib hlis
Anonim
Tswb moos
Tswb moos

Qhov no yog qhia rau lub tswb moos. Peb tau ua lub tswb moos vim peb ib txwm tuaj lig lossis peb feem ntau hnov qab teeb tsa lub tswb.

Lub tswb moos no tsis siv neeg tag nrho, yog li koj tsis tas yuav teeb tsa koj lub tswb. Koj tuaj yeem xaiv lub sijhawm sawv sib txawv rau txhua hnub. Koj yuav tsum teeb tsa lub sijhawm sawv ntxov ib zaug, thiab tom qab ntawd koj lub tswb nrov ntawm lub sijhawm xaiv.

Kauj ruam 1: Cov ntaub ntawv

Khoom siv
Khoom siv
Khoom siv
Khoom siv
Khoom siv
Khoom siv

1. Arduino

Peb siv Arduino Uno. Koj tuaj yeem txuas Arduino rau lub khoos phis tawj nrog USB-cable. Txhawm rau program Arduino, koj xav tau Arduino Sketch program hauv koj lub computer.

2. Lub Sijhawm Tiag

Lub Sijhawm Tiag, lub npe RTC, yog lub computer-moos. RTC hloov kho lub sijhawm, yog li koj yuav tsum teem sijhawm ib zaug. Peb siv RTC ZS-042

3. Ua kua Crystal Display

Cov kua siv lead ua kua, npe hu ua LCD, yog lub vijtsam uas koj tuaj yeem txuas rau arduino.

4. Cov qhob cij

Txhawm rau ua hluav taws xob hluav taws xob, nws yog qhov muaj txiaj ntsig zoo kom muaj lub khob cij. Arduino tswj hwm txhua tus pin.

5. Poj niam thiab txiv neej cov xov hlau

Txhawm rau txuas cov khoom siv hluav taws xob, koj tuaj yeem siv cov xov hlau no. Koj tuaj yeem txuas tus txiv neej thiab poj niam cov xov hlau nrog lub qhov thiab tus pin.

6. Buzzer

Lub suab nrov ua rau lub suab rau koj lub tswb.

7. USB-cable

Koj tuaj yeem txuas Arduino mus rau lub khoos phis tawj nrog USB-cable, yog li koj tuaj yeem tsim kho Arduino.

8. 9 volt roj teeb

9. Roj teeb clip

Txhawm rau txuas cov arduino nrog 9 volt batty, koj xav tau daim vis dis aus no.

10. Lego

Peb tau ua peb daim npog tiv thaiv nrog lego, tab sis koj tuaj yeem xaiv lwm yam yog tias koj xav tau.

Kauj Ruam 2: Txuas RTC

Txuas RTC
Txuas RTC

Txhawm rau txuas RTC rau arduino, peb xav tau RTC, Arduino, Breadboard, poj niam thiab txiv neej cov xov hlau.

Kev sib txuas Arduino

-GND: muab tso rau ntawm txoj hauj lwm j12 ntawm lub khob cij

-8: Muab tso rau ntawm txoj hauj lwm j10 ntawm lub khob cij

Kev Txuas RTC:

- 32K: tso ntawm A5 hauv Arduino

-SQW: qhov chaw ntawm Vin hauv Arduino

- SCL: Muab tso rau ntawm txoj hauj lwm h30 ntawm lub khob cij

- SDA: Muab tso rau ntawm txoj hauj lwm g30 ntawm lub khob cij

-VCC: tsis txhob tso qhov no

-GND: tso rau ntawm GND hauv Arduino

Kauj Ruam 3: Teem Sijhawm

Ua ntej, koj yuav tsum piav qhia RTC hauv daim duab:

#suav nrog

DS3231 rtc (SDA, SCL);

Tam sim no, koj tuaj yeem teem sijhawm:

rtc.begin ();

rtc.setDOW (Friday); // Teeb Hnub-ntawm-Lub Limtiam rau SUNDAY

rtc.setTime (15, 49, 0); // Teem sijhawm rau 12:00:00 (24 teev hom ntawv)

rtc.setDate (13, 4, 2018);

Koj tuaj yeem tshawb xyuas koj lub sijhawm ntawm tus saib xyuas.

Kauj Ruam 4: Txuas lub LCD

Txuas lub LCD
Txuas lub LCD

Tam sim no koj yuav tsum txuas lub LCD mus rau Arduino. Peb txuas 4 cov xov hlau los ntawm LCD mus rau Arduino lossis lub khob cij. Koj yuav tsum txuas cov xov hlau zoo li no:

- GND: tso rau ntawm GND rau hauv arduino

- VCC: muab tso rau hauv lub hwj chim ntawm daim txiag ntoo

- SDA: muab tso rau ntawm txoj haujlwm j29 ntawm daim ntawv qhia zaub mov

- SCL: tso rau ntawm txoj hauj lwm f30 ntawm lub khob cij

Kauj Ruam 5: Teeb LCD

Koj yuav tsum piav qhia LCD hauv daim duab. Koj yuav tsum ua li no:

#suav nrog

Hauv ntu no ntawm txoj cai tau piav qhia tias LCD yuav qhia hnub thiab sijhawm ntawm lub vijtsam.

void teeb tsa ()

{lcd.begin (16, 2); rau (int i = 0; i <5; i ++) {lcd.noBacklight (); ncua (500); lcd.backlight (); lcd.print ("Tswb ceeb"); ncua (500); lcd.clear (); }

Kauj Ruam 6: Txuas Buzzer

Txuas Buzzer
Txuas Buzzer

Lub tswb nrov tau muab tso rau ntawm tus pin h10 thiab hauv tus pin h12 ntawm lub khob cij. Lub suab yog qhia los ntawm lo lus 'tone'. Hauv peb daim duab peb tau xaiv lub suab no rau lub tswb nrov: suab nrov (10, 440, 200).

Kauj Ruam 7: Nruab Tswb

Peb tau xaiv los ua lub tswb tsis siv neeg. Peb tau teeb tsa lub tswb moos txij hnub Monday txog Saturday. Peb feem ntau muaj teeb meem uas peb tsis nco qab teeb tsa peb lub tswb moos, qhov no yog kev daws teeb meem rau peb. Peb tau hloov lub tswb ntawm peb lub tsev kawm ntawv lub sijhawm. Yog tias lub tswb ceeb toom muaj lub suab nrov thiab lub vijtsam flashes. Nov yog cov cai rau lub tswb ceeb toom hauv de void loop:

tswb ceeb toom (); yog (t.min == 15 && t.hour == 7) {lcd.noBacklight (); ncua (5000); lcd.backlight (); suab nrov (10, 440, 200); }}

void alarmcheck () {if (t.min == 15 && t.hour == 7 && rtc.getDOWStr (FORMAT_LONG) == "Monday") {tswb (); } yog (t.min == 45 && t.hour == 9 && rtc.getDOWStr (FORMAT_LONG) == "Tuesday") {tswb (); } yog (t.min == 14 && t.hour == 13 && rtc.getDOWStr (FORMAT_LONG) == "Wednesday") {tswb (); } yog (t.min == 45 && t.hour == 7 && rtc.getDOWStr (FORMAT_LONG) == "Thursday") {tswb (); } yog (t.min == 45 && t.hour == 7 && rtc.getDOWStr (FORMAT_LONG) == "Friday") {tswb (); } yog (t.min == 15 && t.hour == 9 && rtc.getDOWStr (FORMAT_LONG) == "Saturday") {tswb (); }}

tsis muaj lub tswb nrov () {lcd.noBacklight (); ncua (1000); lcd.backlight (); rau (int kuv = 0; kuv <100; kuv ++) {suab (10, 200*kuv+200); }}

Thaum tsis muaj lub tswb koj tuaj yeem pom lub sijhawm thiab hnub tim ntawm cov zaub. Nov yog qhov chaws:

t = rtc.getTime (); Serial.println (rtc.getDOWStr (FORMAT_LONG)); lcd.setCursor (0, 0); lcd.print ("Sijhawm:"); lcd.print (rtc.getTimeStr ()); lcd.setCursor (0, 1); lcd.print ("Hnub tim:"); lcd.print (rtc.getDateStr ()); ncua (1000); lcd.clear ();

Kauj Ruam 8: Ua Daim Npog Tiv Thaiv

Ua Qhov Tiv Thaiv
Ua Qhov Tiv Thaiv
Ua Qhov Tiv Thaiv
Ua Qhov Tiv Thaiv
Ua Qhov Tiv Thaiv
Ua Qhov Tiv Thaiv

Tag nrho cov khoom siv hluav taws xob tau txuas nrog tam sim no. Ib yam uas peb xav tau yog lub hau npog. Peb tau ua daim npog tiv thaiv los ntawm Lego, tab sis koj tuaj yeem xaiv yam koj xav tau.

Kauj Ruam 9: Siv Koj Lub Tswb

Siv Koj Alarmclock
Siv Koj Alarmclock

Tam sim no, lub tswb ceeb toom tau npaj siv. Koj yuav tsis tuaj lig, vim yog lub tswb moos tsis siv neeg no!

Pom zoo: