需要帮助在LCD上显示串行监视器

时间:2017-12-06 21:43:23

标签: arduino lcd

我在lcd上显示串行监视器时遇到问题。我没有收到任何错误,液晶显示屏亮了,所以我不认为我错了。我可以打开串口监视器/绘图仪,看到信息变化,所以我的其他组件也在工作,所以问题必须在代码中......

#include <LiquidCrystal.h>

/**
 * LIDARLite I2C Example
 * Author: Garmin
 * Modified by: Shawn Hymel (SparkFun Electronics)
 * Date: June 29, 2017
 * 
 * Read distance from LIDAR-Lite v3 over I2C
 * 
 * See the Operation Manual for wiring diagrams and more information:
 * http://static.garmin.com/pumac/LIDAR_Lite_v3_Operation_Manual_and_Technical_Specifications.pdf
 */

#include <Wire.h>
#include <LIDARLite.h>


const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
// Globals
LIDARLite lidarLite;
int cal_cnt = 0;

void setup()
{
  Serial.begin(9600); // Initialize serial connection to display distance readings

  lidarLite.begin(0, true); // Set configuration to default and I2C to 400 kHz
  lidarLite.configure(0); // Change this number to try out alternate configurations


  lcd.begin(16, 2);
  // initialize the serial communications:
}

void loop()
{
  int dist;

  // At the beginning of every 100 readings,
  // take a measurement with receiver bias correction
  if ( cal_cnt == 0 ) {
    dist = lidarLite.distance();      // With bias correction
  } else {
    dist = lidarLite.distance(false); // Without bias correction
  }

  // Increment reading counter
  cal_cnt++;
  cal_cnt = cal_cnt % 100;

  // Display distance
  Serial.print(dist);
  Serial.println(" cm");

  delay(10);

    // when characters arrive over the serial port...
  if (Serial.available()) { 
    // wait a bit for the entire message to arrive
    delay(100);
    // clear the screen
    lcd.clear();
    // read all the available characters
    while (Serial.available() > 0) {
      // display each character to the LCD
      lcd.write(Serial.read());
    }
  }
}

液晶显示屏应显示更改的测量值

液晶显示屏亮起,我可以调节背光,但我无法显示任何内容。

1 个答案:

答案 0 :(得分:2)

仅仅因为液晶显示屏“点亮”并不意味着它的连接正确。实际上,背光电路通常与数据和控制信号电路完全分开。我首先要检查一下这个假设,即用一个简单的命令正确连接,以便将已知值打印到LCD上:

lcd.clear();
lcd.println("TEST");

如果这样可行,那么您就知道LCD正在工作,并且可以在其他地方查找问题。

如果这不起作用,我会质疑你的假设它是否正确连接,但如果你仍然只得到“蓝色块”,那么它可能就像你的对比度不正确一样简单。为了便于阅读,将对比度和亮度设置为良好的组合可能会非常棘手。看看你的显示器背面是否有一个小电位器(通常可以通过一个非常小的飞利浦头驱动器调节),并仔细调整对比度。

亮度通常可通过软件命令更改,但大多数LCD在首次启动时默认为高亮度。

如果改变对比度不起作用,你可能会遇到一个真正的布线问题,然后它真的是这个论坛的主题。在这种情况下,您应该绘制一个原理图并在电气工程堆栈上发布。

相关问题