標(biāo)題: 課堂隨筆 [打印本頁(yè)]

作者: suozhang    時(shí)間: 2017-6-8 00:10
標(biāo)題: 課堂隨筆
概念  聲音:頻率 20 HZ~2000 HZ
物體表面積 >=0.5m2
pulsein(elco,HIGH);



float dist;
int TRIG=2;//接2腳
int echo=3;//接3腳
void setup() {
  pinMode(TRIG,OUTPUT);
  pinMode(echo,INPUT);
  Serial.begin(9600);// put your setup code here, to run once:

}

void loop() {
  digitalWrite(TRIG,LOW);
  delayMicroseconds(4);// 發(fā) 送 一 個(gè) 4us 的  
  digitalWrite(TRIG,HIGH);// put your main code here, to run repeatedly:
  delayMicroseconds(10);
  digitalWrite(TRIG,LOW);
  dist=Pulsein(echo,HIGH)/58;
  Serial.println(dist);
  delay(1000);
}






歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1