Cov txheej txheem:

Scroll Tib Kab LCD: 4 Cov Kauj Ruam (nrog Duab)
Scroll Tib Kab LCD: 4 Cov Kauj Ruam (nrog Duab)

Video: Scroll Tib Kab LCD: 4 Cov Kauj Ruam (nrog Duab)

Video: Scroll Tib Kab LCD: 4 Cov Kauj Ruam (nrog Duab)
Video: КИТАЙЦЫ, ЧТО ВЫ ТВОРИТЕ??? 35 СУПЕР ТОВАРОВ ДЛЯ АВТОМОБИЛЯ С ALIEXPRESS 2024, Kaum ib hlis
Anonim
Image
Image

Liquid Crystal Library muaj ob txoj haujlwm muaj txiaj ntsig scrollDisplayLeft () thiab scrollDisplayRight (). Cov haujlwm no scroll tag nrho cov zaub. Ntawd yog, lawv nqes ob kab ntawm 1602 LCD thiab tag nrho plaub kab ntawm 2004 LCD. Qhov peb nquag xav tau yog lub peev xwm los nqes ib kab rau ntawm cov lus no ntau dua li nqes tag nrho cov zaub.

Cov Lus Qhia no muab ob txoj haujlwm ntxiv, scrollInFromRight (kab los tso saib cov ntawv ntawm, txoj hlua yuav tsum tau scrolled) thiab scrollInFromLeft (kab los tso saib cov ntawv rau, hlua kom raug scrolled). Ob txoj haujlwm no uas txav kab mus rau hauv lub vijtsam LCD ua ke nrog ob lub luag haujlwm, scrollLineRight (kab los tso saib cov ntawv ntawm, hlua kom raug scrolled) thiab scrollLineLeft (kab los tso saib cov ntawv ntawm, hlua kom raug scrolled) los ntawm kuv cov lus qhia ua ntej, uas tau nthuav tawm kev ua haujlwm kom txav kab tawm ntawm lub vijtsam, muab ntau txoj hauv kev rau peb los tswj cov ntawv tuaj yeem nthuav tawm, lossis tshem tawm ntawm, lub vijtsam LCD.

Kauj Ruam 1: Dab Tsi Xav Tau

Hookup
Hookup

- Ib qho 1602 lossis 2004 LCD cov zaub ib leeg, lossis cov ntaub thaiv npog LCD

- Saib daim ntawv hauv qab no hais txog kev siv 2004 LCD zaub

- Ib qho Arduino UNO R3 lossis clone

- USB cable txuas Arduino rau lub khoos phis tawj

- Ib nrab-qhov loj me, 400 cov ntsiab lus khi, lub khob cij

- Arduino IDE

- Ib qho chaw sim (xaiv tau, tab sis pab tau)

Cov khoom xav tau yog lub vijtsam LCD yog 1602 lossis 2004 [yog siv 2004, nws yuav ua haujlwm yam tsis muaj teeb meem los ntawm sab xis los ntawm kev hloov lcd.begin () ua haujlwm kom pom tias koj tam sim no siv 20 tus cim x 4 kab zaub. [Txhawm rau nkag los ntawm sab laug siv lub xyoo 2004 zaub, yuav tsum rov sau tus lej ntawm kev ua haujlwm crollInFromLeft () yog qhov tsim nyog]. Ntxiv nrog rau LCD koj yuav xav tau Arduino UNO lossis clone, Arduino IDE, thiab USB cable los txuas Arduino rau lub khoos phis tawj.

Ib daim iav tiv thaiv LCD tuaj yeem siv tsis siv lub LCD ib leeg nyob ntawm no. Yog tias yog qhov xwm txheej, tom qab ntawv tus lej pin rau LCD hauv daim duab hauv qab no yuav tsum tau hloov pauv.

- Rau kev ywj pheej 1602 LCD zaub kuv siv cov lej txuas hauv qab no hauv kuv daim duab:

// LiquidCrystal (rs, pab, d4, d5, d6, d7)

LiquidCrystal lcd (12, 11, 5, 4, 3, 2);

thiab suav nrog lub tsev qiv ntawv kua Crystal LiquidCrystal.h.

- Rau cov ntaub thaiv npog LCD, Kuv siv tus lej txuas hauv qab no hauv kuv daim duab, thiab tseem suav nrog Lub Tsev Qiv Crystal LiquidCrystal.h.

// LiquidCrystal (rs, pab, d4, d5, d6, d7)

LiquidCrystal lcd (8, 13, 9, 4, 5, 6, 7);

Ob txoj hauv kev yuav khiav txoj cai ntawm no, piv txwv li, ib qho LCD tiv thaiv lossis LCD ib leeg. Ib qho 1602 standalone LCD zaub tau siv hauv Cov Lus Qhia no, tab sis raws li tau sau tseg 1602 daim ntaub thaiv tuaj yeem siv tau ib yam yog tias cov lej sib txawv tau ua rau hauv tus account.

Kuv siv "qhov chaw sim" los txuas Arduino UNO mus rau ib nrab-qhov loj me, 400 cov ntsiab lus khi, cov qhob cij. (Saib ib qho Kev Qhia Ua Ntej ntawm kuv, "Kev Tshawb Fawb Platform Rau Arduino UNO R3, Yuav Npaj Li Cas Rau Kev Siv"). Txawm li cas los xij, qhov kev sim sim tsis xav tau, txawm hais tias rau kuv nws ua txuas LCD rau UNO yooj yim dua thiab nrawm dua.

Cov haujlwm uas kuv siv los txuas LCD rau UNO tuaj yeem pom saum toj no.

Kauj ruam 2: Hookup

Lub LCD tau txuas rau hauv lub khob cij thiab tom qab ntawd cov xov txuas tau txuas los ntawm lub khob cij mus rau tus pin tsim nyog ntawm Arduino (saib cov kauj ruam 2 yog tias koj muaj lus nug txog kev sib txuas kuv tau siv).

Kuv nyiam lub LCD ib leeg rau qhov haujlwm no ntau dua li daim ntaub thaiv raws li nws tau txaus siab rau kuv, thiab tso cai rau kuv pom yooj yim uas cov pins muaj. Nws kuj tseem tso cai rau kuv siv lub hwj chim ntsuas hluav taws xob uas muaj lub pob qhov rooj, ntau dua li daim iav thaiv lub zog uas yuav tsum tau kho nrog tus ntsia hlau.

LCD ib leeg yuav tsum siv cais 10k ohm potentiometer cais. Raws li tau sau tseg saum toj no, Kuv tau siv ib lub pob qhov rooj uas muaj nws lub wiper txuas nrog rau tus lej LCD thib peb (suav los ntawm sab xis nrog LCD pins ntsib koj). Lub potentiometer siv los tswj lub LCD qhov sib txawv. Cov kev sib txuas zoo ib yam rau 1602 thiab 2004. Txawm li cas los xij, nqe lus lcd.begin (16, 2) xav tau hloov pauv hauv daim duab mus rau lcd.begin (20, 4) los qhia tias peb lub LCD tau hloov pauv los ntawm 16 cim los ntawm ob kab tso rau 20 tus cim los ntawm plaub kab ib.

Saib ntawm cov duab txuas nrog qhia pom qhov txuas uas kuv tau siv, suav nrog lub platform sim, thiab 10k potentiometer.

Kauj ruam 3: Sketch

Daim Duab
Daim Duab
Daim Duab
Daim Duab
Daim Duab
Daim Duab

Tsuas yog nkag mus rau qhov kos duab txuas rau hauv Arduino IDE. Thov nco ntsoov tias Lub Chaw Qhia Ntawv feem ntau tshem tawm txhua qhov ntau dua thiab tsawg dua li cov cim thiab cov ntawv nruab nrab ntawm lawv. Yog li, nco ntsoov thiab suav nrog cov ntawv, #suav nrog LiquidCrystal.h thiab muab cov lus LiquidCrystal.h sab hauv ntau dua thiab tsawg dua cov cim.

// Sketch kom scroll cov cim rau ntawm lub vijtsam LCD

#suav nrog // Saib cov ntawv sau hauv kab ntawv hais txog dab tsi xav tau ntawm no, piv txwv li, LiquidCrystal.h nyob hauv

// ntau dua thiab tsawg dua cov cim

// Qhov chaw no feem ntau tshem ntau dua thiab tsawg dua cov cim thiab cov ntawv ntawm lawv

// LiquidCrystal (rs, pab, d4, d5, d6, d7)

LiquidCrystal lcd (12, 11, 5, 4, 3, 2);

// Tshaj tawm lcd ua LiquidCrystal Object

int kuv = 0;

int j = 0;

koj k = 0;

int delayTime2 = 350; // Ncua nruab nrab ntawm kev hloov pauv

void scrollInFromRight (int kab, char str1 ) {

// Sau los ntawm R. Jordan Kreindler Lub Rau Hli 2016

kuv = strlen (str1);

rau (j = 16; j> = 0; j--) {

lcd.setCursor (0, kab);

rau (k = 0; k <= 15; k ++) {

lcd.print (""); // Ntshiab kab

}

lcd.setCursor (j, kab);

lcd.print (str1);

ncua (delayTime2);

}

}

void scrollInFromLeft (int kab, char str1 ) {

// Sau los ntawm R. Jordan Kreindler Lub Rau Hli 2016

kuv = 40 - strlen (str1);

kab = kab - 1;

rau (j = i; j <= i+16; j ++) {

rau (k = 0; k <= 15; k ++) {

lcd.print (""); // Ntshiab kab

}

lcd.setCursor (j, kab);

lcd.print (str1);

ncua (delayTime2);

}

}

void teeb tsa () {

Serial.begin (9600);

Serial.println ("Pib xeem …");

lcd.begin (16, 2);

lcd.clear ();

lcd.print ("Xeem Xwb");

}

void voj () {

lcd.clear ();

scrollInFromRight (0, "Kab 1 Ntawm Txoj Cai");

scrollInFromRight (1, "Kab 2 Ntawm Txoj Cai");

lcd.clear ();

scrollInFromLeft (0, "Kab 1 Ntawm Sab laug.");

scrollInFromLeft (1, "Kab 2 Ntawm Sab laug.");

lcd.clear ();

scrollInFromRight (0, "Kab 1 Ntawm Txoj Cai");

scrollInFromLeft (1, "Kab 2 Ntawm Sab laug.");

lcd.clear ();

}

Ob txoj haujlwm: scrollInFromRight (kab los tso saib cov ntawv ntawm, hlua kom raug scrolled) thiab scrollInFromLeft (kab kom pom cov ntawv ntawm, hlua kom raug scrolled) tuaj yeem txav mus rau hauv koj daim duab los tswj cov kab uas tau nqes mus rau ntawm lub vijtsam LCD. Cov haujlwm no muab txoj hauv kev zoo los txav cov ntawv tshiab mus rau lub vijtsam.

Thaum ua ke nrog ob lub luag haujlwm hauv daim duab kos uas muaj nyob hauv Cov Lus Qhia "Scroll ib txoj kab LCD tawm mus rau sab laug lossis sab xis, Yuav ua li cas" plaub lub luag haujlwm muab txoj hauv kev zoo rau scroll cov ntawv mus rau thiab tawm ntawm LCD zaub. Cov haujlwm no tso cai rau koj nqes kab ntawv ib kab zuj zus, thiab tsis tas yuav tsum tso tag nrho cov duab kom raug raws li ua haujlwm, scrollDisplayLeft () thiab scrollDisplayRight ().

Lub peev xwm nqes peev txheej no tso cai rau peb nthuav qhia kab ntev dua uas cov duab ib txwm muaj peev xwm ua tau pom. Ntawd yog, rau 1602 cov zaub peb tsis txwv tsuas yog 16 tus cim ib kab (txawm hais tias tsuas yog 16 yuav qhia nyob rau ib lub sijhawm), thiab rau xyoo 2004 peb tsis txwv rau 20 tus cim rau ib kab.

Raws li ib sab, koj yuav xav hloov lub sijhawm tso saib ntawm cov ntawv kom haum koj cov kev xav tau.

Kauj ruam 4: Tom qab ntawd

Qhov ntawd yog txhua yam rau nws. Cov haujlwm no thiab ob qho los ntawm kuv Cov Lus Qhia yav dhau los tuaj yeem muab ntxiv rau txhua daim duab uas koj muaj uas siv LCD thiab nthuav tawm cov ntawv. Raws li tau sau tseg, kev muaj peev xwm siv kab ntev dua yog qhov txiaj ntsig tau txais txiaj ntsig uas muaj peev xwm ua tau los ntawm kev siv nqes.

Yog tias koj xav tiv tauj kuv nrog cov lus nug lossis xav paub ntxiv, lossis nthuav kuv qhov kev paub hauv thaj chaw nthuav tawm, Kuv tuaj yeem hu rau ntawm [email protected]. (thov hloov qhov thib ob 'kuv' nrog 'e' tiv tauj kuv.

Pom zoo: