Skip to content

4.3.10. Bluetooth Variable DC Fan Controller

Description In this project, learners will build an adjustable cooling fan station controlled wirelessly using an HC-05 Bluetooth module, a 5V DC Motor, an L298N Motor Driver, an I2C 1602 LCD, and an Active Buzzer. Users send speed codes from a smartphone, which controls the motor speed via Pulse Width Modulation (PWM) and outputs the percentage speed on the LCD.
Use case This system models remote temperature ventilation systems, wireless fan speed switches, industrial motor velocity nodes, and automated cooling vents.

Components (Things You will need)

Arduino Uno Arduino USB Cable Bread Board Jumper Wires LCD Display Buzzer DC Motor Motor Driver Bluetooth Module Fan Blades

Building the circuit

Things Needed:

  • Arduino Uno Core Board = 1
  • HC-05 Bluetooth Module = 1
  • DC Motor = 1
  • L298N Motor Driver Module = 1
  • I2C 1602 LCD Module = 1
  • Active Buzzer = 1
  • USB Cable & Jumper Wires
  • Bread Board
  • Fan Blades

Mounting the component on the breadboard and wiring the circuit

Step 1: Establish 5V and GND rails on the breadboard from the Arduino pins.

Step 2: Connect HC-05 Bluetooth: VCC to 5V, GND to GND, TXD to Pin 2, and RXD to Pin 3.

Step 3: Connect the L298N driver: VCC to the 5V rail, GND to GND, ENA (PWM) to Pin 9, IN1 to Pin 8, and IN2 to Pin 7. Connect the DC Motor to the Out1/Out2 terminal blocks.

Step 4: Place the I2C LCD: Connect VCC to 5V, GND to GND, SDA to A4, and SCL to A5.

Step 5: Connect the active buzzer positive (+) pin to Pin 4 and negative (-) pin to the GND rail.

Step 6: Double-check all connections, ensuring L298N share the common ground rail, then plug in the USB cable.

Components on breadboard

Make sure to connect the Arduino USB cable to the Arduino board.

PROGRAMMING

Step 1: Open your Arduino IDE. See how to set up here: Getting Started.

Step 2: Write the complete program implementing the system logic with appropriate pin definitions, setup configuration, and the main control loop.

#include <SoftwareSerial.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

SoftwareSerial BT(2, 3); // RX, TX
LiquidCrystal_I2C lcd(0x27, 16, 2);

const int ENA = 9; // PWM pin for speed control
const int IN1 = 8;
const int IN2 = 7;
const int buzzerPin = 4;

void setup() {
  BT.begin(9600);
  lcd.init();
  lcd.backlight();

  pinMode(ENA, OUTPUT);
  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);
  pinMode(buzzerPin, OUTPUT);

  // Set DC motor direction
  digitalWrite(IN1, HIGH);
  digitalWrite(IN2, LOW);
  analogWrite(ENA, 0); // Start OFF
  digitalWrite(buzzerPin, LOW);

  lcd.setCursor(0, 0);
  lcd.print("Fan Controller");
  lcd.setCursor(0, 1);
  lcd.print("Speed: OFF (0%)");
}

void loop() {
  if (BT.available()) {
    char cmd = BT.read();
    int speedVal = 0;
    String speedStr = "OFF";

    // Play confirmation beep
    digitalWrite(buzzerPin, HIGH);
    delay(50);
    digitalWrite(buzzerPin, LOW);

    if (cmd == '0') {
      speedVal = 0;
      speedStr = "OFF (0%)";
    } else if (cmd == '1') {
      speedVal = 100;
      speedStr = "Low (40%)";
    } else if (cmd == '2') {
      speedVal = 180;
      speedStr = "Med (70%)";
    } else if (cmd == '3') {
      speedVal = 255;
      speedStr = "High (100%)";
    } else {
      return; // Ignore other characters
    }

    analogWrite(ENA, speedVal);

    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Speed Changed");
    lcd.setCursor(0, 1);
    lcd.print(speedStr);

    BT.print("Fan Speed Set To: ");
    BT.println(speedStr);
  }
}

Step 3: Save your code. See the Getting Started section

Step 4: Select the Arduino board and port. See the Getting Started.

Step 5: Upload your code.

CONCLUSION

The Bluetooth Variable DC Fan Controller demonstrates speed adjustments using Pulse Width Modulation (PWM). Coordinating serial character codes with variable duty cycle outputs teaches students how logic levels govern heavy electrical actuators.