Cov txheej txheem:

Siv 16x2 LCD Nrog I2C: 4 Kauj Ruam
Siv 16x2 LCD Nrog I2C: 4 Kauj Ruam

Video: Siv 16x2 LCD Nrog I2C: 4 Kauj Ruam

Video: Siv 16x2 LCD Nrog I2C: 4 Kauj Ruam
Video: Hmong funny movie lub neej nrog xov tooj life with mobile 2024, Hlis ntuj nqeg
Anonim
Siv 16x2 LCD Nrog I2C
Siv 16x2 LCD Nrog I2C
Siv 16x2 LCD Nrog I2C
Siv 16x2 LCD Nrog I2C
Siv 16x2 LCD Nrog I2C
Siv 16x2 LCD Nrog I2C

Hauv ib qho ntawm kuv Cov Lus Qhia yav dhau los, Kuv tau qhia koj yuav ua li cas txuas thiab cuam tshuam LCD rau Arduino Uno thiab tso saib qhov tseem ceeb ntawm nws. Tab sis raws li tau pom, muaj ntau qhov kev sib txuas thiab yog tias txoj haujlwm pib tau txais kev ntxhov siab ntau vim muaj xov hlau ntau dhau.

Hauv Cov Lus Qhia no, Kuv yuav qhia koj li cas txuas lub LCD rau I2C, uas yuav tsuas muaj 4 tus pin los tswj thiab siv LCD. Yog li cia peb pib.

Kauj Ruam 1: Cov Cheeb Tsam Yuav Tsum Tau

Cov Cheeb Tsam Yuav Tsum Tau
Cov Cheeb Tsam Yuav Tsum Tau
Cov Cheeb Tsam Yuav Tsum Tau
Cov Cheeb Tsam Yuav Tsum Tau
Cov Cheeb Tsam Yuav Tsum Tau
Cov Cheeb Tsam Yuav Tsum Tau

Rau qhov haujlwm no koj yuav xav tau:

  • Arduino Ib
  • 16x2 LCD Zaub
  • I2C rau 16x2 LCD
  • Hook-Up xov hlau

Nrog rau tag nrho cov no, cia peb nkag mus rau hauv qhov txuas.

Kauj ruam 2: Kev sib txuas

Kev sib txuas
Kev sib txuas
Kev sib txuas
Kev sib txuas
Kev sib txuas
Kev sib txuas
Kev sib txuas
Kev sib txuas

Xa cov duab thiab ua kom muaj kev sib txuas. Nws yog qhov yooj yim heev, koj tsuas yog yuav tsum ntsaws I2C hauv cov chaw nres nkoj ntawm LCD thiab muab nws tso rau hauv qhov chaw. Tom qab ntawd txuas SCL tus pin rau A4 tus pin ntawm Arduino thiab SDA tus pin rau A5 tus pin ntawm Arduino.

Kuv tsis siv lub I2C li kuv twb tau siv lub taub hau taub hau ntawm lub LCD. Tab sis kuv yuav hais kom siv lub I2C ntawm LCD

Kauj ruam 3: Code

Muaj LCD I2C tus tswv tsev qiv ntawv suav nrog hauv Arduino IDE. Tab sis muaj teeb meem me me nrog cov cai hauv nws. Txhua qhov piv txwv hauv lub tsev qiv ntawv no xav tias qhov chaw nyob tsis raug ntawm I2C li 0x27. Yog li ua ntej peb yuav tsum nrhiav seb qhov chaw nyob ntawm peb I2C yog dab tsi. Peb tuaj yeem ua qhov no los ntawm kev siv I2C scanner code. Thaum peb muaj I2C chaw nyob peb tuaj yeem hloov tus nqi no hauv tus piv txwv code thiab pib siv nws.

I2C Scanner Code:

#suav nrog

teeb tsa tsis muaj dabtsis () {Wire.begin (); Serial.begin (9600); thaum (! Serial); // tos saib daim ntawv Serial.println ("\ nI2C Scanner"); } void loop () {byte yuam kev, chaw nyob; koj nDevices; Serial.println ("Luam theej duab …"); nDevices = 0; rau (chaw nyob = 1; chaw nyob <127; chaw nyob ++) {// Tus i2c_scanner siv tus nqi rov qab los ntawm // Tus Sau.endTransmisstion kom pom tias // lub cuab yeej puas lees paub rau qhov chaw nyob. Wire.beginTransmission (chaw nyob); yuam kev = Wire.endTransmission (); yog (yuam kev == 0) {Serial.print ("I2C ntaus ntawv pom ntawm qhov chaw nyob 0x"); yog (chaw nyob <16) Serial.print ("0"); Serial.print (chaw nyob, HEX); Serial.println ("!"); nDevices ++; } lwm yog (yuam kev == 4) {Serial.print ("Tsis paub qhov yuam kev ntawm qhov chaw 0x"); yog (chaw nyob <16) Serial.print ("0"); Serial.println (chaw nyob, HEX); }} yog (nDevices == 0) Serial.println ("Tsis pom I2C li pom / n"); lwm tus Serial.println ("ua tiav / n"); ncua (5000); // tos 5 vib nas this rau tom ntej scan}

Piv txwv Code (Txhawm rau pom cov cim nkag rau hauv Serial Monitor):

#ncig #ncig

LiquidCrystal_I2C lcd (0x3F, 20, 4); // teeb tsa qhov chaw nyob LCD rau 0x27 rau 16 tus cim thiab 2 kab lus tso tawm

void teeb tsa ()

{lcd.init (); // pib lub lcd lcd.backlight (); Serial.begin (9600); }

void lub voj ()

{// thaum cov cim tuaj txog ntawm qhov chaw nres nkoj… yog (Serial.available ()) {// tos me ntsis rau tag nrho cov lus kom tuaj txog qeeb (100); // tshem qhov screen lcd.clear (); // nyeem tag nrho cov cim muaj thaum (Serial.available ()> 0) {// tso saib txhua lub cim rau LCD lcd.write (Serial.read ()); }}}

Kauj Ruam 4: Cov Zis

Cov Zis
Cov Zis
Cov Zis
Cov Zis

Thaum koj tau xa cov cai, koj npaj txhij mus. Txog qhov Kev Qhia Kuv tau coj tus piv txwv ntawm Cov Cai Sau Tus Qauv. Yog li tam sim no tom qab rub tawm cov cai, qhib Serial Monitor thiab ntaus ib lo lus thiab nyem "xa". Tam sim no koj yuav tsum pom tus nqi no nthuav tawm ntawm LCD.

Pom zoo: