Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

ESP8266 Sound Reactive RGB LED Strip with MOSFET Control

View and Edit Project In Cirkit DesignerImage of ESP8266 Sound Reactive RGB LED Strip with MOSFET Control

Circuit Documentation

Summary

This circuit is a sound-reactive RGB LED strip light system. It uses an ESP8266 microcontroller to read the output from a sound sensor and control an RGB LED strip via MOSFETs. The system is powered by a 12V battery, with a voltage regulator providing the necessary 3V for the ESP8266. A 5V adapter powers the sound sensor.

Component List

  1. ESP8266

    • Description: A Wi-Fi enabled microcontroller.
    • Pins: 3V, G, D8, D7, D6, D5, D4, D3, D2, D1, D0, A0, S3, S2, S1, SC, S0, SK, EN, VIN, RST, VU
  2. 12V Battery

    • Description: Provides 12V power to the circuit.
    • Pins: -, +
  3. LED Strip

    • Description: RGB LED strip.
    • Pins: B, +12V, R, G
  4. Sound Sensor

    • Description: Detects sound levels.
    • Pins: 5V +, OUT, GND
  5. STP16NF06 N-Channel Power MOSFET

    • Description: Used to control the RGB LED strip.
    • Pins: gate, drain, source
  6. Voltage Regulator

    • Description: Regulates 12V to 3V for the ESP8266.
    • Pins: IN, GND, OUT
  7. 5V Adapter

    • Description: Provides 5V power to the sound sensor.
    • Pins: AC In 1, AC In 2, 5V, GND

Wiring Details

ESP8266

12V Battery

LED Strip

Sound Sensor

STP16NF06 N-Channel Power MOSFET

Voltage Regulator

5V Adapter

Code Documentation

/*
 * Sound Reactive RGB LED Strip Light
 * This code reads the output from a sound sensor and controls an RGB LED strip
 * using MOSFETs connected to the ESP8266 microcontroller.
 */

const int soundSensorPin = D2; // Sound sensor output pin
const int redLEDPin = D5;      // MOSFET gate for red LED
const int greenLEDPin = D6;    // MOSFET gate for green LED
const int blueLEDPin = D7;     // MOSFET gate for blue LED

void setup() {
  pinMode(soundSensorPin, INPUT);
  pinMode(redLEDPin, OUTPUT);
  pinMode(greenLEDPin, OUTPUT);
  pinMode(blueLEDPin, OUTPUT);
}

void loop() {
  int soundLevel = analogRead(soundSensorPin);
  int brightness = map(soundLevel, 0, 1023, 0, 255);

  analogWrite(redLEDPin, brightness);
  analogWrite(greenLEDPin, brightness);
  analogWrite(blueLEDPin, brightness);

  delay(10); // Small delay to smooth out the response
}

This code initializes the pins for the sound sensor and the MOSFET gates controlling the RGB LED strip. In the loop function, it reads the sound level from the sound sensor, maps the sound level to a brightness value, and writes this brightness value to the MOSFET gates, thereby controlling the brightness of the RGB LEDs based on the sound level.