Download presentation
Presentation is loading. Please wait.
Published byJonathan Logan Modified over 9 years ago
1
Autumn, 2014C.-S. Shieh, EC, KUAS, Taiwan1 智慧電子應用設計導論 (1/3) Communication - Serial Chin-Shiuh Shieh ( 謝欽旭 ) http://bit.kuas.edu.tw/~csshieh Department of Electronic Engineering National Kaohsiung University of Applied Sciences, Taiwan
2
Autumn, 2014C.-S. Shieh, EC, KUAS, Taiwan2 Communication Built-in –UART –SPI –TWI/I2C Software –UART –OneWire –…
3
Autumn, 2014C.-S. Shieh, EC, KUAS, Taiwan3 Advanced Communications PC Smart Phone/Bluetooth Internet/ WiFi,Ethernet Wireless UART GSM GPS …
4
Autumn, 2014C.-S. Shieh, EC, KUAS, Taiwan4 Serial -Functions if (Serial) available() begin() end() find() findUntil() flush() parseFloat() parseInt()
5
Autumn, 2014C.-S. Shieh, EC, KUAS, Taiwan5 Serial –Functions (cont) peek() print() println() read() readBytes() readBytesUntil() setTimeout() write() serialEvent()
6
Autumn, 2014C.-S. Shieh, EC, KUAS, Taiwan6 Example – available/read void setup() { Serial.begin(9600);Serial1.begin(9600); } void loop() { Serial1.println("Hello, Arduino!"); delay(500); while(Serial.available()) { Serial.print(char(Serial.read())); } delay(500); }
7
Autumn, 2014C.-S. Shieh, EC, KUAS, Taiwan7 Example – find/parse void setup() { Serial.begin(9600); } void loop() { if(Serial.find("Speed=")){ Serial.println(Serial.parseInt()); }
8
Autumn, 2014C.-S. Shieh, EC, KUAS, Taiwan8 RS-232 Programming on PC My personal choice –Borland C++ Builder 5.0 –ComPort Library version 2.64 by Paul Doland –TMS Instrumentation Workshop by TMS Software http://bit.kuas.edu.tw/~csshieh/teach/101A /mc/advanced/index.html#PCChttp://bit.kuas.edu.tw/~csshieh/teach/101A /mc/advanced/index.html#PCC
9
Autumn, 2014C.-S. Shieh, EC, KUAS, Taiwan9 Example – TMSIW_02 void setup() { int i; Serial.begin(9600); for(i=0;i<8;i++)pinMode(14+i,OUTPUT); } void loop() { unsigned char x; int i; while(Serial.available()) { x=Serial.read(); for(i=0;i<8;i++){digitalWrite(14+i,bitRead(x,i));} Serial.write(analogRead(A0)/4); delay(100); } http://bit.kuas.edu.tw/~csshieh/teach/101A/mc/a dvanced/pcc02.zip on PChttp://bit.kuas.edu.tw/~csshieh/teach/101A/mc/a dvanced/pcc02.zip
10
Autumn, 2014C.-S. Shieh, EC, KUAS, Taiwan10 Example – TMSIW_03 void setup() { Serial.begin(9600); } void loop() { Serial.write(analogRead(A0)/4); delay(100); } http://bit.kuas.edu.tw/~csshieh/teach/101A/mc/a dvanced/pcc03.zip on PChttp://bit.kuas.edu.tw/~csshieh/teach/101A/mc/a dvanced/pcc03.zip
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.