3386

帖子

0

TA的资源

五彩晶圆(中级)

41
 

实验的视频记录

优酷:https://v.youku.com/v_show/id_XNTkyMTAwNDQwOA==.html?spm=a2hcb.playlsit.page.1

B站:https://www.bilibili.com/video/BV1gP4y117Xx/?vd_source=98c6b1fc23b2787403d97f8d3cc0b7e5

 


 

 

回复

3386

帖子

0

TA的资源

五彩晶圆(中级)

42
 

  【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)

  实验一百七十七:Wemos D1 R32 ESP32开发板

  项目之四十七:快速傅里叶变换256位频谱仪

 

/*
  【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
  实验一百七十七:Wemos D1 R32 ESP32开发板
  项目之四十七:快速傅里叶变换256位频谱仪
*/

#include  "arduinoFFT.h" 
#include <FastLED.h>    

#define NUM_LEDS 256    
#define LED_TYPE WS2812 
#define COLOR_ORDER GRB 

arduinoFFT FFT = arduinoFFT(); 
CRGB leds[NUM_LEDS];           

#define CHANNEL 39 
#define DATA_PIN 23 

const uint8_t max_bright = 2;          
const uint16_t samples = NUM_LEDS / 4;
const byte halfsamples = samples / 2;  
uint8_t gHue;                          
int value;                             
double vReal[samples];                 
double vImag[samples];                 
char toData[halfsamples];              

int pointJump[halfsamples]; 
int uJump[halfsamples];     
int dJump[halfsamples];    

int uValue;                 
int dValue;                 
int tValue;                 
int toDown = 0;             
uint8_t toDownSpeed = 3;    
int pointDown = 0;          
uint8_t pointDownSpeed = 9; 

void setup(){
  delay(100);              
  Serial.println("Ready"); 
  FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
  FastLED.setBrightness(max_bright); 
}

void loop(){
  FastLED.clear();                         
  EVERY_N_MILLISECONDS(10) {
    gHue += 10;  
  }
  for (int i = 0; i < samples; i++)        
  {
    value = analogRead(CHANNEL); 
    vReal[i] = value;       
    vImag[i] = 0.0;         
  }
  
  FFT.Windowing(vReal, samples, FFT_WIN_TYP_HAMMING, FFT_FORWARD);
  FFT.Compute(vReal, vImag, samples, FFT_FORWARD);
  FFT.ComplexToMagnitude(vReal, vImag, samples);
  
  for (int i = 0; i < halfsamples; i++) 
  {
    toData[i] = vReal[i + halfsamples / 2];   
    toData[i] = constrain(toData[i], 0, 100); 
    toData[i] = map(toData[i], 0, 100, 1, 7); 
  }
  for (int i = 0; i < halfsamples; i++) 
  {
    uValue = toData[i];    
    uJump[i]++;            
    if (uValue > uJump[i]) 
    {
      uValue = uJump[i]; 
    }
    else
    {
      uJump[i] = uValue;
    }
    dValue = uValue; 
    toDown++;                      
    if (toDown % toDownSpeed == 0) 
    {
      dJump[i]--; 
      toDown = 0; 
    }
    if (dValue > pointJump[i]) 
    {
      dJump[i] = dValue; 
    }
    else
    {
      dValue = dJump[i]; 
    }
    tValue = uValue;                     
    pointDown++;                         
    if (pointDown % pointDownSpeed == 0) 
    {
      pointJump[i]--; 
      pointDown = 0;  
    }
    if (tValue > pointJump[i]) 
    {
      pointJump[i] = tValue; 
    }
    else
    {
      tValue = pointJump[i]; 
    }
    fill_rainbow(leds + 8 * i, uValue, gHue, 30);
    fill_rainbow(leds + 8 * i, dValue, gHue, 30);
    fill_solid(leds + 8 * i + tValue, 1, CRGB::White);
    
  }
  FastLED.show(); 
  delay(2);      
}

 

 
 

回复

3386

帖子

0

TA的资源

五彩晶圆(中级)

43
 

实验场景图

 

 
 
 

回复

3386

帖子

0

TA的资源

五彩晶圆(中级)

44
 

实验的视频记录

优酷:https://v.youku.com/v_show/id_XNTkxOTQxODA2OA==.html?spm=a2hcb.playlsit.page.3

B站:https://www.bilibili.com/video/BV1ye4y1s7n1/?vd_source=98c6b1fc23b2787403d97f8d3cc0b7e5

 


 

 
 
 

回复

3386

帖子

0

TA的资源

五彩晶圆(中级)

45
 

实验场景图  动态图

 

 

 
 
 

回复

3386

帖子

0

TA的资源

五彩晶圆(中级)

46
 

实验的视频记录

优酷:https://v.youku.com/v_show/id_XNTkxOTQxODEzNg==.html?spm=a2hcb.playlsit.page.1

B站:https://www.bilibili.com/video/BV1hg411q7yo/?vd_source=98c6b1fc23b2787403d97f8d3cc0b7e5

 


 

 
 
 

回复

3386

帖子

0

TA的资源

五彩晶圆(中级)

47
 

  【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)

  实验一百七十七:Wemos D1 R32 ESP32开发板

  项目之四十八:Arduino 和 FastLED多彩音乐灯

 

/*
  【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
  实验一百七十七:Wemos D1 R32 ESP32开发板
  项目之四十八:Arduino 和 FastLED多彩音乐灯
*/

#include <FastLED.h>
#define SAMPLEPERIODUS 200
#define MIC_PIN 39
#define LED_DT 23
#define COLOR_ORDER GRB
#define LED_TYPE WS2812
#define NUM_LEDS 256
uint8_t max_bright = 33;
struct CRGB leds[NUM_LEDS];
CRGBPalette16 currentPalette = RainbowColors_p;
CRGBPalette16 targetPalette;

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
  LEDS.addLeds<LED_TYPE, LED_DT, COLOR_ORDER>(leds, NUM_LEDS);
  FastLED.setBrightness(max_bright);
}

float bassFilter(float sample) {
  static float xv[3] = {0, 0, 0}, yv[3] = {0, 0, 0};
  xv[0] = xv[1]; xv[1] = xv[2];
  xv[2] = sample / 9.1f;
  yv[0] = yv[1]; yv[1] = yv[2];
  yv[2] = (xv[2] - xv[0]) + (-0.7960060012f * yv[0]) + (1.7903124146f * yv[1]);
  return yv[2];
}

float envelopeFilter(float sample) {
  static float xv[2] = {0, 0}, yv[2] = {0, 0};
  xv[0] = xv[1];
  xv[1] = sample / 160.f;
  yv[0] = yv[1];
  yv[1] = (xv[0] + xv[1]) + (0.9875119299f * yv[0]);
  return yv[1];
}

float beatFilter(float sample) {
  static float xv[3] = {0, 0, 0}, yv[3] = {0, 0, 0};
  xv[0] = xv[1]; xv[1] = xv[2];
  xv[2] = sample / 7.015f;
  yv[0] = yv[1]; yv[1] = yv[2];
  yv[2] = (xv[2] - xv[0]) + (-0.7169861741f * yv[0]) + (1.4453653501f * yv[1]);
  return yv[2];
}

void loop() {
  unsigned long time = micros();
  float sample, value, envelope, beat, thresh, micLev;
  for (uint8_t i = 0; ; ++i) {
    sample = (float)analogRead(MIC_PIN);
    micLev = ((micLev * 67) + sample) / 68;
    sample -= micLev;
    value = bassFilter(sample);
    value = abs(value);
    envelope = envelopeFilter(value);
    if (i == 200) {
      beat = beatFilter(envelope);
      thresh = 0.02f * 75.;

      if (beat > thresh) {
        digitalWrite(LED_BUILTIN, LOW);

        int strt = random8(NUM_LEDS / 2);
        int ende = strt + random8(NUM_LEDS / 2);
        for (int i = strt; i < ende; i++) {
          uint8_t index = inoise8(i * 30, millis() + i * 30);
          leds[i] = ColorFromPalette(currentPalette, index, 255, LINEARBLEND);
        }
      } else {
        digitalWrite(LED_BUILTIN, HIGH);
      }
      i = 0;
    }

    EVERY_N_SECONDS(5) {
      uint8_t baseC = random8();
      targetPalette = CRGBPalette16(CHSV(baseC + random8(32), 255, random8(128, 255)),
                                    CHSV(baseC + random8(64), 255, random8(128, 255)),
                                    CHSV(baseC + random8(64), 192, random8(128, 255)),
                                    CHSV(baseC + random8(),   255, random8(128, 255)));
    }

    EVERY_N_MILLISECONDS(50) {
      uint8_t maxChanges = 24;
      nblendPaletteTowardPalette(currentPalette, targetPalette, maxChanges);
    }

    EVERY_N_MILLIS(50) {
      fadeToBlackBy(leds, NUM_LEDS, 64);
      FastLED.show();
    }

    for (unsigned long up = time + SAMPLEPERIODUS; time > 20 && time < up; time = micros()) {  }

  } // for i
} // loop()

 

 
 
 

回复

3386

帖子

0

TA的资源

五彩晶圆(中级)

48
 

实验场景图

 

 
 
 

回复

3386

帖子

0

TA的资源

五彩晶圆(中级)

49
 

实验的视频记录

优酷:

B站:https://www.bilibili.com/video/BV14K411d7y2/?vd_source=98c6b1fc23b2787403d97f8d3cc0b7e5

 


 

 
 
 

回复

3386

帖子

0

TA的资源

五彩晶圆(中级)

50
 

实验场景图  动态图

 

 

 
 
 

回复

3386

帖子

0

TA的资源

五彩晶圆(中级)

51
 

实验的视频记录

优酷:

B站:https://www.bilibili.com/video/BV1nK411d78Z/?vd_source=98c6b1fc23b2787403d97f8d3cc0b7e5

 


 

 
 
 

回复
您需要登录后才可以回帖 登录 | 注册

随便看看
查找数据手册?

EEWorld Datasheet 技术支持

相关文章 更多>>
关闭
站长推荐上一条 1/9 下一条

 
EEWorld订阅号

 
EEWorld服务号

 
汽车开发圈

About Us 关于我们 客户服务 联系方式 器件索引 网站地图 最新更新 手机版

站点相关: 国产芯 安防电子 汽车电子 手机便携 工业控制 家用电子 医疗电子 测试测量 网络通信 物联网

北京市海淀区中关村大街18号B座15层1530室 电话:(010)82350740 邮编:100190

电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号 Copyright © 2005-2025 EEWORLD.com.cn, Inc. All rights reserved
快速回复 返回顶部 返回列表