logo

  • Tổng Hợp
No Result
View All Result
logo
No Result
View All Result
Trang chủ Tổng Hợp mạch điều khiển màn hình lcd sử dụng giao tiếp i2c

Mạch điều khiển màn hình lcd sử dụng giao tiếp i2c

by Admin _ June 10, 2022

Màn hình LCD16x02 giao tiếp I2C

*
Sơ trang bị đấu nối tiếp xúc IC2 với LCD 16×2.

Bạn đang xem: Mạch điều khiển màn hình lcd sử dụng giao tiếp i2c

Code quét những device trong một bus I2C

*

Module I2C PCF8574 cung cấp giao tiếp I2C cùng với 7bit địa chỉ, trong số đó có 4 bit cố định và thắt chặt và 3 bit có thể được tín đồ dùng tùy chỉnh cấu hình có dạng 0 1 0 0 A2 A1 A0. Mặc định, bên trên module nhà thêm vào để các chân A0, A1, A2 làm việc mức lô ghích cao phải PCF8574 có showroom là 0x27. Để cố đổi địa chỉ của IC này khi cần, chúng ta có thể tùy chọn biến đổi các mức xúc tích của 3 chân này bằng phương pháp nối xuống GND (mức thấp) cho các chân A0, A1, A2.

*

*
: Sunrom Electronics" />

Các bạn có thể tải code tìm địa chỉ cửa hàng bus ngơi nghỉ đây. Tải ngay.

// --------------------------------------//http://playground.arduino.cc/Main/I2cScanner// i2c_scanner//// Version 1// This program (or code that looks like it)// can be found in many places.// For example on the Arduino.cc forum.// The original author is not know.// Version 2, Juni 2012, Using Arduino 1.0.1// Adapted to lớn be as simple as possible by Arduino.cc user Krodal// Version 3, Feb 26 2013// V3 by louarnold// Version 4, March 3, 2013, Using Arduino 1.0.3// by Arduino.cc user Krodal.// Changes by louarnold removed.// Scanning addresses changed from 0...127 to 1...119,// according khổng lồ the i2c scanner by Nick Gammon// http://www.gammon.com.au/forum/?id=10896// Version 5, March 28, 2013// As version 4, but address scans now khổng lồ 127.// A sensor seems to use address 120.// Version 6, November 27, 2015.// Added waiting for the Leonardo serial communication.////// This sketch tests the standard 7-bit addresses// Devices with higher bit address might not be seen properly.// Watch đoạn clip explainign I2C address: https://www.youtube.com/watch?v=bqMMIbmYJS0// #include void setup() Wire.begin(); Serial.begin(9600); while (!Serial); // Leonardo: wait for serial monitor Serial.println("I2C Scanner"); void loop() byte error, address; int nDevices; Serial.println("Scanning..."); nDevices = 0; for(address = 1; address 127; address++ ) // The i2c_scanner uses the return value of // the Write.endTransmisstion lớn see if // a device did acknowledge to the address. Wire.beginTransmission(address); error = Wire.endTransmission(); if (error == 0) Serial.print("I2C device found at address 0x"); if (address16) Serial.print("0"); Serial.print(address,HEX); Serial.println(" !"); nDevices++; else if (error==4) Serial.print("Unknown error at address 0x"); if (address16) Serial.print("0"); Serial.println(address,HEX); if (nDevices == 0) Serial.println("No I2C devices found"); else Serial.println("done"); delay(5000); // wait 5 seconds for next scan

*

Code chương trình cho 2 màn hình hiển thị LCD 16×02, kết nối với Arduino

*

/* * Arduino code for use two or more LCD1602 with I2C with Arduino * Custom function khổng lồ display float (like 2.45), integer (like 2 or 8) và string * very easily * this Arduino sketch makes it possible to use two display at the set time * * Watch video instruction for this code: https://youtu.be/L6ekl2ABcuY* * * Written by Ahmad Shamshiri for Robojax.com on Saturday November 17, 2018 * at 20:45 in Ajax, Ontario, Canada * * This code is "AS IS" without warranty or liability. Không tính tiền to be used as long as you keep this lưu ý intact.* * This code has been tải về from Robojax.com This program is không tính tiền software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the không tính phí Software Foundation, either version 3 of the License, or (at your option) any later version.

Xem thêm: Kamen Rider Decade Phần 2 - Kamen Rider Decade: All Riders Vs

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #include // this is part of arduino#include LiquidCrystal_I2C lcd1(0x3F, 16, 2);// display 1LiquidCrystal_I2C lcd2(0x26, 16, 2);// display 2// number settingsconst int decimals = 2;// number of decimal places needed to be displayedconst int positions = 5;// total position of numbers including the decimal placesvoid setup() // initialize the LCD lcd1.begin();//initialize LCD1 lcd2.begin();//initialize LCD2 lcd1.backlight();// turn the backlight ON for the LCD1 lcd2.backlight();// turn the backlight ON for the LCD2 Serial.begin(9600);// initialize serial monitor with 9600 baud lcd1.print("Robojax Display"); lcd1.setCursor(0,1); lcd1.print("Display 1"); lcd2.print("Robojax Display"); lcd2.setCursor(0,1); lcd2.print("Display 2"); Serial.println("Robojax Displays"); Serial.println("2 or More"); delay(3000);// change this line if you want not khổng lồ wait lcd1.clear();// clearn screen 1 lcd2.clear();// clearn screen 2 void loop() // Robojax.com multiple LCD1602 I2C display int age = 31; int days= age * 365; float weight = 4.84; float voltage = 22.1; lcdDisplay(1, 0, "Age: ", intToStr(age), " years"); // print "Age: 31 years" to line 1 of display 1 lcdDisplay(1, 1, "Days: ", intToStr(days), " days");// print "Days: 11351 days" to lớn line 2 of display 1 lcdDisplay(2, 0, "Weight: ", floatToStr(weight), " kg");//print "Weight: 2.84 kg" t line 1 of display 2 lcdDisplay(2, 1, "Voltage: ", floatToStr(voltage), "V");// print "Voltage 22.10V" lớn line 2 of display 2 Serial.println("Age: ");Serial.print(age); Serial.print(" years"); Serial.println("Days: ");Serial.print(days); Serial.print(" days"); Serial.println("===="); delay(50); // wait for 200 milliseconds // loop end/* * Written by Ahmad Shamshiri on Nov 17, 2018 for Robojax.com * lcdDisplay(int dis, int rowNum, String titleText, String valueText, String value2Text) for example to display * dis is display number * rowNum is row number (0) * title is the text (Voltage:) * valueText is the value * value2Text is the appended lớn the valueText lượt thích (A, V etc) * *
Share Tweet Linkedin Pinterest
Previous Post

Trang phục mùa hè cho bé

Next Post

Các loại switch phím cơ

CÙNG CHUYÊN MỤC

hồi ký lý quang diệu

Hồi ký lý quang diệu

08/02/2022
giấy dán tường giả đá cẩm thạch

Giấy dán tường giả đá cẩm thạch

10/02/2022
mẫu bàn sắt mặt đá

Mẫu bàn sắt mặt đá

08/02/2022
hình ảnh chúc thượng lộ bình an

Hình ảnh chúc thượng lộ bình an

26/01/2022
đọc truyện tranh shin cậu bé bút chì tập 47

Đọc truyện tranh shin cậu bé bút chì tập 47

06/07/2022
máy câu nhật bãi tphcm

Máy câu nhật bãi tphcm

06/07/2022
vi kim tảo biển tại nhà

Vi kim tảo biển tại nhà

06/07/2022
hình ảnh nhụy hoa nghệ tây

Hình ảnh nhụy hoa nghệ tây

06/07/2022

Newsletter

The most important automotive news and events of the day

We won't spam you. Pinky swear.

Chuyên Mục

  • Tổng Hợp

News Post

  • Phụ tùng chế xe đạp thường thành xe đạp điện

About

Chúng tôi tạo ra trang web nhằm mục đích mang lại kiến thức bổ ích cho cộng đồng, các bài viết được sưu tầm từ nhiều nguồn trên internet giúp mang lại kiến thức khách quan dành cho bạn

©2022 4566.vn - Website WordPress vì mục đích cộng đồng

No Result
View All Result
  • Trang chủ
  • Chuyên mục
    • Tổng Hợp
  • Lưu trữ
  • Liên hệ

© 2022 4566.vn - Website WordPress vì mục đích cộng đồng.