Arduino Mega 2560 Music-Responsive LED Lighting System with TRIAC Control
View and Edit Project In Cirkit Designer
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
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.
MP3 BT 4.1 Decoder
- Description: Bluetooth MP3 decoder module.
- Pins: +5V, GND, R, L.
BT139 600
- Description: TRIAC for switching high power loads.
- Pins: MT1, MT2, GATE.
Power LED 12V 10W 0.8-0.9A
- Description: High-power LED.
- Pins: +, -.
MCB
- Description: Miniature Circuit Breaker.
- Pins: IN, OUT.
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).
power 220v
- Description: 220V AC power source.
- Pins: hot wire, neutral wire.
Wiring Details
Arduino Mega 2560
- 5V connected to +5V of MP3 BT 4.1 Decoder.
- GND connected to GND of MP3 BT 4.1 Decoder.
- A0 connected to R and L of MP3 BT 4.1 Decoder.
- D2 PWM connected to GATE of BT139 600.
- D3 PWM connected to GATE of BT139 600.
- D4 PWM connected to GATE of BT139 600.
- D5 PWM connected to GATE of BT139 600.
- D6 PWM connected to GATE of BT139 600.
- D7 PWM connected to GATE of BT139 600.
- D8 PWM connected to GATE of BT139 600.
- D9 PWM connected to GATE of BT139 600.
- D10 PWM connected to GATE of BT139 600.
- D11 PWM connected to GATE of BT139 600.
- D12 PWM connected to GATE of BT139 600.
- D13 PWM connected to GATE of BT139 600.
- D22 connected to GATE of BT139 600.
- D23 connected to GATE of BT139 600.
- D24 connected to GATE of BT139 600.
- D25 connected to GATE of BT139 600.
- D26 connected to GATE of BT139 600.
- D27 connected to GATE of BT139 600.
- D28 connected to GATE of BT139 600.
- D30 connected to GATE of BT139 600.
- D31 connected to GATE of BT139 600.
- D32 connected to GATE of BT139 600.
- D34 connected to GATE of BT139 600.
- D35 connected to GATE of BT139 600.
- D36 connected to GATE of BT139 600.
- D37 connected to GATE of BT139 600.
- D38 connected to GATE of BT139 600.
- D39 connected to GATE of BT139 600.
- D40 connected to GATE of BT139 600.
- D41 connected to GATE of BT139 600.
- D42 connected to GATE of BT139 600.
- D43 connected to GATE of BT139 600.
- D49 connected to GATE of BT139 600.
- D50 connected to GATE of BT139 600.
- D51 connected to GATE of BT139 600.
- D52 connected to GATE of BT139 600.
- D53 connected to GATE of BT139 600.
MP3 BT 4.1 Decoder
- +5V connected to 5V of Arduino Mega 2560.
- GND connected to GND of Arduino Mega 2560.
- R and L connected to A0 of Arduino Mega 2560.
BT139 600
- GATE connected to various PWM pins of Arduino Mega 2560.
- MT1 connected to 12V-24V Output (DC) of POWER SUPPLY 12V 5AMP.
- MT2 connected to + of Power LED 12V 10W 0.8-0.9A.
Power LED 12V 10W 0.8-0.9A
- + connected to MT2 of BT139 600.
- - connected to OUT of MCB.
MCB
- IN connected to GND (DC) of POWER SUPPLY 12V 5AMP.
- OUT connected to - of Power LED 12V 10W 0.8-0.9A.
POWER SUPPLY 12V 5AMP
- 220V Positive Pole (AC) connected to hot wire of power 220v.
- 220V Negative Pole (AC) connected to neutral wire of power 220v.
- GND (DC) connected to IN of MCB.
- 12V-24V Output (DC) connected to MT1 of BT139 600.
power 220v
- hot wire connected to 220V Positive Pole (AC) of POWER SUPPLY 12V 5AMP.
- neutral wire connected to 220V Negative Pole (AC) of POWER SUPPLY 12V 5AMP.
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.