标题: 课堂随笔 [打印本页]

作者: suozhang    时间: 2017-6-8 00:10
标题: 课堂随笔
概念  声音:频率 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);// 发 送 一 个 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.51hei.com/bbs/) Powered by Discuz! X3.1