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

Arduino Mega 2560-Based PWM Fan and LED Strip Controller with Potentiometer Adjustment

View and Edit Project In Cirkit DesignerImage of Arduino Mega 2560-Based PWM Fan and LED Strip Controller with Potentiometer Adjustment

Circuit Documentation

Summary

This circuit is designed to control four PWM fans and a 12V white LED strip using an Arduino Mega 2560. The fan speeds and LED brightness are controlled by two potentiometers. The circuit also includes a motor driver and several fuses for protection.

Component List

  1. Arduino Mega 2560

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

    • Description: Variable resistor used to control fan speed and LED brightness.
    • Pins: GND, Output, VCC
  3. 12V PWM Fan (120mm)

    • Description: 120mm fan with PWM control.
    • Pins: GND, +12V, TACH, PWM
  4. 12V White LED strip

    • Description: LED strip powered by 12V.
    • Pins: +12V, GND
  5. Toggle Switch SPST

    • Description: Single-pole single-throw switch.
    • Pins: L1, COM
  6. 5A Fuse

    • Description: Fuse rated at 5A for circuit protection.
    • Pins: 1, 2
  7. 12V 200Ah Battery

    • Description: 12V battery for powering the circuit.
    • Pins: GND, 12V
  8. Motor Driver - N-Mos PWM Trigger

    • Description: Motor driver for controlling the LED strip.
    • Pins: + PWM, GND, OUT -, OUT +, DC OUT +, DC IN -

Wiring Details

Arduino Mega 2560

Potentiometer (Fan Control)

Potentiometer (LED Control)

12V PWM Fan (120mm)

12V White LED strip

Toggle Switch SPST

5A Fuse

12V 200Ah Battery

Motor Driver - N-Mos PWM Trigger

Code Documentation

/*
 * This Arduino sketch controls four PWM fans and an LED strip.
 * Fan speeds are controlled by a potentiometer connected to A0.
 * LED brightness is controlled by a potentiometer connected to A1.
 */

// Pin definitions
const int fan1PWM = 2;
const int fan2PWM = 3;
const int fan3PWM = 4;
const int fan4PWM = 5;
const int ledPWM = 8;
const int potFan = A0;
const int potLED = A1;

void setup() {
  // Initialize PWM pins as outputs
  pinMode(fan1PWM, OUTPUT);
  pinMode(fan2PWM, OUTPUT);
  pinMode(fan3PWM, OUTPUT);
  pinMode(fan4PWM, OUTPUT);
  pinMode(ledPWM, OUTPUT);
  // Initialize serial communication for debugging
  Serial.begin(9600);
}

void loop() {
  // Read potentiometer values
  int potFanValue = analogRead(potFan);
  int potLEDValue = analogRead(potLED);
  // Map potentiometer values to PWM range (0-255)
  int fanSpeed = map(potFanValue, 0, 1023, 0, 255);
  int ledBrightness = map(potLEDValue, 0, 1023, 0, 255);
  // Set fan speeds
  analogWrite(fan1PWM, fanSpeed);
  analogWrite(fan2PWM, fanSpeed);
  analogWrite(fan3PWM, fanSpeed);
  analogWrite(fan4PWM, fanSpeed);
  // Set LED brightness
  analogWrite(ledPWM, ledBrightness);
  // Print values for debugging
  Serial.print("Fan Speed: ");
  Serial.print(fanSpeed);
  Serial.print("\tLED Brightness: ");
  Serial.println(ledBrightness);
  // Small delay to stabilize readings
  delay(100);
}

This code initializes the PWM pins for the fans and LED strip as outputs. It reads the values from the potentiometers connected to A0 and A1, maps these values to the PWM range (0-255), and sets the fan speeds and LED brightness accordingly. The values are also printed to the serial monitor for debugging purposes.