Cov txheej txheem:

OLED I2C Zaub Arduino/NodeMCU Qhia: 15 Kauj Ruam
OLED I2C Zaub Arduino/NodeMCU Qhia: 15 Kauj Ruam

Video: OLED I2C Zaub Arduino/NodeMCU Qhia: 15 Kauj Ruam

Video: OLED I2C Zaub Arduino/NodeMCU Qhia: 15 Kauj Ruam
Video: #06 SI7021 ESP8266 Display (Schweizerdeutsch) 2024, Kaum ib hlis
Anonim
Image
Image

Thawj qhov program koj sau thaum koj pib kawm a

hom lus programming tshiab yog: "Nyob Zoo Ntiaj Teb!".

Qhov kev zov me nyuam nws tus kheej tsis muaj dab tsi ntau dua li luam ntawv "Nyob Zoo Ntiaj Teb" cov ntawv ntawm qhov screen.

Yog li, peb yuav ua li cas thiaj tau txais peb Arduino los tso saib "Nyob Zoo Ntiaj Teb!"

Hauv cov vis dis aus no, kuv yuav qhia koj yuav pib li cas nrog 0.91 (128x32) thiab 0.96 (128x64) I2C OLED cov lus.

Muaj 100s kev qhia ntawm lub vev xaib piav qhia tib yam hauv ntau txoj kev, tab sis kuv nrhiav tsis tau ib qho uas qhia kuv txhua yam txog OLED zaub thiab yuav siv nws li cas hauv ntau qhov xwm txheej. Nws coj kuv qee lub sijhawm los ua haujlwm tag nrho. Yog li, kuv xav tias kuv yuav tsum tsim cov lus qhia ntawm yam kuv tau kawm thiab muab tag nrho cov yam ntxwv thiab txoj hauv kev OLED cov lus tuaj yeem siv hauv peb cov phiaj xwm.

Kauj Ruam 1: Yam Peb Yuav Mus Kawm Hnub No

Yuav Tsum Tau Kho Vajtse
Yuav Tsum Tau Kho Vajtse

Hauv daim vis dis aus no peb yuav tham txog:

- Dab tsi yog OLED zaub?

- Tom qab ntawd peb yuav tau saib ze ze ntawm 0.91 (128x32) thiab 0.96 (128x64) I2C OLED cov lus

- Tom ntej no peb yuav tham txog kev txhim kho Adafruit Library rau koj Arduino IDE

- Tom qab ntawd peb yuav txuas NodeMCU thiab Arduino mus rau OLED zaub

- Tom ntej no peb yuav tau saib cov cai thiab tso tawm qee cov duab thiab cov ntawv ntawm nws

- Peb tseem yuav tham txog kev thov Kev Cai Fonts thiab tso duab

- Tom qab ntawd peb yuav txuas Ntau OLEDs rau lub micro-controller siv I2C Multiplexer

- Thaum kawg, peb yuav tham txog ob peb qhov yuam kev uas tib neeg ua thaum siv OLED cov lus

Kauj Ruam 2: Yuav Tsum Tau Kho Vajtse

Rau qhov kev qhia no peb xav tau:

- Ib daim ntawv qhia zaub mov

- 0.91 "(128x32) thiab 0.96" (128x64) I2C OLED cov lus

- Arduino UNO/NANO (txhua yam yog yooj yim)

- NodeMCU

TCA9548A I2C multiplexer

- Ob peb Txuas Cables

- thiab USB cable txhawm rau upload cov cai

Kauj Ruam 3: Dab tsi yog OLED Zaub?

Dab tsi yog OLED Zaub?
Dab tsi yog OLED Zaub?
Dab tsi yog OLED Zaub?
Dab tsi yog OLED Zaub?

OLED lossis cov teeb pom kev zoo ntawm lub teeb yog lub teeb ci

