Robofun 機器人論壇

 找回密碼
 申請會員
搜索
熱搜: 活動 交友 discuz
查看: 3653|回復: 6
打印 上一主題 下一主題

兩組程式碼該怎樣結合

[複製鏈接]
跳轉到指定樓層
1#
發表於 2012-3-1 20:28:58 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
void setup() {
  Serial.begin(9600);
}

void loop() {
  int sensorValue = analogRead(A0);
  Serial.println(sensorValue);
}

-----------------------------------------------------------------------------------------------------------------------
#include <LiquidCrystal.h>

LiquidCrystal lcd(3, 4, 5, 8, 9, 10, 11);  //初始化LCD

void setup()
{
lcd.begin(16, 2);      //設定LCD大小
lcd print();    //輸出字串
}

void loop()
{
  
}
--------------------------------------------------------------
該怎樣結合
請各位大大幫忙了
謝謝你們
2#
 樓主| 發表於 2012-3-1 21:23:21 | 只看該作者
#include <LiquidCrystal.h>

LiquidCrystal lcd(3, 4, 5, 8, 9, 10, 11);  //初始化LCD

void setup()
{  
Serial.begin(9600);
}
void loop() {
  int sensorValue = analogRead(A0);
  lcd.begin(16, 2);      //設定LCD大小
  lcd print(sensorValue);    //輸出字串
}


這樣的程式無法編譯
不知道哪裡出了問題
偵錯顯示為

sketch_mar01e.cpp: In function 'void loop()':
sketch_mar01e:11: error: expected `;' before 'print'
3#
發表於 2012-3-1 21:45:00 | 只看該作者
Hi, Compiler 給你的訊息並不困難,試著瞭解它想跟你說什麼:

sketch_mar01e:11: error: expected `;' before 'print'
4#
 樓主| 發表於 2012-3-1 21:59:54 | 只看該作者
回復 3# coopermaa


   因為看不太懂給我的訊息
   可能還是需要高手解釋
謝謝
5#
發表於 2012-3-1 22:53:38 | 只看該作者
#include

LiquidCrystal lcd(3, 4, 5, 8, 9, 10, 11);  //初始化LCD

void setup()
{  
Serial.beg ...
mjm2246 發表於 2012-3-1 21:23



    lcd print(sensorValue); //輸出字串

>>> lcd.print(sensorValue); //輸出字串
6#
發表於 2012-3-2 00:04:29 | 只看該作者
咦?! 這根本結合前就已經是錯誤的耶
建議還是一段一段試吧
感覺根本沒做過直接來要求給答案
這不是學東西的態度喔
7#
 樓主| 發表於 2012-3-2 00:22:43 | 只看該作者
回復 6# mzw2008

就是因為有試過可不可行所以才遇到問題
感謝你的建議
問題已經解決了
您需要登錄後才可以回帖 登錄 | 申請會員

本版積分規則

小黑屋|手機版|Archiver|機器人論壇 from 2005.07

GMT+8, 2024-5-11 19:07 , Processed in 0.215540 second(s), 8 queries , Apc On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回復 返回頂部 返回列表