RGB LED Fan With Buzzer

382

3

1

Published

Introduction: RGB LED Fan With Buzzer

In the summer while you're in your room and it's very hot, having a fan is very convenient isn't it? Well today, I can show you how you can create your own little electronic fan by using a few engineering parts. This instructable will teach you how to create an electronic fan which you can use by simply clicking a button and holding it wherever you wish. It contains and RGB Led which displays a green color when the fan is on and a red color when the fan is off. It also creates a sound whenever you turn your fan on or off so you know for sure that you're not wasting any more electricity!

Step 1: Collecting the Parts

For this machine to function to its full extent, you will need (I have included links to where you can buy the items) :

* DC Motor

* Wires

* 2 Switches

* Potentiometer

* 9V Battery

* Two 10 k-ohm resistors

* Three 330 ohm resistors

* Buzzer

* BreadBoard

* Arduino UNO

* RGB LED

This Purchase will cost around a maximum of $45.

Step 2: Beginning With the Switches

In this step, I want you to put the switches (a device for making and breaking the connection in an electric circuit) in the middle of the breadboard and connect it to your Arduino. Use a wire to add 5v and ground to your breadboard. After, connect your switches to power using wires and two 10 k-ohm resistors to ground. This will ensure that your buttons will work perfectly without short circuiting.

Step 3: Adding the Potentiometer and H-Bridge

In this step, connect the potentiometer and h-bridge to your circuit. A potentiometer is three-terminal resistor with a sliding or rotating contact that forms an adjustable voltage divider. If only two terminals are used, one end and the wiper, it acts as a variable resistor or rheostat. An H-Bridge is an electronic circuit that enables a voltage to be applied across a load in opposite direction. Proceed to add wires accordingly to the image above and connect them to the gpio pins which best suit you.

Step 4: DC Motor and RGB LED

In this step, add the dc motor. You can do this by connecting 2 wires to the motor and connecting it to the H-Bridge. For the RGB LED, you will need to use Three 330 ohm resistors and connect each of them to the RGB legs. Once you do that, use a wire and connect one side to the resistor leg and the other to a PWM pin on your Arduino UNO board. A Pulse Width Modulation, or PWM, is a technique for getting analog results with digital means. Digital control is used to create a square wave, a signal switched between on and off. For the last leg of the RGB LED, use a wire and connect it to ground. You can also bring your 9v battery in now as well. (But i recommend you don't plug it in yet even though it is plugged in the diagram).

Step 5: Installing the Buzzer

This is the final component of the hardware portion. For this step, add your buzzer onto your breadboard. This is a very simple part of the hardware. All you will need to do is connect the positive leg to a gpio pin and connect the negative leg to ground.

Step 6: Writing the Code

This part of the procedure requires you to write the code in order for the hardware components to operate.

First : Declare Each Variable:

const int controlPin1 = 2;

const int controlPin2 = 3;

const int enablePin = 9;

const int redPin = 6;

const int greenPin = 10;

const int bluePin = 11;

const int buzzer = 12;

const int directionSwitchStatePin = 4;

const int onOffSwitchStatePin = 5;

const int potPin = A0;

int onOffSwitchState = 0;

int previousOnOffSwitchState = 0;

int directionSwitchState = 0;

int previousDirectionSwitchState = 0;

int motorEnabled = 0;

int motorSpeed = 0;

int motorDirection = 1;

Step 7: Void Setup

Then, add the void setup:

void setup() {

pinMode(directionSwitchStatePin, INPUT);

pinMode(onOffSwitchStatePin, INPUT);

pinMode(controlPin1, OUTPUT);

pinMode(controlPin2, OUTPUT);

pinMode(enablePin, OUTPUT);

digitalWrite(enablePin, LOW);

Serial.begin (9600);

pinMode(redPin, OUTPUT);

pinMode(greenPin,OUTPUT);

pinMode(bluePin,OUTPUT);

pinMode(buzzer,OUTPUT);

}

This part of the code essentially tells whether each pin is input or output.

Step 8: Void SetColor

This part of the code is for the RGB LED:

void setColor(int red, int green, int blue)

{

red= 255 - red;

green= 255 - green;

blue= 255 - blue;

analogWrite(redPin, red);

analogWrite(greenPin, green);

analogWrite(bluePin, blue);

}

It tells the RGB LED that it is connected to a PWM and gives its a value.

Step 9: Void Loop

This is the main part of the code:

void loop() {

onOffSwitchState=digitalRead(onOffSwitchStatePin);

delay(1); directionSwitchState = digitalRead(directionSwitchStatePin);

motorSpeed=analogRead(potPin)/4;

Serial.println(motorSpeed);

if(onOffSwitchState != previousOnOffSwitchState){ if(onOffSwitchState == HIGH){ motorEnabled = !motorEnabled;

digitalWrite(buzzer, HIGH);

delay(100);

digitalWrite(buzzer, LOW); } } if(directionSwitchState!=previousDirectionSwitchState){ if(directionSwitchState == HIGH){ motorDirection=!motorDirection;

} } if(motorDirection == 1){ digitalWrite(controlPin1, HIGH);

digitalWrite(controlPin2, LOW);

} else{ digitalWrite(controlPin1, LOW);

digitalWrite(controlPin2, HIGH);

} if(motorEnabled == 1){ analogWrite(enablePin, motorSpeed);

setColor(0, 255, 0);

} else{ analogWrite(enablePin, 0);

setColor(255, 0, 0);

} previousDirectionSwitchState = directionSwitchState;

previousOnOffSwitchState = onOffSwitchState;

}

What this part of the code represents is that this is where the real magic works. It basically displays that once you click on the button, it sounds the buzzer and turns on the green light while at the same time spinning the dc motor. And once you click the button again, it turns off the dc motor and at the same time, it turns on the red light and sounds the buzzer once more.

Step 10: Done!

Now you are all finished and you can enjoy your new Electronic RGB LED Buzzer Fan.

Share

    Recommendations

    • Clocks Contest

      Clocks Contest
    • Oil Contest

      Oil Contest
    • Planter Challenge

      Planter Challenge
    user

    We have a be nice policy.
    Please be positive and constructive.

    Tips

    Questions

    Comments

    This would be useful in the summer :) I'd likely forget it on so I like that you built in the LED and sound systems as a reminder.