Clap Activated Fan
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:
- Digital input (sound detection)
- Motor control
- Basic state logic (toggle behavior)
- Wiring Basics
- 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) Arduino Uno + breadboard
- (1) Sound detector (Sparkfun SKU: SEN-12642)
- (1) Motor driver
- (1) Hobby DC motor
- (1) RGB LED
- (2) 330 Ω resistors (one per LED channel used)
- Jumper wires
Mechanical:
- 3D printed fan blades + housing (files provided) OR
- Cardboard/plastic for DIY casing
Before Getting Started
If you're new to Arduino, complete these steps before starting:
- Download the Arduino IDE
- Connect your board via USB
- Select Tools → Board → Arduino Uno
- 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
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)
- VCC → 5V
- GND → GND
- OUT → Pin 2
Motor Driver → Arduino
- PWMA → Pin 6
- AIN1 → Pin 7
- AIN2 → Pin 8
RGB LED (Use resistors to protect the LED)
- Red → Pin 3
- Green → Pin 5
- Blue → Pin 11
- 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
- Print provided STL files (fan blades + casing)
- Attach the motor shaft to the fan blade hub
- Mount the motor securely inside the casing
Option 2: DIY (Cardboard)
- Cut 3–4 blades (equal size)
- Tape or glue to the motor shaft
- 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:
- Adjust the potentiometer on the sound sensor
- Try clapping closer/farther
- Increase/decrease the delay(300)
Troubleshooting
If the fan doesn’t spin
- Check motor driver wiring
- Make sure external power (if needed) is connected
Clap not detected
- Adjust sensor sensitivity
- Verify the OUT pin is correct
LED not lighting
- Check resistor + wiring
- Make sure it’s not reversed