|
|
发表于 2015-5-15 09:44:08
|
显示全部楼层
wangruihan 发表于 2015-5-14 19:09 
Serial input 怎么实现呢?能不能具体一点。谢谢
你可以看看有關 Arduino 的 Serial class 的資料.
這是官網上的一個簡單例子 (http://www.arduino.cc/en/Serial/Read ) ,
- int incomingByte = 0; // for incoming serial data
- void setup() {
- Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
- }
- void loop() {
- // send data only when you receive data:
- if (Serial.available() > 0) {
- // read the incoming byte:
- incomingByte = Serial.read();
- // say what you got:
- Serial.print("I received: ");
- Serial.println(incomingByte, DEC);
- }
- }
-
复制代码 |
|