Cov txheej txheem:

Custom Character Generator (Adafruit HT16k33 Matrix): 3 Kauj Ruam
Custom Character Generator (Adafruit HT16k33 Matrix): 3 Kauj Ruam

Video: Custom Character Generator (Adafruit HT16k33 Matrix): 3 Kauj Ruam

Video: Custom Character Generator (Adafruit HT16k33 Matrix): 3 Kauj Ruam
Video: Adding a push button matrix to HT16K33 led display modules (featuring the TinyPICO) 2024, Kaum ib hlis
Anonim
Kev Tsim Tus Cwj Pwm (Adafruit HT16k33 Matrix)
Kev Tsim Tus Cwj Pwm (Adafruit HT16k33 Matrix)

Luam Ntawv Tus Kheej Tshwj Xeeb ntawm LCDs thiab Led Matrices yog qhov lom zem heev. Cov txheej txheem luam tawm cov cim tshwj xeeb lossis cov cim tshwj xeeb yog tsim kom muaj cov kab nrog cov lej binary rau txhua kab thiab kab. Tej zaum nws yuav nyuaj rau nrhiav txoj cai raug rau txhua tus cim kev cai, yog li no, txoj haujlwm no yuav siv lub tshuab thiab tsim cov cai rau 8x8 coj matrix thiab tseem yuav luam tawm tus cim kev cai ntawm Adafruit HT16k33 8x8 Bicolor Matrix.

Adafruit HT16k33, 1.2 `` 8x8 Bicolor Led Matrix sib tham nrog Arduino ntawm I2C kev sib txuas lus raws tu qauv

Raws li Adafruit, "Qhov no ntawm lub hnab ev ntawv LED tau tsim los rau 1.2" 8x8 matrices. Lawv ntsuas tsuas yog 1.2 "x1.2" yog li nws yog kev txaj muag los siv ntau qhov loj ntawm cov chips los tswj nws. Lub hnab ev ntawv daws qhov kev thab plaub ntawm kev siv 16 tus pin lossis ib pawg ntawm cov chips los ntawm kev muaj I2C qhov tsis tu ncua-tam sim no matrix maub los zaum zoo nyob tom qab ntawm PCB. Tus tswj hwm lub ntsej muag saib xyuas txhua yam, kos tag nrho 64 LEDs hauv keeb kwm yav dhau. Txhua yam koj yuav tsum ua yog sau cov ntaub ntawv rau nws siv 2-pin I2C interface. Muaj ob qhov chaw nyob xaiv tus pin yog li koj tuaj yeem xaiv ib ntawm 8 qhov chaw nyob kom tswj tau txog 8 ntawm cov no ntawm ib tus lej 2-pin I2C npav (nrog rau lwm yam I2C chips lossis cov cim uas koj nyiam). Tus neeg tsav tsheb nti tuaj yeem 'dim' tag nrho cov zaub los ntawm 1/16 ci ntsa iab mus txog qhov ci tag nrho hauv 1/16 qib. Nws tsis tuaj yeem dim tus kheej LEDs, tsuas yog tso saib tag nrho ib zaug."

Hauv cov lus qhia no, kuv yuav piav qhia rau koj yuav ua li cas kom tau txais cov cai rau txhua tus cwj pwm hauv lub sijhawm tiag tiag thiab luam tawm tus cim ntawm Led Matrix.

Kauj Ruam 1: Cheeb Tsam

Cov lus qhia no yog txoj haujlwm yooj yim ntawm Adafruit HT16k33 Matrix. Koj xav tau:

  1. Adafruit HT16k33 1.2 `` x 1.2 '' 8x8 Bicolor Led Matrix.
  2. Arduino (ib qho kev hloov pauv tab sis Uno nyiam dua).
  3. Cov qhob cij
  4. Hwj chim Mov

Kauj ruam 2: Schematic

Schematic
Schematic
Schematic
Schematic

