Giter VIP home page Giter VIP logo

iot's People

Contributors

sdes5317 avatar

Watchers

 avatar

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 photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.