久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索

【Arduino】108種傳感器模塊系列實驗(134)---2004A LCD液晶屏

查看數(shù): 6793 | 評論數(shù): 30 | 收藏 0
關(guān)燈 | 提示:支持鍵盤翻頁<-左 右->
    組圖打開中,請稍候......
發(fā)布時間: 2019-10-6 20:07

正文摘要:

37款傳感器與模塊的提法,在網(wǎng)絡(luò)上廣泛流傳,其實Arduino能夠兼容的傳感器模塊肯定是不止37種的。鑒于本人手頭積累了一些傳感器和模塊,依照實踐出真知(一定要動手做)的理念,以學(xué)習(xí)和交流為目的,這里準(zhǔn)備逐一動 ...

回復(fù)

ID:513258 發(fā)表于 2020-12-25 21:16
  1. /*
  2.   【Arduino】168種傳感器模塊系列實驗(資料代碼+圖形編程+仿真編程)
  3.   實驗一百五十二:GY-25 串口直接輸出角度數(shù)據(jù) 傾斜度角度傳感器模塊 MPU-6050
  4.   使用步驟:
  5.   1.先下載GY25_uart程序至arduino
  6.   2.再接上GY25模塊
  7.   3.按復(fù)位按鍵
  8.   4.打開串口,波特率115200
  9.   5、接線
  10.   GY25                arduino uno
  11.   VCC----------------------VCC
  12.   RX-----------------------TX
  13.   TX-----------------------RX
  14.   GND----------------------GND
  15.   ---------------------------------------
  16.   IICLCD2004           arduino uno
  17.   VCC----------------------VCC
  18.   SCL----------------------A5
  19.   SDA----------------------A4
  20.   GND----------------------GND
  21.   實驗之二:IICLCD2004顯示動態(tài)角度數(shù)值
  22. */

  23. #include <Wire.h>
  24. #include <LiquidCrystal_I2C.h>
  25. int YPR[3];
  26. unsigned char Re_buf[8], counter = 0;
  27. unsigned char sign = 0;
  28. int led = 13;
  29. LiquidCrystal_I2C lcd(0x27, 20, 4); // set the LCD address to 0x20 for a 20 chars and 4 line display

  30. //-----------------------------------------------------------
  31. void setup()
  32. {
  33.   lcd.init();                      // initialize the lcd
  34.   // Print a message to the LCD.
  35.   Serial.begin(115200);
  36.   delay(2000);
  37.   Serial.write(0XA5);
  38.   Serial.write(0X52);    //初始化GY25,連續(xù)輸出模式
  39.   lcd.backlight();
  40.   lcd.setCursor(0, 0);    //I2C接口LCD2004顯示初始值
  41.   lcd.print("Yaw:");
  42.   lcd.setCursor(0, 1);
  43.   lcd.print("Pitch:");
  44.   lcd.setCursor(0, 2);
  45.   lcd.print("Roll:");
  46. }
  47. //-------------------------------------------------------------
  48. void loop() {
  49.   if (sign)
  50.   {
  51.     sign = 0;
  52.     if (Re_buf[0] == 0xAA && Re_buf[7] == 0x55)   //檢查幀頭,幀尾
  53.     {
  54.       YPR[0] = (Re_buf[1] << 8 | Re_buf[2]) / 100; //合成數(shù)據(jù),去掉小數(shù)點后2位
  55.       YPR[1] = (Re_buf[3] << 8 | Re_buf[4]) / 100;
  56.       YPR[2] = (Re_buf[5] << 8 | Re_buf[6]) / 100;

  57.       lcd.setCursor(4, 0);
  58.       lcd.print("    ");
  59.       lcd.setCursor(4, 0);
  60.       lcd.print(YPR[0]);      //顯示航向

  61.       lcd.setCursor(6, 1);
  62.       lcd.print("    ");
  63.       lcd.setCursor(6, 1);   //顯示俯仰角
  64.       lcd.print(YPR[1]);

  65.       lcd.setCursor(5, 2);
  66.       lcd.print("    ");
  67.       lcd.setCursor(5, 2);    //顯示橫滾角
  68.       lcd.print(YPR[2]);
  69.       delay(100);
  70.     }
  71.   }
  72. }
  73. //----------------------------------------------------------
  74. void serialEvent() {
  75.   while (Serial.available()) {
  76.     Re_buf[counter] = (unsigned char)Serial.read();
  77.     if (counter == 0 && Re_buf[0] != 0xAA) return; // 檢查幀頭
  78.     counter++;
  79.     if (counter == 8)             //接收到數(shù)據(jù)
  80.     {
  81.       counter = 0;               //重新賦值,準(zhǔn)備下一幀數(shù)據(jù)的接收
  82.       sign = 1;
  83.     }
  84.   }
  85. }
復(fù)制代碼


ID:513258 發(fā)表于 2019-11-25 10:17
絕情谷里人 發(fā)表于 2019-11-22 23:40
請問怎么條件顯示屏對比度

有個調(diào)節(jié)電位器,手工調(diào)整的
ID:629777 發(fā)表于 2019-11-22 23:40
請問怎么條件顯示屏對比度
ID:513258 發(fā)表于 2019-10-7 15:22
  1. /*
  2.   【Arduino】108種傳感器模塊系列實驗(資料+代碼+圖形+仿真)
  3.   實驗一百三十四:2004A字符顯示液晶模塊LCD/LCM 藍(lán)屏5V(帶背光 IIC/I2C)
  4.   安裝庫:工具——管理庫——搜索“LiquidCrystal_I2C"——下載安裝
  5.   項目三:多重顯示字符,系列演示
  6.   Arduino------LCD2004A
  7.   5V-------------VCC
  8.   GND-----------GND
  9.   A4-----------SDA IIC 數(shù)據(jù)線
  10.   A5-----------SCL IIC 時鐘線
  11. */

  12. #include <Wire.h>
  13. #include <LiquidCrystal_I2C.h>

  14. #if defined(ARDUINO) && ARDUINO >= 100
  15. #define printByte(args)  write(args);
  16. #else
  17. #define printByte(args)  print(args,BYTE);
  18. #endif

  19. uint8_t bell[8]  = {0x4, 0xe, 0xe, 0xe, 0x1f, 0x0, 0x4};
  20. uint8_t note[8]  = {0x2, 0x3, 0x2, 0xe, 0x1e, 0xc, 0x0};
  21. uint8_t clock[8] = {0x0, 0xe, 0x15, 0x17, 0x11, 0xe, 0x0};
  22. uint8_t heart[8] = {0x0, 0xa, 0x1f, 0x1f, 0xe, 0x4, 0x0};
  23. uint8_t duck[8]  = {0x0, 0xc, 0x1d, 0xf, 0xf, 0x6, 0x0};
  24. uint8_t check[8] = {0x0, 0x1, 0x3, 0x16, 0x1c, 0x8, 0x0};
  25. uint8_t cross[8] = {0x0, 0x1b, 0xe, 0x4, 0xe, 0x1b, 0x0};
  26. uint8_t retarrow[8] = {        0x1, 0x1, 0x5, 0x9, 0x1f, 0x8, 0x4};

  27. LiquidCrystal_I2C lcd(0x27, 20, 4); // set the LCD address to 0x27 for a 16 chars and 2 line display

  28. void setup()
  29. {
  30.   lcd.init();                      // initialize the lcd
  31.   lcd.backlight();

  32.   lcd.createChar(0, bell);
  33.   lcd.createChar(1, note);
  34.   lcd.createChar(2, clock);
  35.   lcd.createChar(3, heart);
  36.   lcd.createChar(4, duck);
  37.   lcd.createChar(5, check);
  38.   lcd.createChar(6, cross);
  39.   lcd.createChar(7, retarrow);
  40.   lcd.home();

  41.   lcd.print("Hello world...");
  42.   lcd.setCursor(0, 1);
  43.   lcd.print(" i ");
  44.   lcd.printByte(3);
  45.   lcd.print(" arduinos!");
  46.   delay(5000);
  47.   displayKeyCodes();

  48. }

  49. // display all keycodes
  50. void displayKeyCodes(void) {
  51.   uint8_t i = 0;
  52.   while (1) {
  53.     lcd.clear();
  54.     lcd.print("Codes 0x"); lcd.print(i, HEX);
  55.     lcd.print("-0x"); lcd.print(i + 16, HEX);
  56.     lcd.setCursor(0, 1);
  57.     for (int j = 0; j < 16; j++) {
  58.       lcd.printByte(i + j);
  59.     }
  60.     i += 16;

  61.     delay(4000);
  62.   }
  63. }

  64. void loop()
  65. {

  66. }
復(fù)制代碼


ID:513258 發(fā)表于 2019-10-7 12:22
  1. /*
  2.   【Arduino】108種傳感器模塊系列實驗(資料+代碼+圖形+仿真)
  3.   實驗一百三十四:2004A字符顯示液晶模塊LCD/LCM 藍(lán)屏5V(帶背光 IIC/I2C)
  4.   安裝庫:工具——管理庫——搜索“LiquidCrystal_I2C"——下載安裝
  5.   項目二:顯示字符“Welcome to Eagler8”
  6.   Arduino------LCD2004A
  7.   5V-------------VCC
  8.   GND-----------GND
  9.   A4-----------SDA IIC 數(shù)據(jù)線
  10.   A5-----------SCL  IIC 時鐘線
  11. */

  12. #include <Wire.h>
  13. #include <LiquidCrystal_I2C.h>
  14. LiquidCrystal_I2C lcd(0x27, 20, 4);

  15. void MyPrintLCD(String MyString)
  16. {
  17.   for (int i = 0; i < MyString.length(); i++)
  18.     lcd.write(MyString.charAt(i));
  19. }

  20. void setup()
  21. {
  22.   lcd.init();
  23.   lcd.backlight();
  24.   MyPrintLCD(" Welcome to ");
  25.   lcd.setCursor(0, 2);
  26.   MyPrintLCD("           Eagler8");
  27. }

  28. void loop()
  29. {
  30. }
復(fù)制代碼


ID:513258 發(fā)表于 2019-10-7 11:49
  1. /*
  2. 【Arduino】108種傳感器模塊系列實驗(資料+代碼+圖形+仿真)
  3. 實驗一百三十四:2004A字符顯示液晶模塊LCD/LCM 藍(lán)屏5V(帶背光 IIC/I2C)
  4. 項目一:尋找查詢設(shè)備IIC地址,在串口上即可看到2004A的地址
  5. 這里查詢結(jié)果是“0x27”(這個地址不對的話,實測無法燒錄程序)
  6. Arduino------LCD2004A
  7. 5V-------------VCC
  8. GND-----------GND
  9. A4-----------SDA IIC 數(shù)據(jù)線
  10. A5-----------SCL  IIC 時鐘線
  11. */

  12. #include <Wire.h>

  13. void setup(){
  14.   Wire.begin();
  15.   Serial.begin(9600);
  16.   Serial.println("\nI2C Scanner");
  17. }
  18. void loop(){
  19.   byte error, address;
  20.   int nDevices;
  21.   Serial.println("Eagler8 Scanning...");
  22.   nDevices = 0;
  23.   for (address = 1; address < 127; address++ ){
  24.    
  25.     Wire.beginTransmission(address);
  26.     error = Wire.endTransmission();
  27.     if (error == 0){
  28.       Serial.print("I2C device found at address 0x");
  29.       if (address < 16)
  30.         Serial.print("0");
  31.       Serial.print(address, HEX);
  32.       Serial.println(" !");
  33.       nDevices++;
  34.     }else if (error == 4){
  35.       Serial.print("Unknow error at address 0x");
  36.       if (address < 16)
  37.         Serial.print("0");
  38.       Serial.println(address, HEX);
  39.     }
  40.   }
  41.   if (nDevices == 0)
  42.     Serial.println("No I2C devices found\n");
  43.   else
  44.     Serial.println("done\n");
  45.   delay(5000);
  46. }
復(fù)制代碼


小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表
主站蜘蛛池模板: 成人午夜av | 国产高潮好爽受不了了夜色 | 看片地址 | 精品一区免费 | 国产91色在线 | 亚洲 | 伊人中文字幕 | 久久国产精品久久国产精品 | 精品视频一区二区三区 | 99在线免费观看视频 | 日韩欧美中文在线 | 欧美一区二区三区在线观看 | 国产激情91久久精品导航 | 精品一区国产 | 色网站在线免费观看 | 免费一级毛片 | 国产精品久久久久久久久久 | 国产精品99久久久久久www | 99精品国产一区二区青青牛奶 | 2018国产大陆天天弄 | 日韩在线视频一区 | 久久久99精品免费观看 | 91久久| 久草免费在线视频 | 久国久产久精永久网页 | 91秦先生艺校小琴 | 亚洲欧美日韩中文在线 | 日韩视频在线播放 | 91在线视频播放 | jlzzjlzz欧美大全 | av黄色国产 | 日韩一级不卡 | 欧美五月婷婷 | 精品一区二区在线观看 | 久久av一区二区三区 | 亚洲精品一区二区二区 | 成人午夜精品 | 国产极品车模吞精高潮呻吟 | 欧美一区二区成人 | 91久久国产综合久久91精品网站 | 国产精品久久久久久高潮 | 国产视频久久 |