[Diao Ye learns programming] Arduino hands-on (190) --- MAX4466 sound module 5

The reference to 37 sensors and modules has been widely circulated on the Internet. In fact, there must be more than 37 sensor modules compatible with Arduino. In view of the fact that I have accumulated some sensor and actuator modules on hand, in accordance with the concept of true knowledge (must be hands-on), for the purpose of learning and communication, here I am going to try and do more experiments one by one. Whether it is successful or not, it will be recorded ——Small progress or unsolvable problems, I hope to be able to throw bricks and spark jade.

[Arduino] 168 sensor module series experiments (data code + simulation programming + graphic programming)
Experiment 190: MAX4466 sound sensor electret microphone amplifier microphone adjustable power amplifier module microphone

insert image description here
insert image description here
Knowledge point: The MAX4466 chip
is a micropower operational amplifier optimized for use as a microphone preamplifier. They offer the ideal combination of optimized gain bandwidth product and supply current, and enable low voltage work environment in an ultra-small package. The MAX4466 is gain-stable and provides a gain bandwidth of 200kHz with only 24µA of supply current. After decompression, a minimum stable gain of +5V/V is achieved and a 600KHZ gain bandwidth is provided. In addition, these amplifiers have rail-to-rail output, high AVOL, and excellent power supply rejection and common-mode rejection ratio, suitable for operation in noisy environments. Widely used in cellular phones, digital repeater devices, earphones, hearing aids, microphone preamplifiers, portable computers and speech recognition systems.

insert image description here
Main Features
1. +2.4V to +5.5V supply voltage version,
2. Can provide 5nA full shutdown (MAX4467/MAX4468)
3. Excellent power supply rejection ratio: 112dB
4. Excellent common-mode rejection ratio: 126dB
5. High AVOL: 125dB (RL= 100kΩ)
6. Rail-to-rail output
7. Low 24μA quiescent power supply
8. Current gain bandwidth product:
200kHz (MAX4465/MAX4467/MAX4469)
600kHz AV≥5 (MAX4466/MAX4468)
9. Space saving
5-Pin SC70 (MAX4465/MAX4466)
8-Pin SOT23 (MAX4467/MAX4468/MAX4469) Packages

insert image description here
[Arduino] 168 kinds of sensor module series experiments (data code + graphic programming + simulation programming)
Experiment 185: MAX4466 Sound Sensor Low Power Electret Microphone Amplifier Microphone Adjustable Power Amplifier Module
Project 12: Measuring Environmental Sound Level Waveform
Experimental wiring: MAX4466 microphone module OUT connects to A0 of Uno

Experimental open source code

/*
  【Arduino】168种传感器模块系列实验(资料代码+图形编程+仿真编程)
  实验一百八十五:MAX4466声音传感器 低功耗驻极体话筒放大器 麦克风可调功放模块
  项目十二:测量环境声级的波形
  实验接线:MAX4466咪头模块OUT接Uno的A0
*/

const int sampleWindow = 50; // Sample window width in mS (50 mS = 20Hz)
unsigned int sample;

void setup() {
    
    
  Serial.begin(9600);
}

void loop() {
    
    
  unsigned long startMillis = millis(); // Start of sample window
  unsigned int peakToPeak = 0;   // peak-to-peak level

  unsigned int signalMax = 0;
  unsigned int signalMin = 1024;

  // collect data for 50 mS
  while (millis() - startMillis < sampleWindow)
  {
    
    
    sample = analogRead(0);
    if (sample < 1024)  // toss out spurious readings
    {
    
    
      if (sample > signalMax)
      {
    
    
        signalMax = sample;  // save just the max levels
      }
      else if (sample < signalMin)
      {
    
    
        signalMin = sample;  // save just the min levels
      }
    }
  }

  peakToPeak = signalMax - signalMin;  // max - min = peak-peak amplitude
  double volts = (peakToPeak * 5.0) / 256;  // convert to volts
  Serial.println(volts);
}

Experimental serial port plotter return status

insert image description here

Experimental scene graph

insert image description here

[Arduino] 168 kinds of sensor module series experiments (data code + graphic programming + simulation programming)
Experiment 185: MAX4466 Sound Sensor Low Power Electret Microphone Amplifier Microphone Adjustable Power Amplifier Module
Project 13: RGB LED Lighting Acoustic Spectrum Control

Experimental open source code

/*
  【Arduino】168种传感器模块系列实验(资料代码+图形编程+仿真编程)
  实验一百八十五:MAX4466声音传感器 低功耗驻极体话筒放大器 麦克风可调功放模块
  项目十三:RGB LED 灯的声学频谱控制
  实验接线:MAX4466咪头模块OUT接Uno的A0
  Rpin 11
  Gpin 10
  Bpin 9
*/

#define Rpin 11
#define Gpin 10
#define Bpin 9
#define delayLEDS 3
#define sensorPin A0

float sensorValue = 0, filteredSignal = 0,
      filteredSignalValues[] = {
    
    3.4, 3.1, 2.7, 2.4, 2.1, 1.7, 1.3, 0.9, 0.4};

void setup () {
    
    
  Serial.begin (9600);
}

void loop () {
    
    
  MainFunction();
  delay(6);
}

void MainFunction() {
    
    
  sensorValue = (float) analogRead(sensorPin) * (5.0 / 1024.0);
  FilterSignal(sensorValue);
  Serial.print(sensorValue);
  Serial.print(" ");
  Serial.println(filteredSignal);
  CompareSignalFiltered(filteredSignal);
}

void FilterSignal(float sensorSignal) {
    
    
  filteredSignal = (0.945 * filteredSignal) + (0.0549 * sensorSignal);
}

void CompareSignalFiltered(float filteredSignal) {
    
    
  if (filteredSignal > filteredSignalValues[0]) {
    
    
    RGBColor(0, 127, 255);
    Serial.println("Blue");
  } else if (filteredSignal <= filteredSignalValues[0] && filteredSignal > filteredSignalValues[1]) {
    
    
    Serial.println("Azure");
    RGBColor(0, 255, 255);
  } else if (filteredSignal <= filteredSignalValues[1] && filteredSignal > filteredSignalValues[2]) {
    
    
    RGBColor(255, 0, 0);
    Serial.println("Cyan");
  } else if (filteredSignal <= filteredSignalValues[2] && filteredSignal > filteredSignalValues[3]) {
    
    
    RGBColor(0, 255, 127);
    Serial.println("Aqua marine");
  } else if (filteredSignal <= filteredSignalValues[3] && filteredSignal > filteredSignalValues[4]) {
    
    
    RGBColor(0, 255, 0);
    Serial.println("Green");
  } else if (filteredSignal <= filteredSignalValues[4] && filteredSignal > filteredSignalValues[5]) {
    
    
    RGBColor(255, 255, 0);
    Serial.println("Yellow");
  } else if (filteredSignal <= filteredSignalValues[5] && filteredSignal > filteredSignalValues[6]) {
    
    
    RGBColor(0, 0, 255);
    Serial.println("Magenta");
  } else if (filteredSignal <= filteredSignalValues[6] && filteredSignal > filteredSignalValues[7]) {
    
    
    RGBColor(255, 0, 127);
    Serial.println("Rose");
  } else if (filteredSignal <= filteredSignalValues[7] && filteredSignal > filteredSignalValues[8]) {
    
    
    RGBColor(255, 127, 0);
    Serial.println("Orange");
  } else if (filteredSignal <= filteredSignalValues[8]) {
    
    
    RGBColor(0, 127, 255);
    Serial.println("Red");
  } else {
    
    
    RGBColor(255, 50 , 0);
    Serial.println("Default: Blue");
  }
}

void RGBColor(int Rcolor, int Gcolor, int Bcolor) {
    
    
  analogWrite(Rpin, Rcolor);
  analogWrite(Gpin, Gcolor);
  analogWrite(Bpin, Bcolor);
  delay(delayLEDS);
}

Experimental serial port return

insert image description here

Experimental scene graph dynamic graph

insert image description here

Acoustic Spectrum Control of RGB LED Strips

How to build your own music visualizer for an RGB LED strip using Arduino
Here is a video showing you how to change the color of the LED strip
Based on the values ​​obtained from the sound sensor, the signal is digitally
filtered using a first order low pass IIR with a cutoff filter filtering
Filtered signal at 900Hz frequency is compared to multiple thresholds Value
used to determine which color to display based on Frequency of
sound sensed by the sensor, low frequency sounds
(barely audible) are shown in blue in the LED bar, always To
high frequency sounds (highly audible) are shown in red in the strip.

MainFunction()

Main function
This method reads the output value of the sound sensor using "sensorValue"
as a float and subtracts 1023, since the sound sensor provides an output of 1023 or 5V
when no sound is sensed, so we have the value when no sound is sensed For 0
& values ​​up to 1023 when it senses sound (vibration in the air) we convert the signal
to volts.

 FilterSignal()

Filter the signal Filter the signal
using a first order IIR low pass digital filter created in Matlab
and assign the value to the variable "filteredSignal"

CompareSignalFiltered()

Comparing Signal Filtering
Comparing the "filteredSignal" variable to the "filteredSignalValues" array
Determine where the variable value we are comparing is less than, greater than or in between, our
threshold assigns a color to the LED strip and prints the color representing what
we set.

   RGBColor()

rgbcolor()
sends a value between 0 and 255 representing the color to the pins defined for each RGB color
we want; Google the RGB color wheel to help you understand how colors are created.

Version 1.2
reverses the order of numbers in the "filteredSignalValues" array from high to low and changes
the equation from the "sensorValue" variable from 1023 - "analogRead(A0)" to "analogRead(A0)" to make it
easier read.
The sound sensor outputs 5V or 1023, which is read from the Arduino as input when there is no sound, and the sound is high, the output 0v
sensor has reverse output logic.

Guess you like

Origin blog.csdn.net/weixin_41659040/article/details/132132198