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

Arduino Mega 2560 Music-Responsive LED Lighting System with TRIAC Control

View and Edit Project In Cirkit DesignerImage of Arduino Mega 2560 Music-Responsive LED Lighting System with TRIAC Control

Circuit Documentation

Summary

This circuit is designed to control multiple Power LEDs using TRIACs, which are triggered by an Arduino Mega 2560 based on music input from an MP3 player. The TRIAC gates are connected to PWM pins on the Arduino, and the music input modulates these PWM signals to control the brightness of the LEDs.

Component List

  1. Arduino Mega 2560

    • Description: Microcontroller board based on the ATmega2560.
    • Pins: IOREF, RESET, 3V3, 5V, GND, VIN, A0-A15, D0-D53, PWM, AREF, SDA, SCL.
  2. MP3 BT 4.1 Decoder

    • Description: Bluetooth MP3 decoder module.
    • Pins: +5V, GND, R, L.
  3. BT139 600

    • Description: TRIAC for switching high power loads.
    • Pins: MT1, MT2, GATE.
  4. Power LED 12V 10W 0.8-0.9A

    • Description: High-power LED.
    • Pins: +, -.
  5. MCB

    • Description: Miniature Circuit Breaker.
    • Pins: IN, OUT.
  6. POWER SUPPLY 12V 5AMP

    • Description: Power supply unit providing 12V DC at 5A.
    • Pins: 220V Positive Pole (AC), 220V Negative Pole (AC), GND, GND (DC), 12V-24V Output (DC).
  7. power 220v

    • Description: 220V AC power source.
    • Pins: hot wire, neutral wire.

Wiring Details

Arduino Mega 2560

MP3 BT 4.1 Decoder

BT139 600

Power LED 12V 10W 0.8-0.9A

MCB

POWER SUPPLY 12V 5AMP

power 220v

Code Documentation

/*
 * Arduino Sketch to trigger TRIACs based on music input from an MP3 player.
 * The circuit consists of multiple Power LEDs controlled by TRIACs, which are
 * triggered by the Arduino Mega 2560. The TRIAC gates are connected to PWM
 * pins on the Arduino, and the music input will modulate these PWM signals.
 */

const int triacPins[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 22, 23, 24, 25,
                         26, 27, 28, 30, 31, 32, 34, 35, 36, 37, 38, 39, 40, 41,
                         42, 43};
const int numTriacs = sizeof(triacPins) / sizeof(triacPins[0]);

void setup() {
  // Initialize all TRIAC pins as outputs
  for (int i = 0; i < numTriacs; i++) {
    pinMode(triacPins[i], OUTPUT);
  }
  // Initialize serial communication for debugging
  Serial.begin(9600);
}

void loop() {
  // Read the analog input from the MP3 player (assumed to be on A0)
  int musicInput = analogRead(A0);
  // Map the analog input to a PWM value (0-255)
  int pwmValue = map(musicInput, 0, 1023, 0, 255);
  // Output the PWM value to all TRIACs
  for (int i = 0; i < numTriacs; i++) {
    analogWrite(triacPins[i], pwmValue);
  }
  // Debugging: print the music input and PWM value
  Serial.print("Music Input: ");
  Serial.print(musicInput);
  Serial.print(" | PWM Value: ");
  Serial.println(pwmValue);
  // Small delay to avoid overwhelming the serial output
  delay(10);
}

This code initializes the TRIAC pins as outputs and reads the analog input from the MP3 player. It maps the analog input to a PWM value and outputs this value to all TRIACs, effectively controlling the brightness of the Power LEDs based on the music input.