Cov txheej txheem:

ESP32 Scrolling WordClock ntawm LED Matrix: 5 Cov Kauj Ruam (nrog Duab)
ESP32 Scrolling WordClock ntawm LED Matrix: 5 Cov Kauj Ruam (nrog Duab)

Video: ESP32 Scrolling WordClock ntawm LED Matrix: 5 Cov Kauj Ruam (nrog Duab)

Video: ESP32 Scrolling WordClock ntawm LED Matrix: 5 Cov Kauj Ruam (nrog Duab)
Video: ESP8266 Word Clock on 16x16 Led Matrix 2024, Hlis ntuj nqeg
Anonim
Image
Image

Hauv qhov haujlwm no kuv tsim Scrolling WordClock nrog ESP32, LED Matrix thiab lub thawv luam yeeb.

WordClock yog lub moos uas sau lub sijhawm ntau dua li tsuas yog luam tawm ntawm lub vijtsam lossis muaj tes uas koj tuaj yeem nyeem. Lub moos no yuav qhia koj tias nws yog 10 feeb dhau los 3 teev tsaus ntuj, lossis tav su. Kuv tseem tau npaj nws los siv Prevening (los ntawm Big Bang Theory) lub npe rau qhov tsis meej pem ntawm lub sijhawm nruab nrab ntawm yav tav su thiab yav tsaus ntuj. Pib 4:00 PM.

ESP32 zoo heev, lawv lom zem heev thiab tsis kim li, Yog tias koj nyiam programming Arduino koj yuav xav tsis thoob li cas ntawm ESP32 tuaj yeem ua rau qis dua $ 10. Lawv siv Arduino IDE thiab yooj yim rau txoj haujlwm. Kuv yuav ua kom pom yuav ua li cas hauv qhov kev qhia no.

Khoom siv

  • ESP32 - ncig $ 10 ntawm amazon
  • LED Matrix (max7219) (thiab xov hlau) - $ 9 amazon
  • Cigar lub thawv
  • USB fais fab cable
  • Yeem 3d tshuab luam ntawv rau esp32 sawv ntsug

Kauj Ruam 1: Teeb Koj Arduino IDE los Txhawb ESP32

Tau txais Arduino IDE:

  • Hauv qhov browser mus rau
  • Nyem rau Software ces rub tawm kom tau ARDUINO 1.8.12
Duab
Duab

Ntxiv ESP32 Txhawb rau koj Arduino IDE:

  • Pib Arduino IDE
  • Nyem rau ntawm File Menu ces Nyiam.

Ib zaug hauv "Nyiam" ntxiv cov chaw tsim khoom txhawb los ntawm kev ntxiv kab hauv qab no mus rau "Tus Thawj Saib Xyuas Haujlwm Ntxiv"

Duab
Duab

dl.espressif.com/dl/package_esp32_index.js

Qhov no yuav ua rau peb nkag mus ntxiv lub rooj tsav xwm rau IDE

Mus rau Cov Ntawv Qhia Cov Cuab Yeej thiab tom qab ntawv Boards thiab mus rau tus thawj tswj hwm pawg thawj coj saib

Duab
Duab

Nrhiav tom ntej rau "ESP" thiab ntxiv pob los ntawm Expressif.

Duab
Duab

Thaum kawg peb xav rov qab mus rau "Cov Cuab Yeej" Ntawv Qhia, tom qab ntawd "Pawg Thawj Coj" dua thiab nqes mus kom pom koj li ESP32 lub cuab yeej.

Kuv yog "ESP32 Wrover Module"

Duab
Duab

Kauj Ruam 2: Txuas lub LED Matrix rau ESP32

Duab
Duab

LED matrix yog ua los ntawm plaub 8x8 blocks ntawm LEDs thiab siv MAX7219 nti. Qhov ntawd muab rau peb 8x32 LEDs hauv Matrix lossis 256 LEDs !!!.

