极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 11093|回复: 0

XBEE无线串口接收问题求助

[复制链接]
发表于 2015-6-26 20:31:15 | 显示全部楼层 |阅读模式
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int val;
char buffer[4];
void setup() {
  // put your setup code here, to run once:
lcd.begin(16,2);
Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  
  if(Serial.available()>0){
      char buffer[]={0};
    Serial.readBytes(buffer, 4);
    Serial.print("buffer: ");
    Serial.println(buffer);
val=atoi(buffer);
Serial.print("val: ");
    Serial.println(val);
if(val<10){
lcd.setCursor(0,0);
  lcd.print("Front obstacle");
  
}
if(val>10){
lcd.setCursor(0,0);
  lcd.print("              ");
  }
}

}


这是代码,读取到的数据是buffer,三位数以内的,控制LCD显示屏的显示,请问问题出在哪里?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|联系我们|极客工坊

GMT+8, 2026-6-17 11:01 , Processed in 0.087173 second(s), 18 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表