Cov txheej txheem:

NODEMCU LUA ESP8266 Nrog MCP23017 16 Ntsis Chaw Nkoj Expander IC: 6 Kauj Ruam (nrog Duab)
NODEMCU LUA ESP8266 Nrog MCP23017 16 Ntsis Chaw Nkoj Expander IC: 6 Kauj Ruam (nrog Duab)

Video: NODEMCU LUA ESP8266 Nrog MCP23017 16 Ntsis Chaw Nkoj Expander IC: 6 Kauj Ruam (nrog Duab)

Video: NODEMCU LUA ESP8266 Nrog MCP23017 16 Ntsis Chaw Nkoj Expander IC: 6 Kauj Ruam (nrog Duab)
Video: Подключение расширителя портов MCP23017 к ESP8266 NodeMcu 2024, Hlis ntuj nqeg
Anonim
NODEMCU LUA ESP8266 Nrog MCP23017 16 Ntsis Chaw Nkoj Expander IC
NODEMCU LUA ESP8266 Nrog MCP23017 16 Ntsis Chaw Nkoj Expander IC

MCP23017 yog ib qho yooj yim IC los ua lub rooj tsav xwm vim nws muaj Chaw Nkag A thiab B ntawm ob sab ntawm lub nti thiab cov pins tau nyob ua ntu zus.

Ib yam li I2C chaw nyob npav yog txhua yam ua ke ib yam nkaus.

Muaj 2 tus pin ntawm IC no uas tsis siv vim nws piv rau MCP23S17 uas siv SPI interface uas siv cov pins no.

Cov ntawv rau IC no muaj los ntawm Microchip.

Kauj Ruam 1: Daim duab Circuit Court

Daim duab Circuit Court
Daim duab Circuit Court

Daim duab hluav taws xob qhia pom yuav ua li cas txuas IC rau ESP8266

NCO TSEG: IC khiav ntawm 2.7 thiab 5.5 Volts.

Pin Txuas ntawm kuv lub rooj tsavxwm

  • Pin 9 (VDD) to 3v3
  • Pin 18 (RESET) rau 3v3
  • Pin 17 (A2) to GND
  • Pin 16 (A1) to GND
  • Pin 15 (A0) to GND
  • Pin 14 (NC) to GND (Tsis tsim nyog)
  • Pin 13 (SDA) to ESP GPIO0
  • Pin 12 (SCL) rau ESP GPIO2
  • Pin 11 (NC) to GND (Tsis tsim nyog)
  • Pin 10 (VSS) to GND

Kauj Ruam 2: Ua Tus Thawj Coj Loj

Ua Tus Thawj Coj Loj
Ua Tus Thawj Coj Loj

Lub rooj tsavxwm yog ncaj nraim rau ua raws li tau piav qhia saum toj no, txhua yam yog txheej txheem yooj yim.

Kuv lub rooj tsavxwm tseem ceeb tau siv sijhawm me ntsis los ua thiab tau qhia saum toj no.

Koj tuaj yeem tsim qhov Circuit Court no ntawm lub khob cij.

Kauj Ruam 3: Cov Ntsiab Lus Ntxiv

Cov laug cam ntxiv
Cov laug cam ntxiv

Kuv tau tsim qee qhov ntxiv 8 ntsis cov laug cam uas tuaj yeem yooj yim ntsaws rau hauv cov phiaj xwm sib txawv.

Thawj pawg thawj coj tau txuas nrog 7 ntu LED zaub thiab txuas nrog tus pin 1 rau ntu a, tus pin 2 rau b thiab lwm yam.

Qhov thib ob yog 8 lub txhab nyiaj hloov pauv txhua qhov txuas ua ke thiab tuaj yeem txuas nrog 3.3V lossis hauv av. Kuv tsis tau suav nrog ib qho kev tiv thaiv rub raws li MCP23017 muaj lawv nyob hauv.

Qhov thib peb yog los ntawm cov khoom siv Ebay, nws suav nrog 8 LEDs thiab cov kab tawm tsam nrog kev txuas mus rau Gnd. Kuv kuj muaj tib lub rooj tsav xwm tab sis teeb tsa LEDs txoj kev sib txawv ib puag ncig kom nws txuas mus rau 3.3V lossis 5V siv Gnd. Ntawm Ebay lawv raug hu ua 8 Channel Flowing Water Light LED DIY Kit, 99p los ntawm Tuam Tshoj.

Kauj ruam 4: Programming

Programming
Programming

Kuv tau sau cov haujlwm los ua haujlwm nrog ESP01 vim qhov no tsuas muaj 2 I/O pins. Nws tuaj yeem siv tau nrog ib qho ntawm ESP8266 cov laug cam. SDA & SCL pins tuaj yeem faib rau txhua tus pin ntawm 1 thiab 12.

Yog tias siv LUA laus dua (piv txwv li NodeMCU 0.9.6 tsim 20150704 siv los ntawm Lua 5.1.4) I2C twb tau teeb tsa lawm. Txwv tsis pub koj yuav tsum ua kom ntseeg tau tias I2C tus qauv tau suav nrog hauv koj qhov kev tsim.

Kuv tau suav nrog 3 txoj haujlwm Lua yooj yim los qhia seb IC tuaj yeem siv tau li cas.

7Segment.lua tsav lub teeb pom kev ntawm LED thiab ua ntu zus ntawm tus lej 1 txog 0.

KittCar.lua tsav lub 8 LED board los sim lub tsheb nto moo los ntawm 80s.

Reader.lua nyeem los ntawm Chaw nres nkoj B.

Kauj ruam 5: Tus Pin twg?

Tus Pin?
Tus Pin?

Ib qho program ntxiv uas kuv tuaj nrog thaum tinkering.

Nws siv chaw nres nkoj B ua cov tswv yim thiab chaw nres nkoj A raws li qhov tso tawm. Daim duab qhia pom DIP hloov pauv, tab sis koj tuaj yeem txuas ib qho ntawm qhov chaw nres nkoj B pins rau Gnd thiab LED zaub yuav qhia tus pin txuas nrog.

NCO TSEG: Nws tsuas ua haujlwm nrog 1 tus pin ntawm ib lub sijhawm!

Kauj Ruam 6: Xaus

Xaus
Xaus

Muaj qhov tseeb lwm qhov I/O nthuav dav muaj. Qee qhov yog 8 ntsis, 16 ntsis thiab txawm tias 24 ntsis! Txhua txoj haujlwm zoo ib yam rau MCP23017, tab sis IC no pheej yig heev rau nws lub peev xwm thiab tuaj yeem nrhiav tau nyob ib puag ncig 10p txhua tus los ntawm Tuam Tshoj.

Kuv tsis tau siv tag nrho cov yam ntxwv ntawm IC no vim tias muaj kev cuam tshuam tseem muaj cov tuaj yeem siv tau. Nyeem cov ntawv qhia txhua yam txog kev sau npe sib txawv thiab txoj hauv kev IC tuaj yeem siv.

Nws muaj peev xwm muaj 8 ntawm cov cuab yeej no ntawm tib lub npav I2C muab 128 I/O chaw nres nkoj txhua qhov kev tswj hwm los ntawm 2 kab. Xav txog qhov muaj peev xwm nyob ntawd!

Pom zoo: