好不好用??????
記得要選擇與arduino相同的連接埠
1.首先下載PLX-DAQ
2.下載程式碼
// HCSR04Ultrasonic/examples/UltrasonicDemo/UltrasonicDemo.pde
#include
#define TRIGGER_PIN 12
#define ECHO_PIN 13
Ultrasonic ultrasonic(TRIGGER_PIN, ECHO_PIN);
void setup()
{
Serial.begin(9600);
Serial.println("CLEARDATA");
Serial.println("LABEL,Time,Timer,d");//標籤
}
void loop()
{
float cmMsec, inMsec;
long
microsec = ultrasonic.timing();
cmMsec = ultrasonic.convert(microsec, Ultrasonic::CM); // 計算距離,單位: 公分
inMsec = ultrasonic.convert(microsec,
Ultrasonic::IN); // 計算距離,單位: 英吋
Serial.print("DATA,TIME");
Serial.print(",");
Serial.print("TIMER");
Serial.print(",");
Serial.println(cmMsec);
// Serial.print("MS: ");
//
Serial.print(microsec);
//
Serial.print(", CM: ");
//Serial.print(cmMsec);
//
Serial.print(", IN: ");
//Serial.println(inMsec);
delay(100);
}