Preston Ferrer
Published © GPL3+

Timed Fan

A fan that will not only cool you off but turn off automatically after a set time to save power and energy in case of being forgotten.

BeginnerFull instructions provided1 hour23
Timed Fan

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Jumper wires (generic)
Jumper wires (generic)
×11
Resistor 220 ohm
Resistor 220 ohm
×6
LED (generic)
LED (generic)
×5
Power MOSFET N-Channel
Power MOSFET N-Channel
×1
1N4007 – High Voltage, High Current Rated Diode
1N4007 – High Voltage, High Current Rated Diode
×1
DC motor (generic)
×1
Pushbutton switch 12mm
SparkFun Pushbutton switch 12mm
×1
9V battery (generic)
9V battery (generic)
×1
9V Battery Clip
9V Battery Clip
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Diagram

Scheme

Code

Code

Arduino
const int buttonPin = 2;               
const int motorPin = 8;                
int ledPins[] = {3, 4, 5, 6, 7};       

unsigned long previousTime = 0;       
long interval = 1000;                  
int currentLED = 0;                    

int buttonState = 0;
int prevButtonState = 0;

void setup() {
  for (int i = 0; i < 5; i++) {
    pinMode(ledPins[i], OUTPUT);
  }

  pinMode(motorPin, OUTPUT);
  pinMode(buttonPin, INPUT_PULLUP);   

  digitalWrite(motorPin, LOW);
}

void loop() {
  unsigned long currentTime = millis();

  if (currentTime - previousTime > interval) {
    previousTime = currentTime;

    if (currentLED < 5) {
      digitalWrite(ledPins[currentLED], HIGH);
      currentLED++;
    }

    if (currentLED == 5) {
      digitalWrite(motorPin, HIGH);   
      delay(5000);                    
      digitalWrite(motorPin, LOW);    
    }
  }

  buttonState = digitalRead(buttonPin);
  if (buttonState == LOW && prevButtonState == HIGH) {
 
    for (int i = 0; i < 5; i++) {
      digitalWrite(ledPins[i], LOW);
    }

    currentLED = 0;
    previousTime = currentTime;

    digitalWrite(motorPin, LOW);
  }

  prevButtonState = buttonState;
}

Credits

Preston Ferrer
1 project • 0 followers

Comments