1 / 13

學期專題報告

學期專題報告. 指導 教授 : 李志清 學生 : 朱竣誠. 設定藍芽位址. 按下方向鍵傳送的值. btnleft.setOnClickListener (new OnClickListener () { public void onClick (View v) { sendData ("2"); } }); btnright.setOnClickListener ( new OnClickListener () { public void onClick (View v) { sendData ("3"); } });.

galia
Download Presentation

學期專題報告

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 學期專題報告 指導教授:李志清 學生 : 朱竣誠

  2. 設定藍芽位址

  3. 按下方向鍵傳送的值 btnleft.setOnClickListener(newOnClickListener() { public void onClick(View v) { sendData("2"); } }); btnright.setOnClickListener(new OnClickListener() { public void onClick(View v) { sendData("3"); } }); btnforward.setOnClickListener(newOnClickListener() { public void onClick(View v) { sendData("0"); } }); btnback.setOnClickListener(newOnClickListener() { public void onClick(View v) { sendData("1"); } });

  4. Layout畫面

  5. 控制PWM public void onStopTrackingTouch(SeekBarseekBar) { // TODO Auto-generated method stub sendData('*'+ss); } public void onStartTrackingTouch(SeekBarseekBar) { // TODO Auto-generated method stub } public void onProgressChanged(SeekBarseekBar, int progress, booleanfromUser) { // TODO Auto-generated method stub Toast.makeText(getApplicationContext(), "speed", Toast.LENGTH_LONG).show(); value.setText("目前速度:"+progress); ss = String.valueOf(progress); } };

  6. Arduino接收部分 } if(incomingByte == '2') { left(); delay(DELAY); motorstop(); delay(500); } if(incomingByte == '3') { right(); delay(DELAY); motorstop(); delay(500); } } void loop() { if (Serial.available() > 0) { // if the data came incomingByte = Serial.read(); // read byte //Serial.print("incomingByte="); Serial.print(incomingByte); Serial.print("\n"); if(incomingByte == '0') { forward(); delay(DELAY); motorstop(); delay(500); } if(incomingByte == '1') { //Serial.print("backward"); backward(); delay(DELAY); motorstop(); delay(500); }

  7. 方向鍵副程式 void right() { digitalWrite(motorIn1, HIGH); digitalWrite(motorIn2, LOW); digitalWrite(motorIn3, LOW); digitalWrite(motorIn4, HIGH); analogWrite(ENA,i); analogWrite(ENB,i); } void left() { digitalWrite(motorIn1, LOW); digitalWrite(motorIn2, HIGH); digitalWrite(motorIn3, HIGH); digitalWrite(motorIn4, LOW); } void motorstop() { digitalWrite(motorIn1, LOW); digitalWrite(motorIn2, LOW); digitalWrite(motorIn3, LOW); digitalWrite(motorIn4, LOW); } void forward() { digitalWrite(motorIn1, LOW); digitalWrite(motorIn2, HIGH); digitalWrite(motorIn3, LOW); digitalWrite(motorIn4, HIGH); } void backward() { digitalWrite(motorIn1,HIGH); digitalWrite(motorIn2, LOW); digitalWrite(motorIn3, HIGH); digitalWrite(motorIn4, LOW); }

  8. 超音波SENOR HC-SRO4

  9. 超音波的簡介 波的傳播速度是頻率與波長的乘積,電磁波的速度是 3 X 10 的 8 次方 m/s ,但空中的音波傳播速度非常緩慢,約為 340m/s,所以波 長較短 ! 超音波在行進中碰到不同性質的物質就會引起反射 ! 超音波本身是一種指頻率超過 20KHz 人的耳朵所不可能聽到的 聲音,超音波上限頻率在固體與液體中約為 107KHz,在氣體中約為 104KHz。高頻超音波之波長短,方向性很好,可以作定向傳播,超音 波感測器之用途很廣,常長作為定位、探傷等應用,這些應用是基於 超音波固、液體之傳播衰減小,穿透力強,對雜質或界面之反射極為 顯著而來。 超音波之感測更可藉著與傳播介質的特性結合,改變物質彈性 模量、密度、溫度、流量、流速、組成成分等,而作為不同功能的感 測器使用。

  10. 超音波 超音波在發射之後,從目標物體反射回來的超音波強度和光的場合一樣,與目標物體的距離以及目標物體的反射率有依存性,不過,反射 時間是固定的,不受目標物體反射率的影響,只要反射波被檢出,就可以在某種程度以上的精度之下測出對象物體的距離。這是超音波感測器的最大特徵。 超音波的強度會隨傳送之距離而衰減,主要原因是由於能量的散失及分佈球面積越來越大的緣故,且超音波在空氣中的衰減 與頻率成正比,超音波的頻率越高時,則其衰減越嚴重,即所傳送的距離也越短。

  11. 超音波測試顯示

  12. 作品實體圖

  13. END

More Related