Esp32 tau zaum ntawm qhov tuav kuv tsim hauv TinkerCad. Kuv tus tuav tuav lub pins tig ntsej muag kom koj tuaj yeem txuas cov xov hlau.

LED Matrix txuas rau ESP32 siv SPI (Serial Peripheral Interface).

Siv Poj Niam/Poj Niam Hluav Taws Xob thiab Txuas tus pin raws li hauv qab no:

  • ESP32 - 5v rau VCC ntawm Matrix
  • ESP32 - GND rau GND ntawm Matrix
  • ESP32 - PIN5 (G5) rau CS ntawm Matrix
  • ESP32 - PIN23 (G23) rau Din ntawm Matrix
  • ESP32 - Tus Pin 18 (G18) rau CLK ntawm Matrix

Nws tuaj yeem siv lwm tus pin lossis yog tias koj ESP32 muaj qhov sib txawv pinout.

Kauj Ruam 3: Muab Nws Ua Ke

Muab tso ua ke
Muab tso ua ke

Tom ntej no kuv txiav lub thawv luam yeeb kom muab qhov chaw rau kuv tso rau hauv LED zaub. Lub thawv yog mos thiab kuv muaj peev xwm siv rab chais rab riam. Tom qab ntawd kuv tau xuab zeb kom du nws.

Kuv kuj txiav tag nrho hauv nraub qaum rau lub hwj chim qaum. Kuv nyuam qhuav siv USB zog. Kuv tuaj yeem tau ntxiv ib lub xov tooj USB them roj teeb sab hauv lub thawv cigar yog tias kuv xav kom nws ua wireless.

Kauj Ruam 4: Arduino IDE thiab INO File

Arduino IDE thiab INO File
Arduino IDE thiab INO File

Qhov zoo tshaj yog qhov chaws. Tab sis ua ntej peb yuav tsum ntxiv lub tsev qiv ntawv los tso cai rau qhov program kom siv cov zaub hauv txoj hauv kev yooj yim dua. Kuv ntxiv MD_MAX72xx lub tsev qiv ntawv.

Txhawm rau ntxiv lub tsev qiv ntawv nyem rau ntawm "Sketch" ntawv qhia zaub mov, tom qab ntawd "suav nrog Lub Tsev Qiv Ntawv" thiab "Tswj Cov Tsev Qiv Ntawv" qhov no yuav thauj khoom thiab tso cai rau koj tshawb nrhiav MD_MAX72xx lub tsev qiv ntawv. Tsuas yog nyem rau nruab thiab koj muaj nws.

Tom ntej no tau txais kuv Arduino INO Cov Ntaub Ntawv:

github.com/aapicella/wordClock/blob/master/Word_Clock_LED_NTP_final_.ino

Thauj cov ntaub ntawv ino rau hauv koj Arduino IDE, Txuas lub USB los ntawm ESP32 rau koj lub computer.

Nyem rau ntawm "Sketch" ces Upload

Txog tam sim no lub moos yuav tsis ua haujlwm, ESP32 yuav tsis tso saib dab tsi. Vim li cas? peb yuav tsum ntxiv koj li WIFI rau cov cai vim tias WordClock txuas rau hauv internet kom tau txais lub sijhawm. Yog lawm … cov kauj ruam tom ntej ->.

Kauj ruam 5: Txoj Cai

Thaum kawg peb ua nws rau qhov kuv nyiam tshaj. Qhov kev zov me nyuam. Kuv yuav npog nws los ntawm sab saum toj mus rau hauv qab yog tias koj xav tau, Kom tau txais txoj haujlwm los ua haujlwm nrog koj li internet hauv tsev koj tsuas yog xav hloov cov kab no.

// Ntxiv koj cov ntaub ntawv network

const char *ssid = "xxxxxx";

const char *password = "xxxxxx";

Qhov kev zov me nyuam yog qhov nyuaj, tab sis lom zem heev.

Txhawm rau lov tes taw "Prevening" tsuas yog hloov tus nqi rau qhov tsis raug:

const boolean PREVENING = muaj tseeb; // Big Bang txoj kev xav.

