Clap Activated Fan

by rmogalian in Circuits > Arduino

27 Views, 0 Favorites, 0 Comments

Clap Activated Fan

Screenshot 2026-05-05 at 8.37.42 PM.png
Screenshot 2026-05-04 at 8.37.47 PM.png

Ever wanted to turn something on with just a clap, like magic? In this project, we built a clap-activated fan using an Arduino, a sound sensor, and a motor driver. One clap turns the fan on, another turns it off.

This project is great for beginners learning:

  1. Digital input (sound detection)
  2. Motor control
  3. Basic state logic (toggle behavior)
  4. Wiring Basics
  5. How to get comfortable with C++ Code

We also designed a 3D-printable fan housing, but we included measurements so you can build it from cardboard or other materials too.

Supplies

Electronics:

  1. (1) Arduino Uno + breadboard
  2. (1) Sound detector (Sparkfun SKU: SEN-12642)
  3. (1) Motor driver
  4. (1) Hobby DC motor
  5. (1) RGB LED
  6. (2) 330 Ω resistors (one per LED channel used)
  7. Jumper wires

Mechanical:

  1. 3D printed fan blades + housing (files provided) OR
  2. Cardboard/plastic for DIY casing

Before Getting Started

If you're new to Arduino, complete these steps before starting:

  1. Download the Arduino IDE
  2. Connect your board via USB
  3. Select Tools → Board → Arduino Uno
  4. ONCE READY TO UPLOAD THE CODE: Select the correct COM port (try unplugging and plugging back in to see which port pops up!)

Wiring the Circuit

Screenshot 2026-05-05 at 8.33.37 PM.png

Important:

The Tinkercad diagram shows a created aspect, representing a sound sensor. The wiring is very simple; use the sound sensor’s digital output pin.

Sound Sensor (SEN-12642)

  1. VCC → 5V
  2. GND → GND
  3. OUT → Pin 2

Motor Driver → Arduino

  1. PWMA → Pin 6
  2. AIN1 → Pin 7
  3. AIN2 → Pin 8


RGB LED (Use resistors to protect the LED)

  1. Red → Pin 3
  2. Green → Pin 5
  3. Blue → Pin 11
  4. Common → GND

Code

// Clap-Activated Fan

// Modified 4/30/2026


// Sound sensor pin

int i = 2;

int soundPin = i;

// Motor driver pins

int PWMA = 6;

int AIN1 = 7;

int AIN2 = 8;


// RGB LED pins

int redPin = 3;

int greenPin = 5;

// no blue pin necessary - the fan will only show on/off


// Clap detection variables

bool fanState = false;

bool lastSoundState = LOW;


void setup() {

pinMode(soundPin, INPUT);


pinMode(PWMA, OUTPUT);

pinMode(AIN1, OUTPUT);

pinMode(AIN2, OUTPUT);


pinMode(redPin, OUTPUT);

pinMode(greenPin, OUTPUT);


Serial.begin(9600);


motorOff();

setRed(); // fan starts OFF

}


void loop() {


int soundState = digitalRead(soundPin);


// Detect a clap (rising edge)

if (soundState == HIGH && lastSoundState == LOW) {

fanState = !fanState; // TOGGLE


if (fanState) {

motorOn();

setGreen();

Serial.println("Fan ON");

} else {

motorOff();

setRed();

Serial.println("Fan OFF");

}


delay(300); //

}


lastSoundState = soundState;

}


// Motor control

void motorOn() {

digitalWrite(AIN1, HIGH);

digitalWrite(AIN2, LOW);

analogWrite(PWMA, 255);

}


void motorOff() {

digitalWrite(AIN1, LOW);

digitalWrite(AIN2, LOW);

analogWrite(PWMA, 0);

}


// LED colors

void setRed() {

analogWrite(redPin, 255);

analogWrite(greenPin, 0);

}


void setGreen() {

analogWrite(redPin, 0);

analogWrite(greenPin, 255);

}


Downloads

Build the Casing

Option 1: 3D Printed - see attached files

  1. Print provided STL files (fan blades + casing)
  2. Attach the motor shaft to the fan blade hub
  3. Mount the motor securely inside the casing


Option 2: DIY (Cardboard)

  1. Cut 3–4 blades (equal size)
  2. Tape or glue to the motor shaft
  3. Build a small enclosure to hold the motor + Arduino



Putting It All Together

In order to put it all together, please see the attached video and images. The main steps are as follows:


place the wired breadboard and battery pack into the bottom portion of the casing. Feed the motor through the top portion's designated hole and allow it to rest comfortably on the hole's lip. Attach the fan blades to the motor. Clap to turn on and off!

Testing and Troubleshooting

Testing & Calibration

If it’s too sensitive or not sensitive enough:

  1. Adjust the potentiometer on the sound sensor
  2. Try clapping closer/farther
  3. Increase/decrease the delay(300)


Troubleshooting

If the fan doesn’t spin

  1. Check motor driver wiring
  2. Make sure external power (if needed) is connected

Clap not detected

  1. Adjust sensor sensitivity
  2. Verify the OUT pin is correct

LED not lighting

  1. Check resistor + wiring
  2. Make sure it’s not reversed