欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

標(biāo)題: arduino聲音傳感器資料與程序 [打印本頁]

作者: 筱豆先生    時間: 2017-11-14 11:38
標(biāo)題: arduino聲音傳感器資料與程序
聲音傳感器資料



arduino源程序如下:
  1. int ledPins[] =  {3,4,5,6,7,8,9,10};
  2. int switchPin = 2;
  3. int soundPin = 0;

  4. boolean showPeak = false;
  5. int peakValue = 0;

  6. void setup()
  7. {
  8.   for(int i = 0;i < 8; i++)
  9.   {
  10.      pinMode(ledPins[i],OUTPUT);
  11.   }
  12.   pinMode(switchPin,INPUT);
  13. }

  14. void loop()
  15. {
  16.   if (digitalRead(switchPin))
  17.   {
  18.     showPeak = !showPeak;
  19.     peakValue = 0;
  20.     delay(200);
  21.   }
  22.   int value = analogRead(soundPin);
  23.   int topLED = map(value,0,400,0,12)-1;
  24.   if(topLED>peakValue)
  25.   {
  26.     peakValue = topLED;
  27.   }
  28.   for(int i = 0;i < 8;i++)
  29.   {
  30.     digitalWrite(ledPins[i],(i <= topLED||(showPeak && i == peakValue)));
  31.   }
  32. }

復(fù)制代碼

所有資料51hei提供下載:
arduino聲音傳感器 模擬.rar (211.57 KB, 下載次數(shù): 40)








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