2017-12-11 15 views
0

레이저 거리계에서 판독 값을 LCD에 표시하려고합니다. "cm"과 함께 시리얼을 표시 할 수 있지만 중국어로 보이는 두 개의 심볼을 계속 추가합니다. 이것은 Arduino를 사용하는 나의 첫 번째 프로젝트입니다, 누군가 나를 도울 수 있습니까?여분의 기호는 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(100); 

    // 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()); 
    } 
    } 

    delay(100); 
    lcd.clear(); 
    lcd.println(dist); 
    lcd.println(" cm"); 

} 

그냥 LCD에 (측정) cm을 표시해야합니다.
대신 나는 218 개의 cm을 받고 있습니다. - 두 개의 중국어 기호입니다.

image

답변

3

그것은 캐리지 리턴과 줄 바꿈 문자를 보여주는 것 같다.

printlnprint으로 바꿉니다.