diode (LED) uas yog txheej txheej electroluminescent emissive yog zaj duab xis ntawm cov organic sib xyaw (ntau lab lub teeb LED me me) uas tso tawm lub teeb nyob rau hauv kev teb rau hluav taws xob tam sim no.

OLEDs tau siv los tsim cov duab digital hauv cov khoom siv xws li cov ntxaij vab tshaus TV, lub computer saib, lub tshuab nqa tau zoo xws li xov tooj ntawm tes, game game consoles thiab PDAs. OLED zaub ua haujlwm yam tsis muaj lub teeb pom kev rov qab vim nws tso lub teeb pom kev.

Kauj ruam 4:

Duab
Duab

Muaj ntau ntau hom OLED cov lus muaj nyob hauv

ua lag luam raws li lawv

- Qhov ntau thiab tsawg

- Xim

- Hom

- Raws tu qauv

- SPI (Serial Peripheral Interface) lossis I2C

-Passive-matrix (PMOLED) lossis nquag-matrix (AMOLED) kev tswj hwm

Hauv qhov kev qhia no, Kuv yuav tham txog kev txuas rau

xim xiav 0.91 (128x32 OLED) thiab 0.96 (128x64 OLED) I2C OLDE qhia rau Arduino NANO thiab NodeMCU. I2C tsheb npav thev naus laus zis siv tsuas yog 2 tus pin ntawm MCU yog li peb muaj heaps muaj rau lwm qhov ntsuas.

Kauj ruam 5: Kaw Zoo

Kaw Zoo
Kaw Zoo
Kaw Zoo
Kaw Zoo
Kaw Zoo
Kaw Zoo

Cia kom ze dua ntawm ob qhov kev qhia no.

Nyob tom qab ntawm cov lus qhia no muaj pob ntawm SMD cov khoom siv hluav taws xob thiab cov tshuaj tiv thaiv tau muab tso rau ntawm lub nkoj; tab sis, txij li nws yog lub cuab yeej I2C peb tsuas yog saib xyuas cov 2 pins (SCL thiab SDA)

Cov zaub txuas rau Arduino siv tsuas yog plaub lub xov hlau - ob rau lub zog (VCC thiab GND) thiab ob qho rau cov ntaub ntawv (cov xov tooj tseem ceeb SCL thiab

cov ntaub ntawv tseem ceeb SDA), ua rau cov xov hlau yooj yim heev. Cov ntaub ntawv sib txuas yog I2C (I²C, IIC lossis Inter-Integrated Circuit) thiab qhov kev sib txuas no tseem hu ua TWI (Two Wire Interface).

- Cov koob nyob ntawm lub rooj tsav xwm tuaj yeem sib txawv, yog li ib txwm kuaj xyuas ua ntej nqes nws mus rau koj qhov haujlwm.

- Lub zog ua haujlwm yog nruab nrab ntawm 3v txog 5v tab sis, nws yog qhov zoo tshaj plaws los siv cov lus qhia los ntawm cov chaw tsim khoom cov ntawv teev npe.

- Qee zaum peb yuav tsum siv 2 cov lus qhia hauv peb cov phiaj xwm. Yog li, peb tuaj yeem ua tiav qhov no li cas?

Qhov ua kom yuam kev yog kom muaj qhov chaw nyob teeb tsa tau ntawm koj cov zaub. Chav tsev no muaj chaw nyob teeb tsa tau ntawm 0x78 thiab 0x7A. Tsuas yog los ntawm qhov muag tsis pom qhov 0Ohm resistor los ntawm ib sab thiab sib txuas nws mus rau lwm sab lossis tsuas yog los ntawm kev muab lub ntiaj teb tso rau hauv lub ntiaj teb peb tuaj yeem hloov chaw nyob. Peb yuav tham txog nws hauv qhov tob thaum peb nqes ntau cov lus rau Arduino hauv ntu tom qab ntawm qhov kev qhia no.

Hauv daim duab cov duab no saib loj heev. Tab sis, xyaum hais lus lawv me me. Lawv tau ua los ntawm 128 x 32/64 tus kheej OLED pixels thiab tsis xav tau lub teeb rov qab. Tsuas yog saib ntawm no thiab pom tias nws me me li cas. Txawm hais tias lawv me me lawv tuaj yeem muaj txiaj ntsig zoo hauv txhua txoj haujlwm hluav taws xob.

Kauj Ruam 6: Tsev qiv ntawv

Tsev qiv ntawv
Tsev qiv ntawv
Tsev qiv ntawv
Tsev qiv ntawv
Tsev qiv ntawv
Tsev qiv ntawv

Muaj ntau lub tsev qiv ntawv muaj los tswj cov no

qhia. Yav dhau los kuv tau siv "u8glib library" tab sis kuv pom AdaFruit lub tsev qiv ntawv yooj yim nkag siab thiab siv hauv peb cov phiaj xwm. Yog li, kuv yuav siv lub tsev qiv ntawv AdaFruit hauv qhov kev qhia no.

Txhawm rau tswj cov zaub OLED koj yuav xav tau lub tsev qiv ntawv "adafruit_GFX.h" thiab "adafruit_SSD1306.h" lub tsev qiv ntawv.

Muaj ob txoj hauv kev koj tuaj yeem rub tawm thiab teeb tsa lub tsev qiv ntawv rau koj Arduino IDE.

Txoj Kev 1

Mus rau "Tus saib xyuas lub tsev qiv ntawv" thiab tshawb nrhiav "adafruit_SSD1306" thiab "adafruit_gfx"

Xaiv qhov tseeb version thiab ntaus lub pob Install.

Thaum teeb tsa koj tuaj yeem siv cov tsev qiv ntawv no hauv koj qhov program.

Txoj kev 2

Ob lub tsev qiv ntawv no tseem tuaj yeem rub tawm los ntawm github (koj xav tau ob qho tib si):

Kuv yuav muab cov kev txuas hauv cov lus piav qhia hauv qab no.

Cov tsev qiv ntawv tso saib:

Lub tsev qiv ntawv GFX:

Thaum rub tawm, theej Adafruit_SSD1306-master nplaub tshev los ntawm rub tawm cov ntawv zipped rau hauv Arduino cov tsev qiv ntawv nplaub tshev. Cov ntawv no feem ntau pom ntawm Cov Ntaub Ntawv> Arduino> cov tsev qiv ntawv ntawm Windows systems. Ntawm Linux nws feem ntau pom nyob hauv tsev nplaub tshev> Arduino> tsev qiv ntawv. Thaum kawg hauv Arduino lub tsev qiv ntawv tais ceev tseg, hloov npe Adafruit_SSD1306-tus tswv tais rau Adafruit_SSD1306. Txawm hais tias koj tsis hloov npe uas yog qhov zoo.

Kauj ruam 7:

Duab
Duab

Tam sim no, cia saib ntawm "Adafruit_SSD1306.h"

ntaub ntawv

Ob yam peb yuav tsum paub hauv lub tsev qiv ntawv no:

1. Yog tias koj xav siv cov zaub me me siv lub neej ntawd 128_32 txwv tsis pub siv rau cov lus pom loj dua 128_32 thiab tsis pom zoo rau 128_64

2. Yog tias koj tau siv lub 0x7A Chaw Nyob ntawm lub rooj tsavxwm (uas peb yuav tham txog tom qab) tom qab ntawd siv 7 me ntsis 0x3D chaw nyob rau cov lus loj dua, txwv tsis pub siv qhov qub 0x3C chaw nyob. Rau qhov me me qhia qhov chaw nyob yog 0x3C.

Kauj Ruam 8: Txuas 128 X 64/32 OLEDs

Txuas 128 X 64/32 OLEDs
Txuas 128 X 64/32 OLEDs

Cia pib los ntawm kev txuas NodeMCU rau cov zaub.

Thawj qhov tseem ceeb tshaj plaws uas yuav tsum tau nco yog tias qee qhov ntawm cov lus yuav muaj GND thiab VCC lub hwj huam khawm pauv nyob ib puag ncig. Txheeb xyuas koj cov zaub kom paub tseeb tias nws zoo ib yam li daim duab. Yog tias cov pins tau pauv, nco ntsoov hloov kev sib txuas mus rau Arduino lossis NodeMCU.

- NodeMCU OLED Txuas

OLED VCC - NodeMCU 3.3V

OLED GND - NodeMCU GND

OLED SCL - NodeMCU D1

OLED SDA - NodeMCU D2

- Arduino Uno OLED thaiv

OLED VCC - Arduino 5V

OLED GND - Arduino GND

OLED SCL - Arduino Uno A5

OLED SDA - Arduino Uno A4

- Arduino MEGA 2560 OLED thaiv

OLED VCC - Arduino 5V

OLED GND - Arduino GND

OLED SCL - Arduino MEGA 2560 tus pin 21

OLED SDA - Arduino MEGA 2560 tus pin 20

Kauj ruam 9: Code

Code
Code
Code
Code
Code
Code
Code
Code

Adafruit lub tsev qiv ntawv los nrog cov piv txwv zoo tiag tiag rau ob leeg

128x32 thiab 128x64 zaub.

Lub Tsev Qiv Ntawv nyob hauv Cov Ntaub Ntawv> Piv Txwv> Adafruit SSD1306> thiab tom qab ntawd tso saib hom hauv Arduino IDE.

Peb yuav siv qhov piv txwv 128x32 I2C thiab yuav hloov kho nws kom ua haujlwm nrog ob qho tib si 128x64 thiab 128x32 qhia nrig los ntawm kev nqes nws mus rau Arduino thiab tom qab ntawd mus rau NodeMCU pawg thawj coj.

Txoj cai pib los ntawm suav nrog ob lub tsev qiv ntawv Adafruit. Hauv qhov kev qhia no kuv yuav ua rau muaj kev nyuab siab rau tsuas yog ib feem ntawm cov cai uas tsim nyog rau peb kom thauj khoom ntawm ob lub rooj thiab cov lus. Yog tias koj xav paub ntau ntxiv txog cov cai thov tso lus tawm ntawm kuv qhov blog lossis hauv cov lus hauv qab no thiab kuv ua siab ntev rov qab los rau koj.

- Ua ntej peb yuav thauj cov cai mus rau Arduino Nano txuas nrog rau 128x32 zaub.

Peb tuaj yeem siv cov cai raws li tsis muaj kev hloov kho.

128x32 siv 0x3C chaw nyob yog li qhov me ntsis zoo li txhua qhov ntawm no, cia ob npaug xyuas lub tsev qiv ntawv header, yog nws tseem siv 0x3C chaw nyob thiab hom zaub yog 128x32.

- Tam sim no cia txuas 128x64 zaub. Raws li peb paub nws siv 0x3C chaw nyob los ntawm lub hauv paus yog li peb tsis tas yuav hloov chaw nyob hauv ob qho chaws lossis lub tsev qiv ntawv.

Peb tsuas yog xav tau peb yuav tsum tawm tswv yim 128_32 thiab tsis pom zoo 128_64 hauv lub tsev qiv ntawv header thiab hloov LCDHEIGHT rau 64 hauv peb cov cai.

- Tam sim no kom ua tib txoj cai ntawm NodeMCU peb yuav tsum hloov ib kab ntxiv hauv peb cov cai.

Qhov "#define OLED_RESET 4"> "#define OLED_RESET LED_BUILTIN" seem ntawm cov cai yog tib yam li Arduino

Zoo nkauj npaum li cas los tso saib txhua yam peb xub xav tau los tshem lub vijtsam dhau los siv

display.clearDisplay (); // Tshem qhov tsis

Tom qab ntawd kos cov khoom

testdrawline (); cov // Kos kab

Qhia nws ntawm qhov kho vajtse

display.display (); // Ua rau lawv pom ntawm cov khoom kho vajtse!

Tos qee lub sijhawm ua ntej tso tawm cov khoom tom ntej.

ncua (2000); // Tos 2 feeb

Hauv qhov piv txwv no peb tab tom nthuav tawm ob peb yam khoom xws li ntawv, kab, voj voog, nqes kab ntawv, daim duab peb sab thiab ntau ntxiv. Mus tom ntej thiab siv koj lub tswv yim thiab tso saib txhua yam koj xav tau ntawm cov lus me me no.

Kauj ruam 10: Customizing Text & Ntxiv Duab

Customizing Text & Ntxiv Cov Duab
Customizing Text & Ntxiv Cov Duab
Customizing Text & Ntxiv Cov Duab
Customizing Text & Ntxiv Cov Duab
Customizing Text & Ntxiv Cov Duab
Customizing Text & Ntxiv Cov Duab

Qee lub sij hawm koj cov cai xav tau los teeb tsa cov ntawv tshwj xeeb thiab

duab Yog tias koj ua tau zoo heev hauv kev qhia me ntsis ces koj tsuas yog yuav tsum tsim cov byte arrays los ntawm kev qhib lossis tua cov LEDs me me ntawm cov zaub los tsim kev cai fonts thiab cov duab.

Txawm li cas los xij, Kuv tsis zoo heev hauv kev ua daim ntawv qhia no thiab tsis xav siv sijhawm teev los tsim cov lus qhia me me.

Yog li, kuv cov kev xaiv yog dab tsi? Kuv feem ntau siv ob lub vev xaib los tsim kev cai fonts thiab cov duab. Cov kev sib txuas tau muab rau hauv cov lus piav qhia hauv qab no.

Kev cai Fonts

Mus rau lub vev xaib hloov pauv font, xaiv tsev neeg font, style, loj, Library Version li "Adafruit GFX Font" thiab tom qab ntawv nyem "Tsim". Ntawm sab xis ntawm nplooj ntawv no koj tuaj yeem pom yuav ua li cas koj daim ntawv yuav zoo li ntawm qhov pom tseeb.

Raws li koj xaiv lub vev xaib tsim cov ntawv fonts header file. Tsim cov ntawv hu ua "modified_font.h" hauv tib daim nplaub tshev uas koj tus lej yog thiab luam thiab khaws thiab tsim cov cai tsim rau hauv. Tom qab ntawd koj tsuas yog xav tau suav nrog cov ntawv header hauv koj cov cai kom siv cov ntawv raug cai.

#suav nrog "modified_font.h"

Tom qab ntawd, koj tsuas yog yuav tsum teeb tsa tus tsiaj ntawv ua ntej tso tawm cov ntawv kom siv tus qauv kev cai rau nws.

display.setFont (& Koj_Fonts_Name);

Koj tuaj yeem tau txais lub npe ntawm tus ntawv los ntawm cov ntawv header koj nyuam qhuav ntxiv rau koj qhov haujlwm. Tias nws, yooj yim.

Nco ib txwm muaj kev txhawj xeeb thaum siv kev cai fonts, yog li nco ntsoov txiav txim siab bytes uas yuav siv los ntawm lub cim xeeb. Tsuas nco ntsoov Arduino UNO tsuas muaj 32K ntawm kev nco.

Kev Cai Duab

Txhawm rau tso duab me me ntawm koj lub vijtsam koj thawj zaug yuav tsum tsim cov duab 128 x 64/32.

Kuv siv qhov qub "MS Paint" los tsim cov duab 128 x 64 bitmap uas kuv yuav muab tso rau hauv lub vev xaib hloov duab no. Lub vev xaib hloov cov duab rau hauv byte-hlua, uas tuaj yeem siv nrog Arduino thiab OLED cov lus.

Pib los ntawm upload cov duab rau lub vev xaib. Tom qab ntawv khij lub npov "Hloov cov duab xim" thiab hloov "Cov qauv tsim tawm" mus rau "Arduino Code" tom ntej xaiv qhov kev taw qhia thiab ntaus lub "Tsim Code" khawm los tsim cov byte array. Tshooj "Saib Ua Ntej" qhia koj li cas koj cov duab yuav zoo li ntawm qhov pom tseeb.

Kuv tau suav nrog cov cai nrog rau qhov kev qhia no uas koj tuaj yeem siv los tso saib koj cov duab. Koj tsuas yog yuav tsum tau hloov cov kab hauv kuv cov lej nrog qhov koj nyuam qhuav tsim thiab tom qab ntawd thauj nws mus rau koj Arduino.

Kauj Ruam 11: Txuas 2 Cov Lus Qhia

Txuas 2 Cov Lus Qhia
Txuas 2 Cov Lus Qhia
Txuas 2 Cov Lus Qhia
Txuas 2 Cov Lus Qhia

Txuas ob 128 x 64 cov lus rau koj qhov haujlwm yog yooj yim.

Koj tsuas yog yuav tsum tau tshem lub 0Ohm resistor los ntawm 0x78 chaw nyob thiab muab tso rau 0x7A thiab tom qab ntawd siv 0x3D chaw nyob hauv koj tus lej hloov pauv 0x3C.

Koj yuav tsum xav tsis thoob vim li cas peb thiaj siv 0x3C thiab 0x3D chaw nyob thiab tsis yog qhov tseeb 0x78 thiab 0x7A. Arduino lees txais 7-ntsis chaw nyob thiab tsis yog 8-ntsis kho vajtse chaw nyob. Yog li, thawj zaug peb yuav tsum hloov qhov chaw nyob 8-ntsis mus rau binary, thiab tom qab ntawd txiav tawm qhov tseem ceeb me ntsis kom tau txais 7 khoom. Tom qab ntawd hloov 7 khoom mus rau HEX kom tau txais 0x3C lossis 0x3D chaw nyob uas koj nkag mus rau hauv koj tus lej.

Ua ntej, pib ua zaub los ntawm muab nws lub npe tshwj xeeb:

Adafruit_SSD1306 display1 (OLED_REST);

Adafruit_SSD1306 display2 (OLED_REST);

Tom qab ntawd hauv koj cov cai siv cov zaub 1 thiab tso saib 2 kom hu cov lus pib nrog cov cuab yeej chaw nyob hauv lawv:

display1.begin (SSD1306_SWITCHCAPVCC, 0x3C); // tso saib 1 qhov chaw nyob 0x3C

display2.begin (SSD1306_SWITCHCAPVCC, 0x3D); // tso saib 2 qhov chaw nyob 0x3D

Yog li ntawd, tam sim no koj tuaj yeem mus tom ntej thiab ua txhua yam uas koj xav tau siv Zaub 1 lossis Zaub 2 hauv koj tus lej seem. Kuv tau muab piv txwv nrog qhov kev qhia no.

Kev xaim hluav taws xob zoo ib yam li peb tau ua dhau los, zoo nkauj npaum li koj tsuas yog xav tau ntxiv lwm cov khoom rau tib I2C pins ntawm Arduino lossis NodeMCU. Raws li qhov chaw nyob, MCU tom qab ntawd xa cov ntaub ntawv ntawm kab I2C cov ntaub ntawv.

Kauj Ruam 12: Txuas Ntau Tshaj 2 Cov Lus Qhia

Txuas Ntau Tshaj 2 Cov Lus Qhia
Txuas Ntau Tshaj 2 Cov Lus Qhia
Txuas Ntau Tshaj 2 Cov Lus Qhia
Txuas Ntau Tshaj 2 Cov Lus Qhia
Txuas Ntau Tshaj 2 Cov Lus Qhia
Txuas Ntau Tshaj 2 Cov Lus Qhia

Tam sim no, yuav ua li cas yog tias koj xav kom nqes ntau dua 2 cov lus?

Arduino muaj tus lej tsawg tus lej thiab yog li koj tsis tuaj yeem muaj ntau dua li qee yam ntawm cov ntaub thaiv npog txuas rau nws. Ntxiv mus, nws tsuas muaj ib khub ntawm I2C tsheb npav.

Yog li, peb tuaj yeem txuas ntau dua 2 I2C cov lus rau Arduino li cas? Qhov ua kom yuam kev yog siv TCA9548 Multiplexer.

TCA9548 tso cai rau ib tus tswj hwm micro sib txuas lus nrog txog '64 sensors 'txhua qhov nrog tib lossis sib txawv I2C chaw nyob los ntawm kev xa ib lub channel tshwj xeeb rau txhua tus sensor qhev sub-bus.

Thaum peb tham txog kev xa cov ntaub ntawv hla 2 xov hlau mus rau ntau lub cuab yeej peb yuav xav tau txoj hauv kev los daws lawv. Nws zoo ib yam li tus kws xa ntawv tuaj ntawm ib txoj kev thiab xa cov ntawv xa mus rau ntau lub tsev vim tias lawv muaj chaw nyob sib txawv sau rau ntawm lawv.

Multiplexer txuas rau 3V3, GND, SDA thiab SCL kab ntawm lub micro-controller. Cov ntsuas tus qhev tau txuas nrog ib ntawm yim SCL/SDA qhev chaw nres nkoj ntawm lub rooj tsavxwm. Cov channel raug xaiv los ntawm kev xa TCA9548A nws qhov chaw nyob I2C (0x70 {default} - 0x77) ua raws los ntawm tus lej channel (0b00000001 - 0b10000000). Koj tuaj yeem muaj qhov siab kawg 8 ntawm cov sib txuas sib txuas ua ke ntawm 0x70-0x77 chaw nyob txhawm rau txhawm rau tswj 64 ntawm tib I2C hais qhov chaw. Los ntawm kev txuas peb qhov chaw nyob A0, A1 thiab A2 rau VIN koj tuaj yeem tau txais kev sib txawv ntawm cov chaw nyob. Kuv yuav piav qhia qhov tob hauv kuv qhov kev qhia tom ntej ntawm TCA9548A pawg thawj coj tawm. Txog tam sim no, cia cia li nqes 8 OLEDs rau lub rooj tsavxwm no thiab saib sai ntawm cov cai.

Kev sib txuas:

VIN rau 5V (lossis 3.3V)

GND rau hauv av

SCL rau I2C moos

Kev lees paub rau lub dav hlau C -SDA data

Tom qab ntawd xaim lub ntsuas hluav taws xob mus rau VIN, GND thiab siv ib qho ntawm SCn / SDn cov npav sib tw

Tam sim no, Int txoj cai cia pib los ntawm suav nrog lub tsev qiv ntawv "Hlau" thiab los ntawm kev txhais cov chaw nyob ntau ntxiv.

#suav nrog "Wire.h"

#suav nrog

#define MUX_Address 0x70 // TCA9548A Encoders address

Tom qab ntawd peb yuav tsum xaiv qhov chaw nres nkoj peb xav sib txuas lus rau thiab xa cov ntaub ntawv ntawm nws siv txoj haujlwm no:

void tcaselect (uint8_t kuv) {

yog tias (i> 7) rov qab;

Wire.beginTransmission (MUX_Address);

Wire.write (1 << kuv);

Wire.endTransmission ();

}

Tom ntej no peb yuav pib ua cov zaub hauv ntu teeb tsa los ntawm kev hu "u8g.begin ();" rau txhua cov duab txuas rau MUX "tcaselect (i);"

Thaum pib ua ntej, peb tuaj yeem ua txhua yam peb xav tau tsuas yog hu rau lub luag haujlwm "tcaselect (i);" qhov twg "i" yog tus nqi ntawm cov npav sib tw thiab tom qab ntawd xa cov ntaub ntawv thiab lub sijhawm raws li.

Kauj Ruam 13: Qhov Zoo thiab Qhov Tsis Zoo

Qhov Zoo thiab Qhov Tsis Zoo
Qhov Zoo thiab Qhov Tsis Zoo

Cov duab ntawm OLED zoo nkauj heev. Txawm li cas los xij, OLEDs tseem muaj

tsis zoo. Vim tias cov ntxaij vab tshaus OLED muaj cov khoom siv organic, lawv lub neej luv dua li cov duab LCD. Ib qho ntxiv, ntau OLED cov lus tau hlawv-tom qab pom tib daim duab ntev. Tom qab hlawv-hauv, cov duab nyob ntawm lub vijtsam txawm tias tom qab pom lwm daim duab. Yog li xyuas kom koj ua kom lub vijtsam rov qab zoo dua txhua ob peb feeb. Dej tuaj yeem ua rau puas cov khoom siv organic ntawm cov lus qhia tam sim.

Zoo

Tsis xav tau lub teeb pom kev

Cov zaub yog nyias thiab hnyav heev

Tsawg zog siv

Saib cov ces kaum yog dav dua LCDs

Brightness thiab sib piv yog qhov zoo

Kev kub ceev thiab muaj sijhawm teb tsawg

Cov xim dub sib sib zog nqus

Tsis zoo

Nqi siv tshuab

Lub neej luv

OLEDS feem ntau yuav hlawv-hauv

Dej puas

Kauj Ruam 14: Cov Yuam Kev Tsis Zoo

Tsis raug
Tsis raug

Txhawm rau xaus qhov kev qhia cia tham txog ob peb qhov ua yuam kev

tib neeg ua thaum siv cov lus qhia no:

- Ib txwm triple tshuaj xyuas tus pin ua ntej siv nws hauv koj qhov project

- Xaiv qhov chaw nyob lub tsev qiv ntawv raug hauv kab ntawv header thiab hauv koj tus lej

#define SSD1306_I2C_ADDRESS 0x3C // hauv Adafruit_SSD1306.h

thiab

display.begin (SSD1306_SWITCHCAPVCC, 0x3C); // hauv koj qhov chaws

Yog tias qhov chaw nyob tsis raug OLED yuav tsis tshwm ib qho

- Cov zaub loj yuav tsum tau hloov pauv hauv tus tsav tsheb ua ntej nws tuaj yeem siv tau. Yog tias nws tsis raug hloov pauv koj yuav tau txais cov lus yuam kev thaum sim txheeb xyuas qhov chaws

#error ("Qhov siab tsis raug, thov kho Adafruit_SSD1306.h!");

- Yog tias siv NodeMCU nco ntsoov koj hloov OLED_RESET los ntawm 4 rau LED_BUILTIN

#define OLED_RESET LED_BUILTIN

Kuv muaj cov neeg ua yeeb yam ua txhua yam uas siv cov zaub OLED no. Qee leej txawm tau ua video games thiab txhua yam. Kuv yeej tsis txaus siab ua qhov vis dis aus siv qhov khoom me me no. Txawm li cas los xij, tam sim no kuv yuav tso koj mus tshawb koj cov kev xav thiab tawm nrog cov tswv yim zoo.

Kauj ruam 15: Txuas

- Blog:

- Ntxiv Duab:

- Cov ntawv raug cai:

- Adafruit tso saib lub tsev qiv ntawv:

-Adafruit GFX lub tsev qiv ntawv:

- u8glib tsev qiv ntawv: https://code.google.com/archive/p/u8glib/ lossis

Yog tias koj xav siv lub vijtsam me me siv lub neej ntawd 128_32 txwv tsis pub siv lub ntsej muag loj dua saib 128_32 thiab tsis pom zoo 128X64 NO_ACK hauv koj tus lej (tsuas yog tsis suav nrog hom vijtsam uas koj siv) (fonts nyob hauv fonts library)

Pom zoo: