Project tutorial
Audio Blink

Audio Blink © GPL3+

This lessons aims to show how to make an Audio Blink.

  • 1,756 views
  • 0 comments
  • 2 respects

Components and supplies

About this project

1. Schematic

As you can see from the schematic there are two macro-blocks: the audio block and the LEDs block.

The audio block is composed by an operational amplifier (LM358) used to amplify of a factor A = 1M/100k = 10, the signal provided from the microphone and the MSGEQ7. The MSGEQ7 samples the output signal of the amplifier and sends an analog value, proportional to the presence of each frequency in each band, to the Arduino's A0 input.

The LEDs are linked in series: the DOUT of the previous LED is attached to the DIN of the next. All the 5V and the GND are linked in parallel. The LEDs are driven by the Arduino's pin 3 using the Adafruit Neo Pixel Libary.

2. How it works

In this example only two values of the seven provided by the MSEQ7 are used. In particular those corresponding to the bands 400Hz and 1 kHz. In base of the analogRead() of these two values, the LEDs will blink more or less brightly and more or less from blue to red (blue + red = purple)! The eye effect is very nice!

3. Code

First of all we need to read the analog values coming out from the MSGEQ7. This can be done using the function readMSGEQ7() which generates step signals and reads the corresponding analog value according to the datasheet of the component.

After this, we can simply use the values to modify the color of the LEDs using the function colorWipe!

4. Mounting

You can make this project on a breadboard or on a perfboard (as we did) and put it in a very cool box!

5. Box

We decided to make a wood box for this project. It can be found in the attachments of the lesson. Laser-cut it!

Code

Code snippet #1Arduino
/*Arduino Audio Blink
The WS2812 LEDs will blink in base of your voice! Try it and have fun!
Author: Arturo Guadalupi <a.guadalupi@arduino.cc>*/
#include <Adafruit_NeoPixel.h>
const int msg7RESET = 2;
const int msg7Strobe = 4;
const int msg7DCout = A0;
const int PIN = 3;
const int NUMPIXELS = 15; //number of LEDs
int spectrumRead[7] = {0}; //variable uded to store the analog values from the MSGEQ7
int i; //variable used as index in the sketch
// Parameter 1 = number of pixels in strip
// Parameter 2 = Arduino pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
  //Pins used to drive the MSGEQ7
  pinMode(msg7RESET, OUTPUT);
  pinMode(msg7Strobe, OUTPUT);
}
void loop() {
  readMSGEQ7(); //read bands value
  //                    R                                      G  B   DELAY
  colorWipe(strip.Color(map(spectrumRead[2], 0, 1023, 0, 100), 0, 0), map(spectrumRead[2], 0, 1023, 0, 3));
  //                    R  G  B                                       DELAY
  colorWipe(strip.Color(0, 0, map(spectrumRead[3], 0, 1023, 0, 100)), map(spectrumRead[3], 0, 1023, 0, 3));
}
//Code used to get the analog values from the MSGEQ7. See datasheet for further informations
void readMSGEQ7()
{
  digitalWrite(msg7RESET, HIGH); // reset the MSGEQ7's counter
  delay(5);
  digitalWrite(msg7RESET, LOW);
  for (i = 0; i < 7; i++) {
    digitalWrite(msg7Strobe, LOW); // output each DC value for each freq band
    delayMicroseconds(35); // to allow the output to settle
    spectrumRead[i] = analogRead(msg7DCout);
    digitalWrite(msg7Strobe, HIGH);
  }
}
// Fill the dots one after the other with a color
void colorWipe(uint32_t c, uint8_t wait) {
  for (uint16_t i = 0; i < strip.numPixels(); i++) {
    strip.setPixelColor(i, c);
    strip.show();
  }
  delay(wait);
}
Github
https://github.com/adafruit/Adafruit_NeoPixel

Schematics

Schematic #1
750x750 5423d721b05135 5avlz1yboe

Comments

Similar projects you might like

Arduino Audio Reactive Desk Light

Project tutorial by Haziq Azri

  • 12,578 views
  • 5 comments
  • 30 respects

Audio Input

Project showcase by Arduino_Scuola

  • 8,404 views
  • 3 comments
  • 8 respects

Electronic Piano Keyboard With Preset Songs

Project tutorial by Lindsay Fox

  • 77,973 views
  • 60 comments
  • 150 respects

Talkative Automation || Audio from Arduino || HC-05 || Voice

Project tutorial by Vishalsoniindia

  • 2,865 views
  • 0 comments
  • 5 respects

POV Cylinder with Arduino Due

Project tutorial by Harald Bauer

  • 19,002 views
  • 23 comments
  • 61 respects

TV,DVD & Audio Control from Android and Arduino

Project tutorial by Jose Luis Bejarano Vasquez

  • 5,724 views
  • 1 comment
  • 19 respects
Add projectSign up / Login