Txhawm rau lov tes taw tso saib lub sijhawm digital tom qab scrolling hloov qhov no mus tsis tseeb.

const boolean DISPLAY_DIGITAL = muaj tseeb; // tig rau tso saib cov sijhawm digital tom qab scrolling.

Scrolling Lub Sijhawm:

Kuv tau txais lub sijhawm los ntawm lub sijhawm server hauv internet siv NTP (Network Time Protocol). Lub sijhawm muaj nyob hauv qhov sib txawv hu ua timeinfo thiab peb tau txais teev thiab feeb los ntawm nws

int teev = timeinfo.tm_hour; /// 0-23

int feeb = timeinfo.tm_min; // 0-59

Txheeb xyuas tom ntej AM lossis PM

Nws AM yog teev <12

Kuv tsim txoj hlua hu ua "theTime" thiab pib nrog:

theTime = "Nws yog";

Kom tau tus lej raws li cov lus, Kuv tau tsim kab lus ntawm cov lej rau 30

const char *lej = {

"0", "Ib", "Ob", "Peb", "Plaub", "Tsib", "Rau", "Xya", "Yim", "Cuaj", "Kaum", "Kaum Ib", "Kaum Ob" "," Kaum Peb "," Kaum Ib "," Peb Hlis "," Kaum Ib "," Kaum Ib "," Kaum Ib "," Kaum Hli "," Nees nkaum "," Nees nkaum Ib "," Nees nkaum-Ob "," Nees nkaum-Peb " "," Nees nkaum-Plaub "," Nees nkaum-Tsib "," Nees nkaum-Rau "," Nees nkaum-Xya "," Nees nkaum-Yim "," Nees nkaum-Nine "," Ib nrab dhau los "};

Yog li thaum nws 12:05 lossis tsib feeb dhau los kaum ob nws tiag tiag rau Arduino

tus lej [5] feeb dhau los tus lej [12]

Txhawm rau txiav txim siab yog tias nws "Minutes Past" lossis "Minutes To" peb tsuas yog saib cov feeb. Yog tias feeb yog <31 nws yog "Minutes Past" yog tias cov feeb ntau dua 31 peb siv "Minutes To" tab sis siv tus lej [60-feeb] yog li 12:50 yuav yog 60-50 feeb lossis tus lej [10] uas yuav muab peb 10 feeb Mus Rau 12 0'clock.

Tau kawg muaj lwm txoj cai zoo li ntawm 15, 30, 45 peb tsis siv feeb nws tsuas yog ib nrab dhau los lossis peb lub hlis rau, thiab yog tias feeb yog 0 lub sijhawm tsuas yog "Kaum Teg" lossis tav su.

Yog li txhawm rau muab tso ua ke, Kuv txuas ntxiv txhua yam khoom mus rau Txoj hlua Lub Sijhawm tom qab ntawd tso nws tawm ntawm LED Matrix. Kuv siv pawg Yog tias nqe lus. Tej zaum kuv yuav tsum tau siv rooj plaub tab sis nws tsuas yog yooj yim dua kom ntxiv lawv.

Rau peb tus piv txwv 12:05

theTime = "Nws yog"

yog feeb <31 siv "Minutes Past" txwv tsis pub nws "Minute To"

theTime + = tus lej [5] + "Minutes Past" + tus lej [12] + "O'Clock" // Nco tseg: Cov cim + + = yog ntxiv.

Tom ntej no peb saib lub sijhawm los txiav txim seb nws puas sawv ntxov, yav tav su lossis yav tsaus ntuj.

theTime+= "Yav tsaus ntuj"

Txoj hlua kawg mus rau qhov sib piv yog:

"Nws yog Tsib feeb dhau los kaum ob teev nyob rau yav tsaus ntuj"

Txoj haujlwm no lom zem heev los sau. Yog tias koj nyiam nws thov nyem Lub Plawv thiab Pov Ntawv rau kuv thov.

Pom zoo: