17256 views|41 replies

3386

Posts

0

Resources
The OP
 

[Flower carving DIY] Interesting and fun music visualization series of small projects (02) --- OLED spectrum light [Copy link]

 
This post was last edited by eagler8 on 2021-10-5 19:26

For this project, four specifications of OLED organic screens were specially prepared.

This post is from DIY/Open Source Hardware

Latest reply

It would be better if the screen was a little bigger, life is all about experimentation! Haha  Details Published on 2021-10-25 13:25
 

3386

Posts

0

Resources
2
 

OLED (Organic Light-Emitting Diode)
is a new type of product in mobile phone OLED and is known as the "dream display". OLED display technology is different from traditional LCD display. It does not require a backlight and uses a very thin organic material coating and a glass substrate (or a flexible organic substrate). When current passes through, these organic materials will emit light. In addition, OLED display screens can be made lighter and thinner, with a wider viewing angle, and can significantly save power consumption.

This post is from DIY/Open Source Hardware
 
 

3386

Posts

0

Resources
3
 
This post was last edited by eagler8 on 2021-10-4 14:28

OLED technology features
(1) The core layer of OLED devices is very thin, less than 1mm, which is 1/3 of that of liquid crystal.
(2) OLED devices are all-solid-state structures, without vacuum or liquid materials, and have good shock resistance. They can adapt to harsh environments such as huge acceleration and vibration.
(3) The active light-emitting characteristics make OLED almost unlimited in viewing angle. The viewing angle can generally reach 170 degrees, with a wide viewing angle and no distortion from the side.
(4) The response time of OLED display screen exceeds that of TFT-LCD screen. The response time of TFT-LCD is about tens of milliseconds. The best TFT-LCD response time is only 12 milliseconds. The response time of OLED display screen is about a few microseconds to tens of microseconds.
(5) OLED has good low-temperature characteristics and can display normally at minus 40 degrees Celsius. Currently, OLED is also used as a display screen on space suits. The response speed of TFT-LCD changes with temperature. At low temperatures, its response speed slows down. Therefore, the display effect of liquid crystal is not good at low temperatures.
(6) OLED uses the principle of organic light emission, requiring very little material. The manufacturing process is less than that of liquid crystal, which uses liquid light emission. The LCD screen has 3 fewer processes, which greatly reduces the cost.
(7) The diodes used by OLED emit light by themselves, so there is no need for a backlight source. The light conversion efficiency is high and the energy consumption is lower than that of liquid crystal. OLED can be manufactured on substrates of different materials. Manufacturers can even print circuits on elastic materials to make flexible displays that can be bent.
(8) Low voltage DC drive, less than 5V, can be lit with batteries. High brightness, up to 300 lumens or more.

This post is from DIY/Open Source Hardware
 
 
 

3386

Posts

0

Resources
4
 

Main experimental materials

This post is from DIY/Open Source Hardware
 
 
 

3386

Posts

0

Resources
5
 

MAX9814 Microphone Amplifier Module The
MAX9814 is a low-cost, high-performance microphone amplifier with automatic gain control (AGC) and low-noise microphone bias. The device features a low-noise front-end amplifier, a variable gain amplifier (VGA), an output amplifier, a microphone bias voltage generator, and an AGC control circuit.
●Automatic gain control (AGC)
●3 gain settings (40dB, 50dB, 60dB)
●Programmable action time
●Programmable action and release time ratio
●Supply voltage range 2.7V ~ 5.5V
●Low THD: 0.04% (typical)
●Low power shutdown mode
●Built-in 2V low-noise microphone bias

This post is from DIY/Open Source Hardware
 
 
 

3386

Posts

0

Resources
6
 

MAX9814 microphone amplifier module schematic diagram

This post is from DIY/Open Source Hardware
 
 
 

3386

Posts

0

Resources
7
 

0.91-inch OLED LCD display module parameters
Driver chip: SSD1306
Support interface: I2C
Display color: white
High resolution: 128×32
Viewing angle: greater than 160°
Operating voltage: 3.3V/5V
Module size: 36 x 12.5 (mm)

This post is from DIY/Open Source Hardware
 
 
 

3386

Posts

0

Resources
8
 

0.96 inch OLED module main parameters
Voltage: 3V~5V DC
Operating temperature: -30℃~70℃
Driving duty: 1/64 duty
High resolution: 128 * 64
Panel size: 26.70 * 19.26 * 1.85mm / 1.03 * 0.76 * 0.07 inches (approx.)
Active area: 21.74 * 11.2mm / 0.86*0.44 inches (approx.)
Driver IC: SSD1306
128 * 64 LED display module, supports a variety of control chips.
Fully compatible with 51 series, MSP430 series, STM32/2, CSR IC, etc.
Ultra-low power consumption: full screen lit 0.08W
ultra-high brightness and contrast adjustable
With embedded driver/controller
Interface type is IIC

This post is from DIY/Open Source Hardware
 
 
 

3386

Posts

0

Resources
9
 
This post was last edited by eagler8 on 2021-10-6 06:57

[Flower carving hands-on] Music visualization series of small projects (02) --- OLED spectrum light

Project 1: Using the MAX9814 sound module to test the dynamic waveform of ambient music

Experimental open source code

/*
  【花雕动手做】音乐可视化系列小项目(02)---OLED频谱灯
  项目之一:使用MAX9814声音模块测试环境音乐的动态波形
  实验接线:
  MAX9814  Arduino
  VCC        5V
  GND        GND
  OUT        A0
*/

const int sampleWindow = 50; // 以mS为单位的采样窗口宽度(50 mS = 20Hz)
unsigned int sample;

void setup() {
  Serial.begin(9600);
  pinMode(A0, INPUT);
}

void loop() {
  unsigned long startMillis = millis(); // 样本窗口的开始
  unsigned int peakToPeak = 0;   // 峰峰值

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

  // collect data for 50 mS
  while (millis() - startMillis < sampleWindow)
  {
    sample = analogRead(A0);
    if (sample < 1024)  // 抛出错误的读数
    {
      if (sample > signalMax)
      {
        signalMax = sample;  // 只保存最大级别
      }
      else if (sample < signalMin)
      {
        signalMin = sample;  // 仅保存最低级别
      }
    }
  }
  peakToPeak = signalMax - signalMin;  // max-min =峰峰值幅度
  double volts = (peakToPeak * 5.0) / 166;
  Serial.println(volts);
}

This post is from DIY/Open Source Hardware
 
 
 

3386

Posts

0

Resources
10
 

Experimental serial port return status

This post is from DIY/Open Source Hardware
 
 
 

3386

Posts

0

Resources
11
 

Open the IDE's serial port plotter

This post is from DIY/Open Source Hardware
 
 
 

3386

Posts

0

Resources
12
 

This post is from DIY/Open Source Hardware
 
 
 

3386

Posts

0

Resources
13
 

Experimental scene diagram

This post is from DIY/Open Source Hardware
 
 
 

3386

Posts

0

Resources
14
 

[Flower carving hands-on] Music visualization series of small projects (02) --- OLED spectrum light

Project 1: Using the MAX9814 sound module to test the dynamic waveform of ambient music

Experimental video clips

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


This post is from DIY/Open Source Hardware
 
 
 

3386

Posts

0

Resources
15
 

Experimental scene diagram Dynamic diagram

This post is from DIY/Open Source Hardware
 
 
 

3386

Posts

0

Resources
16
 
This post was last edited by eagler8 on 2021-10-6 06:58

[Flower carving hands-on] Music visualization series of small projects (02) --- OLED spectrum light

Project 2: 11-segment 0.91-inch OLED LCD screen with sound visualization spectrum light

Experimental open source code

/*
  【花雕动手做】音乐可视化系列小项目(02)---OLED频谱灯
  项目之二:0.91寸OLED液晶屏声音可视化频谱灯
  实验接线: max9814接A0
  oled模块    Ardunio Uno
  GND---------GND接地线
  VCC---------5V 接电源
  SDA---------A4
  SCL ------- A5
*/

#include "arduinoFFT.h"
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SAMPLES 64 // power of 2
#define SAMPLING_FREQ 8000 // 12 kHz Fmax = sampleF /2 
#define AMPLITUDE 100 // 灵敏度
#define FREQUENCY_BANDS 14
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 32
#define BARWIDTH 11
#define BARS 11
#define ANALOG_PIN A0
#define OLED_RESET     -1 // 重置引脚 #(如果共享 Arduino 重置引脚,则为 -1)

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
double vImag[SAMPLES];
double vReal[SAMPLES];
unsigned long sampling_period_us;
arduinoFFT fft = arduinoFFT(vReal, vImag, SAMPLES, SAMPLING_FREQ);
//调整参考以去除背景噪声
float reference = log10(60.0);
double coutoffFrequencies[FREQUENCY_BANDS];

void setup() {
  // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
  if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3C for 128x32
    for (;;); // Don't proceed, loop forever
  }

  // Setup display
  display.clearDisplay();
  display.display();
  display.setRotation(0);
  display.invertDisplay(false);

  sampling_period_us = (1.0 / SAMPLING_FREQ ) * pow(10.0, 6);

  // 计算截止频率,以对数标度为基数 POt
  double basePot = pow(SAMPLING_FREQ / 2.0, 1.0 / FREQUENCY_BANDS);
  coutoffFrequencies[0] = basePot;
  for (int i = 1 ; i < FREQUENCY_BANDS; i++ ) {
    coutoffFrequencies = basePot * coutoffFrequencies[i - 1];
  }

  // 绘制虚线以分离频段
  for (int i = 0; i < BARS - 1 ; i++) {
    for (int j = 0; j < SCREEN_HEIGHT ; j += 4) {
      display.writePixel((i + 1)*BARWIDTH + 2 , j, SSD1306_WHITE );
    }
  }
  display.drawRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, SSD1306_WHITE);
}

int oldHeight[20];
int oldMax[20];
double maxInFreq;

void loop() {
  // 采样
  for (int i = 0; i < SAMPLES; i++) {
    unsigned long newTime = micros();
    int value = analogRead(ANALOG_PIN);
    vReal = value;
    vImag = 0;
    while (micros() < (newTime + sampling_period_us)) {
      yield();
    }
  }

  // 计算 FFT
  fft.DCRemoval();
  fft.Windowing(FFT_WIN_TYP_HAMMING, FFT_FORWARD);
  fft.Compute(FFT_FORWARD);
  fft.ComplexToMagnitude();

  double median[20];
  double max[20];
  int index = 0;
  double hzPerSample = (1.0 * SAMPLING_FREQ) / SAMPLES; //
  double hz = 0;
  double maxinband = 0;
  double sum = 0;
  int count = 0;
  for (int i = 2; i < (SAMPLES / 2) ; i++) {
    count++;
    sum += vReal;
    if (vReal >  max[index] ) {
      max[index] = vReal;
    }
    if (hz > coutoffFrequencies[index]) {
      median[index] = sum / count;
      sum = 0.0;
      count = 0;
      index++;
      max[index] = 0;
      median[index]  = 0;
    }
    hz += hzPerSample;
  }
  // 计算每个频段的中值和最大值
  if ( sum > 0.0) {
    median[index] =  sum / count;
    if (median[index] > maxinband) {
      maxinband = median[index];
    }
  }
  int bar = 0;

  for (int i = FREQUENCY_BANDS - 1; i >= 3; i--) {
    int newHeight = 0;
    int newMax = 0;
    // 计算实际分贝
    if (median > 0 && max > 0 ) {
      newHeight = 20.0 * (log10(median ) - reference);
      newMax = 20.0 * (log10(max ) - reference);
    }

    // 调整最小和最大级别
    if (newHeight < 0 ||  newMax < 0) {
      newHeight = 1;
      newMax = 1;
    }
    if (newHeight >= SCREEN_HEIGHT - 2) {
      newHeight = SCREEN_HEIGHT - 3;
    }
    if (newMax >= SCREEN_HEIGHT - 2) {
      newMax = SCREEN_HEIGHT - 3;
    }

    int barX = bar * BARWIDTH + 5;
    // 删除旧水平中位数
    if (oldHeight > newHeight) {
      display.fillRect(barX, newHeight + 1, 7, oldHeight, SSD1306_BLACK);
    }
    // 删除旧的最大级别
    if ( oldMax > newHeight) {
      for (int j = oldMax; j > newHeight; j -= 2) {
        display.drawFastHLine(barX , j, 7, SSD1306_BLACK);
      }
    }
    // 绘制新的最大级别
    for (int j = newMax; j > newHeight; j -= 2) {
      display.drawFastHLine(barX , j, 7,  SSD1306_WHITE);
    }
    // 绘制新的级别中位数
    display.fillRect(barX , 1, 7, newHeight, SSD1306_WHITE);
    oldMax = newMax;
    oldHeight = newHeight;
    bar++;
  }
  display.drawFastHLine(0 , SCREEN_HEIGHT - 1, SCREEN_WIDTH, SSD1306_WHITE);
  display.display();
}

This post is from DIY/Open Source Hardware
 
 
 

3386

Posts

0

Resources
17
 

Experimental scene diagram

This post is from DIY/Open Source Hardware
 
 
 

3386

Posts

0

Resources
18
 

[Flower carving hands-on] Music visualization series of small projects (02) --- OLED spectrum light

Project 2: 0.91-inch OLED LCD screen sound visualization spectrum light

Experimental video clips

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


This post is from DIY/Open Source Hardware
 
 
 

3386

Posts

0

Resources
19
 

Experimental scene diagram Dynamic diagram

This post is from DIY/Open Source Hardware
 
 
 

3386

Posts

0

Resources
20
 

[Flower carving hands-on] Music visualization series of small projects (02) --- OLED spectrum light

Project 3: 0.96-inch OLED LCD screen sound visualization spectrum light

Experimental video clips

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


This post is from DIY/Open Source Hardware
 
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list