Clap Activated Fan

by rmogalian in Circuits > Arduino

47 Views, 1 Favorites, 0 Comments

Clap Activated Fan

Screenshot 2026-05-13 at 1.23.11 PM.png
Screenshot 2026-05-05 at 8.37.42 PM.png
Screenshot 2026-05-04 at 8.37.47 PM.png
ClapActivatedFanVideo

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 and attached it here!

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. (1) Arduino-fit battery pack
  8. (4) AA Batteries
  9. Jumper wires
  10. 1 large sheet of Cardboard (or other thin, layerable filler material)
  11. Hot glue and glue gun (small amount)

Mechanical:

  1. 3D printed fan blades + housing (files provided)

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 and Blades

Option 1: 3D Printed - see attached files

  1. Print provided SLDPRT files (fan blades, box, and lid) - you may need to convert these to a different file type depending on your 3D printer.
  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

AssemblyImage1.png
AssemblyImage2.png
AssemblyImage3.png
AssemblyImage4.png
AssemblyImage5.png
AssemblyImage6.png
AssemblyImage7.png
AssemblyImage8.png

The main steps are as follows:

  1. Print the casing and blades.
  2. Wire and code the board.
  3. Gather materials.
  4. Cut ~4 sheets of cardboard that fit inside the box snugly.
  5. Place the cardboard in the box.
  6. Place the wired board with the battery port in line with the hole on one of the long sides of the box.
  7. Situate the motor so the 'butt' that spins (not the arms) is facing up.
  8. Cut another sheet of cardboard, with a hole in the middle to accommodate the portion beneath the arms, and place it in the box as shown in the attached image. This step prevents the spinning arms of the motor from jumbling the wires. Tweak as needed to ensure the board, wires, and motor are situated.
  9. Place the lid on top of the box, feeding the motor through the hole on top.
  10. With the glue gun, put a small amount of glue into the hole on the underside of the fan blades. Let the glue become slightly tacky.
  11. Attach the fan to the motor as seen in the attached image. Add more glue if necessary, but do not allow the glue to get on the motor other than its spinning portion.
  12. Allow the glue to fully cool and ensure the fan is attached
  13. At this point, you might need to tape or glue the lid to the box. This is an optional step, but it ensures the project stays as one.
  14. Attach the battery pack next to the hole on the box and feed the plug attached to the port available on the board through the hole.
  15. Clap 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