iot's People
iot's Issues
1070622
今天物聯網課程的第一個作業是透過電腦傳送指令給arduino
要使其閃爍指定的次數
看起來很簡單的作業卻遇到了一個bug
花了一個午休最後旁邊的同學先找到了問題所在
delay(100);
//這裡如果沒有設延遲,接收的數據可能會分段
//如傳送123,被分為1,23
cmd_lengh=Serial.available();
if(Serial.available()>0){
// cmd_lengh=Serial.available();
// Serial.println(cmd_lengh);
cmd_send(); //接收指令並轉為數值
blink(cmd); //閃爍輸入的次數
在原先沒有設定delay時傳送字串會被切斷
如傳送123,會分成兩次接收1與23
與同學討論後推測,電腦端傳送數據到arduino的cache是有延遲的
如果傳送到一半,即從cache中取值,便會產生指令被分段的bug
第二個作業是arduino與藍芽的互動
這個部分新學到的知識是腳位的觀念
RX是接收數據
TX發送數據
故可推估在腳位的銜接
arduino的TX要接藍芽的RX
ardunio的RX要接藍芽的TX
#include
SoftwareSerial BT(8,9);//rx=8,tx=9
在arduino部分
因為外接藍芽所以要使用SoftwareSerial.h這個函示庫
(之前使用usb時,因hardwareSerial.h預設為開啟,不用特別宣告)
BT(rx,tx)為預設的位置
此為arduino的RX,TX
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.