Kev Txuas Adafruit HT16k33 Led matrix yog qhov yooj yim heev raws li peb xav tau txuas lub moos thiab cov ntaub ntawv tus pin raws li peb ib txwm ua rau I2C cov cuab yeej. Kev sib txuas yuav zoo li:

  1. SCL (Tus pin tus lej ntawm Matrix) txuas nrog A5 (Tus pin tus pin ntawm Arduino Uno. Xa cov ntaub ntawv rau lwm yam kev hloov pauv ntawm Arduino)
  2. SDA (Cov ntaub ntawv tus lej ntawm Matrix) txuas nrog A4. (Xa cov ntaub ntawv rau lwm qhov sib txawv ntawm Arduino)
  3. VCC txuas nrog 5V.
  4. GND txuas nrog 0V.

Koj tseem tuaj yeem sab laj nrog schematic qhia hauv daim duab.

Kauj ruam 3: Code

Code
Code
Code
Code

Arduino Txoj Cai

Ua ntej tshaj, peb yuav suav nrog txhua lub tsev qiv ntawv xav tau.

  1. Wire.h:- Rau I2C kev sib txuas lus
  2. Adafruit_LedBackpack
  3. Adafruit_GFX

Txhua lub tsev qiv ntawv no muaj nyob hauv Arduino IDE nws tus kheej. Koj tsuas yog yuav tsum teeb tsa lawv los ntawm Tus Thawj Saib Xyuas Tsev Qiv Ntawv. Kev kos duab >> suav nrog lub tsev qiv ntawv >> Tswj lub tsev qiv ntawv

Teeb muaj nuj nqi ()

Teeb tsa tus lej tsis tau kos npe 8-ntsis array rau strore8 binary qhov tseem ceeb rau 8 kab, ntawm 8 khoom txhua (8 kab). Teem chaw nyob rau I2C kev sib txuas lus.

Loop muaj nuj nqi ()

Raws li peb xav tau luam tus cim, peb xav tau cov cai rau tus ua cim hauv lub sijhawm tiag tiag. Txoj hauv kev yooj yim tshaj plaws yog xa cov lej ua ntu zus thiab Arduino yuav nyeem cov ntaub ntawv xov xwm thiab luam tus cim raws li. Kev xa cov kab ntawv ib ntu tuaj yeem yog txoj haujlwm nyuaj, yog li peb tuaj yeem xa txoj hlua nrog txhua 8 tus lej (8 khoom txhua tus) cais los ntawm tus lej.

Nyeem Serial String:

yog (Serial.available ()> 0) {data = Serial.readStringUntil ('\ n'); Serial.println (cov ntaub ntawv); }

Tom qab nyeem cov ntawv, peb yuav tsum tau txiav txim siab txoj hlua no thiab tau txais rov qab qhov txiaj ntsig binary. Raws li peb paub, hom ntawv ntawm cov hlua nkag yuav ib txwm zoo ib yam. Peb tuaj yeem ua tus lej nws txhawm rau nrhiav cov hlua thiab hloov cov hlua rau lawv cov lej sib npaug. Tom qab ntawd peb yuav hla cov lej uas tau tsim ua zauv (uint8_t) los luam cov cim ntawm matrix.

Hloov txoj hlua ntawm 8 khoom mus rau zauv:

int val (String str) {int v = 0; rau (int i = 0; i <8; i ++) {if (str == '1') {v = v+power (2, (7-i))); }} rov v; }

Txog kev ntsuas qhov sib npaug ntawm zauv siv lub zog ua haujlwm (pow ()), koj yuav tsum tau ua nrog ob hom kev muaj txiaj ntsig thiab yog li peb tuaj yeem sau peb tus kheej lub zog ua haujlwm li:

int zog (int puag, int exponent) {int c = 1; rau (int kuv = 0; kuv {c = c*puag;} rov qab c;}

Tam sim no, thaum kawg, peb yuav sau cov cai los luam tawm tus cim siv cov khoom tsim los ntawm 8 tus lej zauv (ib qho rau txhua kab).

void print_emoji (uint8_t emoji , Xim xim) {matrix.clear (); yog (xim == "liab") {matrix.drawBitmap (0, 0, emoji, 8, 8, LED_RED); } lwm {matrix.drawBitmap (0, 0, emoji, 8, 8, LED_GREEN); } matrix.writeDisplay (); ncua (500); }

Koj yuav nkag siab cov cai no yooj yim raws li peb tau tshem tawm cov lej ua ntej thiab tom qab ntawd tso tawm tus cim siv emoji array siv matrix.drawBitmap () muaj nuj nqi. Tsis txhob hnov qab sau "matrix.writeDisplay ()" tom qab txhua qhov kev teeb tsa raws li txoj haujlwm no tsuas yog tso tawm txhua qhov kev ua tiav kom deb li deb ntawm matrix.

Tam sim no koj tuaj yeem xa cov hlua nrog txhua tus lej muaj txiaj ntsig thiab Arduino yuav luam tawm tus cim ntawm tus lej. Koj tuaj yeem rub tawm Arduino code los ntawm hauv qab no. Rau lub hom phiaj sim, koj tuaj yeem sau

B00111100, B01000010, B10100101, B10000001, B10100101, B10011001, B01000010, B00111100

txoj hlua no hauv Serial Monitor thiab tuaj yeem pom tus ua cim ntawm matrix.

Tam sim no, peb yuav tsum xa cov ntaub ntawv xov xwm tuaj ntawm lub software thaum peb nias "Luam tawm" khawm. Txog kev siv lub tshuab no, peb yuav ua tus qauv 8x8 matrix thiab peb yuav muab qhov chaw rau cov neeg siv los xaiv cov xov tooj twg yuav tsum tau xim thiab tom qab ntawd software yuav cia li tsim cov cai thiab xa cov ntaub ntawv txuas mus rau Arduino hauv kab ntawv. Kuv xaiv Kev Ua Haujlwm rau qhov seem ntawm kuv txoj haujlwm. Hauv kev ua, peb tuaj yeem ua tus lej siv 64 khawm (duab plaub nrog nias ua haujlwm) thiab tuaj yeem muab tus nqi tshwj xeeb thiab xim thaum pib (Cia nws yog xim dawb nrog tus nqi 0). Tam sim no thaum twg lub pob nyem, peb yuav hloov xim ntawm lub pob kom dub thiab teeb tus nqi rau 1. Yog tias tus neeg siv nias tib lub pob dua, nws tus nqi yuav rov hloov mus rau 0 thiab xim rov rau dawb. Qhov no yuav pab tus neeg siv hloov pauv txoj cai ib zaug thiab yooj yim dua thiab tuaj yeem hloov kho tau yooj yim yam tsis muaj kev tshem tawm tag nrho cov lej. Ntawm qhov nyem ntawm "Luam tawm" khawm, peb yuav ua txoj hlua zoo ib yam rau saum toj no rau qhov ua piv txwv. Tom qab ntawd txoj hlua yuav raug xa mus rau qhov chaw nres nkoj tshwj xeeb.

Koj tuaj yeem rub cov txheej txheem ua los ntawm hauv qab no. Nov yog kuv thawj txoj cai hauv kev ua. Cov lus pom zoo rau txoj hauv kev txhim kho coding tau txais txiaj ntsig zoo.

Koj tuaj yeem pom tias GUI zoo li cas thiab lub cim tau tsim los siv lub kaw lus li cas. Nws yuav tsis siv sijhawm vib nas this los tsim tus yam ntxwv ntawm matrix.

Koj tuaj yeem rub tawm cov cai thiab cov duab ntawm txoj haujlwm no los ntawm kuv GitHub Cov Chaw Cia Khoom.

Pom zoo: