Cov txheej txheem:

Cov duab ntawm SSD1306 I2C OLED 128x64 Zaub Nrog CircuitPython Siv Itsybitsy M4 Express: 13 Kauj Ruam (nrog Duab)
Cov duab ntawm SSD1306 I2C OLED 128x64 Zaub Nrog CircuitPython Siv Itsybitsy M4 Express: 13 Kauj Ruam (nrog Duab)

Video: Cov duab ntawm SSD1306 I2C OLED 128x64 Zaub Nrog CircuitPython Siv Itsybitsy M4 Express: 13 Kauj Ruam (nrog Duab)

Video: Cov duab ntawm SSD1306 I2C OLED 128x64 Zaub Nrog CircuitPython Siv Itsybitsy M4 Express: 13 Kauj Ruam (nrog Duab)
Video: SH1106 128x64 OLED display and u8glib graphics library 2024, Hlis ntuj nqeg
Anonim
Cov duab ntawm SSD1306 I2C OLED 128x64 Zaub Nrog CircuitPython Siv Itsybitsy M4 Express
Cov duab ntawm SSD1306 I2C OLED 128x64 Zaub Nrog CircuitPython Siv Itsybitsy M4 Express

SSD1306 OLED zaub yog qhov me me (0.96 ), pheej yig, muaj dav, I2C, cov duab duab ib leeg nrog 128x64 pixels, uas yooj yim cuam tshuam (tsuas yog 4 kab) rau microprocessor kev txhim kho cov laug cam xws li Raspberry Pi, Arduino lossis Adafruit Itsybitsy M4 Express, CircuitPlayground Express lossis lwm yam CircuitPython cov cuab yeej. Cov tsav tsheb tuaj yeem rub tawm los ntawm is taws nem.

Cov duab niaj hnub rau Arduinos tau muaj rau qee lub sijhawm tab sis tsis yog rau lwm txoj hauv kev txhim kho.

Cov cuab yeej tsav tsheb yooj yim tso cai rau cov neeg siv:

  • Tshem qhov screen rau dub lossis dawb. oled.fill (c)
  • Sau kab ntawv mus rau qhov screen ntawm qhov tshwj xeeb (x, y) txoj haujlwm oled.text ("Ntawv", x, y, c)
  • Kos tus lej ntawm qhov teev tseg (x, y) txoj haujlwm oled.pixel (x, y, c)
  • Thauj ib daim duab rau ntawm qhov screen. (Tsis siv hauv qhov haujlwm no)
  • Hloov kho cov zaub oled.show ()

Cov Lus Qhia no yuav qhia, nrog cov txheej txheem yooj yim, yuav kos li cas, sib cuam tshuam:

  • kab
  • voj voog
  • thawv thawv
  • khoom thaiv
  • cov cim ua ntej

Kuv yuav siv Adafruit Itsybitsy M4 Express los qhia cov txheej txheem tab sis cov cai, hauv Python, tuaj yeem yooj yim xa mus rau lwm qhov kev txhim kho.

Kuv tau xaiv Itsybitsy M4 rau qhov ua qauv qhia no vim tias nws pheej yig, muaj zog, yooj yim rau txoj haujlwm, suav nrog kev sib piv thiab cov tswv yim/tawm tswv yim, muaj lub cim xeeb ntau, tau yooj yim nrhiav cov ntaub ntawv thiab pab kev sib tham hauv Is Taws Nem, yooj yim heev los teeb tsa thaum pib. thiab txhawb nqa CircuitPython, version ntawm Python zoo tagnrho rau cov tshiab rau coding.

Thaum koj tau teeb tsa koj li Itsybitsy thiab SSD1306 qhov no yog ib qho yooj yim heev ua mov ci tsim. Tsis muaj kev ntaus ntawv, txhua cov ntaub ntawv tuaj yeem rub tawm.

Nov yog qhov pheej yig thiab txoj haujlwm yooj yim los tsim tab sis qhia qee cov tswv yim nruab nrab/qib siab. Kuv vam tias koj yuav muab nws sim. Kuv zoo siab nrog cov zaub me me no.

Kauj Ruam 1: Yam Peb Xav Tau rau Txoj Haujlwm no

Yam Peb Xav Tau rau Txoj Haujlwm no
Yam Peb Xav Tau rau Txoj Haujlwm no

Kho vajtse:

  • SSD1306 I2C mono zaub 128x64 pixels
  • Itsybitsy M4 nthuav qhia
  • microUSB rau USB cable - rau program lub rooj tsavxwm
  • Cov qhob cij
  • 1 10K Ohm potentiometer
  • 1 khawm hloov
  • txuas xov hlau - ntau yam xim tuaj yeem pab tau
  • Khoos phis tawj (txhawm rau sau cov cai thiab xa nws mus) - lub laptop qub heev yuav ua.

Software:

Mu editor - rau kev sau cov cai thiab xa cov ntawv mus rau Itsybitsy

Teeb tsa Itsybitsy tau piav qhia ntawm no:

Qhov hloov tshiab kawg ntawm CircuitPython:

Cov tsev qiv ntawv CircuitPython:

Mu Editor:

Kauj ruam 2: Circuit Court

Qhov Circuit
Qhov Circuit

Nov yog lub voj voog yooj yim heev los teeb tsa. Nplooj ntawv tom ntej qhia txog daim ntawv qhia zaub mov tiav nrog cov xaim xim ua kom yooj yim.

Kauj Ruam 3: Breadboard Version ntawm Circuit

Breadboard Version ntawm Circuit
Breadboard Version ntawm Circuit

Muaj cov ntsia fais fab nyob rau sab saum toj thiab hauv qab ntawm daim ntawv qhia zaub mov. Nrog xaim liab koom nrog +ve txoj kab ua ke. Nrog cov xaim dub koom nrog -ve cov ntsia ua ke.

Koom nrog 3V tus pin ntawm Itsybitsy mus rau qis dua +ve tsheb nqaj hlau - xaim liab. (Kab 12)

Koom nrog G (GND) tus pin ntawm Itsybitsy mus rau saum -v txoj kev tsheb ciav hlau - xaim dub. (Kab 12)

Hauv kab 33 thiab 34, txuas SSD1306 VCC thiab GND pins rau sab saum toj ntawm txoj kab hluav taws xob.

Nrog cov xov paj liab koom nrog SCL koob ua ke.

Nrog cov xaim grey koom nrog SDA tus pin ua ke.

Nrog cov xov hlau liab thiab dub txuas cov pins sab nraud ntawm lub zog hluav taws xob mus rau txoj kab hluav taws xob sab saud thiab nrog cov xaim ntsuab txuas lub hauv paus (wiper) tus pin rau A5 ntawm Itsybitsy.

Txuas ib sab ntawm lub khawm hloov nrog cov xaim xaim rau tus pin 2 thiab nrog xaim dub txuas lwm sab mus rau GND tsheb nqaj hlau.

Kauj ruam 4: Loading Font

Loading Font
Loading Font

Rub tawm cov ntawv font thiab rub nws mus rau CIRCUITPY tsav. (Qhov no yog Itsybitsy.)

Ob npaug nias rau lub nplaub tshev lib thiab saib cov npe ntawm cov tsav tsheb uas koj twb tau thauj khoom lawm.

Kauj Ruam 5: Ntxiv Cov Tsav Tsheb Ntxiv

Ntxiv Cov Tsav Tsheb Ntxiv
Ntxiv Cov Tsav Tsheb Ntxiv

Koj yuav xav tau cov hauv qab no hauv cov ntawv tais ceev tseg lib:

  • simpleio.mpy
  • adafruit_bus_device
  • adafruit_framebuf.mpy
  • adafruit_ssd1306.mpy

Yog tias lawv ploj lawm, rub lawv mus rau hauv daim nplaub tshev los ntawm qhov hloov tshiab kawg muaj.

Tam sim no koj tau npaj los rub cov ntawv.

Thaum thauj mus rau hauv Mu editor koj tuaj yeem txuag nws mus rau Itsybitsy nrog lub npe main.py.

Qhov kev zov me nyuam ua haujlwm dhau los ntawm kev ua qauv qhia ntawm kab, lub voj voos, kab teeb pom kev zoo thiab nthuav qhia cov cim. Tsuas yog tig lub lauj kaub maj mam thiab nias thiab tuav lub pob kom tswj cov zaub.

Cov nplooj ntawv hauv qab no muab cov ntaub ntawv ntau ntxiv txog qhov kev zov me nyuam ua haujlwm li cas.

Kauj Ruam 6: Teeb Cov Khoom Siv

Teeb Devices
Teeb Devices

Thawj ntu no thauj tag nrho cov tsev qiv ntawv thiab teeb tsa SSD1306, lub hwj chim thiab lub pob hloov ntawm tus pin raug.

Kauj Ruam 7: Txheeb Cov Cim thiab Kos Kab Kab Kab thiab Kab Ntsig

Txheeb Cov Cim thiab Kos Kab Kab Kab thiab Kab Ntsig
Txheeb Cov Cim thiab Kos Kab Kab Kab thiab Kab Ntsig
Txhais Cov Cim thiab Kos Kab Kab Kab thiab Kab Ntsig
Txhais Cov Cim thiab Kos Kab Kab Kab thiab Kab Ntsig

Seem no teeb tsa cov cim ua ntej. Lawv yog 5 dots dav thiab 8 dots siab. Txhua tus dot hauv qhov txhais tau kos 4 tus lej ntawm qhov screen kom lawv pom zoo dua.

Kab rov tav thiab kab ntsug tau yooj yim kos nrog lub voj. Koj tsuas yog yuav tsum nco ntsoov tias koj xav tau cov cim ntxiv ntawm qhov kawg. Ib kab los ntawm (0, 7) txog (5, 7) yuav xav tau 6 tus ntawv: nrog x sib npaug 0, 1, 2, 3, 4 thiab 5 nyob rau hauv lem.

Qhov yooj yim teev cov lus txib yog oled.pixel (x, y, xim) - 0 yog dub thiab 1 yog dawb.

Lub hauv paus chiv keeb (0, 0) yog nyob rau sab laug sab saum toj ntawm lub vijtsam, 0 - 127 pixels kab rov tav (sab laug mus rau sab xis) thiab 0 - 63 ntsug (saum toj mus rau hauv qab).

Kauj Ruam 8: Cov Thawv, Cov Thaiv thiab Cov Kab Txim

Thawv, Thaiv thiab Kab Kab
Thawv, Thaiv thiab Kab Kab

Cov thawv yog tsim los ntawm kab rov tav thiab ntsug.

Thaiv tau tsim los ntawm ntau kab kab rov tav.

Rau txoj kab nqes peb xub txheeb xyuas qhov ua haujlwm tau muab tso rau feem ntau ua ntej. Yog tsis yog peb pauv lawv raws li kab yuav kos los ntawm sab laug mus rau sab xis.

Tom qab ntawd peb suav qhov nqes hav thiab siv nws los teeb tus nqi y rau txhua tus nqi ntawm x.

Cov txheej txheem tso saib (t) ua rau lub vijtsam hloov tshiab pom thiab tos kom ncua sijhawm luv, t vib nas this.

Kauj Ruam 9: Daim Ntawv Pov Thawj Kawm Ntawv, Kev Tsis Txaus Siab, Bar Graph thiab Vajvoog

Cov Cim Cim, Kev Tsis Txaus Siab, Bar Graph thiab Vajvoog
Cov Cim Cim, Kev Tsis Txaus Siab, Bar Graph thiab Vajvoog

Lub cim qib yog tsim los ntawm 4 pixels.

Qhov sib dhos () niaj hnub ntxiv qhov chaw ntxiv nyob rau hauv pem hauv ntej ntawm tus lej kom ncaj ncaj qhov tseem ceeb hauv qhov chaw ruaj khov.

Cov duab kab (v) niaj hnub kos kab duab kab rov tav muab qhov feem pua xaiv. Tus nqi tau sau ntawm sab tes xis kawg siv 'T' los sawv cev 100 (Tuj lossis Tshaj).

Cov voj voos xav tau qee qhov trigonometry yog li peb yuav tsum tau xa cov tsev qiv ntawv ua lej thaum pib ntawm tsab ntawv. Peb siv kev txhaum, cos thiab radians los xam x thiab y offsets los ntawm qhov chaw raws li lub vojvoog tau tig los ntawm 90 degrees. Cov ntsiab lus tau npaj rau hauv txhua ntawm plaub qhov quadrants rau txhua qhov kev suav ntawm cov offsets.

Kauj Ruam 10: Khaws Khib Nyiab, Lub Npe thiab Lub Vev Xaib

Khib Nyiab, Cov Npe thiab Cov Vajvoog
Khib Nyiab, Cov Npe thiab Cov Vajvoog

Cov lus qhia no qhia pom kev tshuaj ntsuam kom pom cov xim dub thiab dawb, sau cov ntawv rau ntawm lub vijtsam thiab siv gc () 'khaws cov khib nyiab' ua ntu zus kom tsis txhob muaj chaw seem. Tus nqi qhia tau tias muaj chaw txaus rau tsab ntawv loj dua.

Qhov kev zov me nyuam rub cov voj voog nrog ib qho chaw sib koom thiab nrog cov chaw txav chaw. Ib qho yooj yim heev niaj hnub txiav txim siab qhov nyiaj yuav tsum tau ua.

Cov ncauj lus rau kab kab demo tau sau tom ntej.

Kauj ruam 11: Kab Demo

Kab Demo
Kab Demo

Txoj haujlwm no yeej muab txoj kab () niaj hnub ua haujlwm. Cov kab hluav taws xob tau kos los ntawm txhua ntawm plaub lub ces kaum ntawm cov zaub nrog qhov sib txawv sib txawv tsim cov qauv.

Kauj Ruam 12: Lub Loop Loj: Bar Graph thiab Cov Cim Cim

Lub Loop Loj: Bar Teeb thiab Cov Cim Cim
Lub Loop Loj: Bar Teeb thiab Cov Cim Cim

Nov yog lub ntsiab lus tseem ceeb ntawm txoj haujlwm. Qhov muaj txiaj ntsig los ntawm lub hwj chim hloov pauv qhov txiaj ntsig tau qhia thiab hloov qhov ntev ntawm kab duab kab.

Yog tias lub pob tau tuav tseg cov cim uas tau pauv pauv zoo ib yam li 1/0 thiab Tseeb/Tsis raug. Lub voj no ua haujlwm qeeb qeeb vim tias kos cov cim ua ntej tau piav qhia yog txheej txheem qeeb. Koj tuaj yeem ua kom nrawm dua los ntawm kev tawm tswv yim qee yam ntawm lawv.

Yog tsis muaj qhov ntsuas kub ntsuas kom haum, kom ua qhov yooj yim no, yog li '?' tau tshwm sim hloov pauv tus nqi hauv kab 190.

Pom zoo: