Giraffe-Shaped Temperature-Controlled & Multi-level Desk Fan With Nano
by SunFounder Maker in Circuits > Arduino
1800 Views, 9 Favorites, 0 Comments
Giraffe-Shaped Temperature-Controlled & Multi-level Desk Fan With Nano
In sweltering summer days, an easy-to-carry fan will definitely comfort you. It’s quite simple to make, so check the following steps to build one. The creation lies on the multi-level and temperature-control functions.
Let’s dig into the details!
Prepare Materials
SunFounder Nano board http://bit.ly/2fwJNnj
Breadboard http://bit.ly/2vW9DqZ
USB cable
DC motor http://bit.ly/2s2hCx6
10KΩ resistor
2 x 220Ω resistor
Press-button
2 x LED (red and green) http://bit.ly/2slvfrB
Dual H-Bridge L293D motor driver http://bit.ly/2sMbO06
104 ceramic capacitor
Fan (blade)
Small box (approx. 90*50)
2 x Toilet paper roll
Black play-doh
Color pen
Some jumper wires
Double-sided tape
Glue gun http://bit.ly/2twpx8w
Soldering iron http://bit.ly/2t3fPKx
7.4V battery
Soldering
Before wiring, you need to solder some devices together or extend some with jumper wires for better wiring. Here you need to solder each 220Ω resistor to each LED to make two groups, and then extend the two poles of two resistor-LED groups, press-button, and the motor with jumper wires respectively.
Note: Make sure the extended wire’s length is more than the total height of the small box and the toilet paper roll.
Wiring
Insert the Arduino Nano and Motor driver to the breadboard as shown, and connect the devices with jumper wires. The Fritzing image shows the wiring details. Next, paste the battery on the back of the breadboard.
Upload the Code to Nano
Connect the Nano board to computer via the USB cable, and open the Arduino IDE. Select the board as Nano and the correct port, upload the code. Then check whether three levels work normally by pressing the button. The fan should rotate slowly for the first pressing, a little faster for the second, and then much faster for the third. Then stop at fourth pressing.
Besides, this fan is a thermally controlled one - it will spin in the strongest mode automatically when the temperature reaches 34 ℃ (threshold adjustable in the code)
const int buttonPin = 7; // the number of the pushbutton pin
const int motorIn1 = 9;
const int motorIn2 = 10;
const int redled = 4;
const int greenled = 3;
int stat = 0;
#define temPin A0
#define beta 3950
#define rank1 130
#define rank2 150
#define rank3 200
// Variables will change:
int buttonState; // the current reading from the input pin
int lastButtonState = LOW; // the previous reading from the input pin
// the following variables are long's because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long lastDebounceTime = 0; // the last time the output pin was toggled
long debounceDelay = 50; // the debounce time; increase if the output flickers
/******************************************************************************/
void setup()
{
pinMode(buttonPin, INPUT);
pinMode(greenled, OUTPUT);
pinMode(motorIn1, OUTPUT);
pinMode(motorIn2, OUTPUT);
pinMode(redled, OUTPUT);
Serial.begin(9600);
}
void loop() {
long a = 1024 - analogRead(temPin);
//the calculating formula of temperature
float tempC = beta / (log((1025.0 * 10 / a - 10) / 10) + beta / 298.0) - 273.0;
Serial.println(tempC);
if (tempC > 34)
{
digitalWrite(redled, HIGH);
clockwise(250);
}
else
{
digitalWrite(redled, LOW);
buttoncontrol();
}
}
/***********************************************************/
void clockwise(int Speed)//
{
analogWrite(motorIn1, 0);
analogWrite(motorIn2, Speed);
}
void buttoncontrol()
{
int reading = digitalRead(buttonPin);
if (reading != lastButtonState)// If the button state is different from last time
{
lastDebounceTime = millis();// reset the debouncing timer
}
if ((millis() - lastDebounceTime) > debounceDelay)
{
if (reading != buttonState)
{
buttonState = reading; // Store the state of button in buttonState
// only toggle the LED if the new button state is HIGH
if (buttonState == HIGH)
{
digitalWrite(greenled, HIGH); //turn on the LED
delay(200);
stat = stat + 1;
if (stat >= 4) // When stat>=4, set it as 0.
{
stat = 0;
}
}
else
digitalWrite(greenled, LOW);
}
}
switch (stat)
{
case 1:
clockwise(rank1);// When stat=1, set the rotate speed of the motor as rank1=150
break;
case 2:
clockwise(rank2);// When stat=2, set the rotate speed of the motor as rank1=200
break;
case 3:
clockwise(rank3);// When stat=3, set the rotate speed of the motor as rank1=250
break;
default:
clockwise(0);
}
// save the reading. Next time through the loop,
// it'll be the lastButtonState:
lastButtonState = reading;
}
Make the Giraffe Body
Paint color on the small box, and insert the breadboard with circuits onside and battery pasted at the bottom into the box (so the size of the box must be larger than the breadboard when you're selecting one).
Cut some holes on the box to leave the thermal resistor, motor, button, and two LED with wires outside the box.
And leave a hole for the Nano board’s USB port for possible code modifying and re-uploading if necessary.
DIY the Giraffe Neck and Head
Neck:
- Take a toilet paper roll, also paint it with yellow color with orange spots, and cut holes on opposite sides for two LED as the giraffe's eyes.
- Insert the motor and two LEDs in the tube.
- Glue the bottom circle of the neck to the body. So the neck is done.
Head:
- Take out another paper roll, cut it open, and draw and cut out a rectangle piece.
- Cut a hole out about the size of the motor (measure the approximate numbers).
- Insert the motor through the hole and curve the rest paper a little. So get the head!
Add a Tail for Giraffe
Take the remaining of the second paper roll, cut and fold a slim tail, paint it also yellow and glue it onto rear of the body.
Build the Giraffe Legs
Take one more toilet paper roll since the remaining of the second is not enough.
- Compare its height with that of the box, mark and cut out the bottom part about 1/3 height of the body, and cut the small roll open. Here you get a rectangle piece.
- Then cut more three strips similarly, roll them all into four thin cylinders, and stick the end with double-sided tape.
- At last, paint them all yellow. Now, you get four cute chubby legs.
Fasten With Glue! DONE!!!
At last, fasten the whole giraffe with glue. Then it’s all completed! You get a cute multi-level giraffe fan!
Ah, it's so adorable I can't wait one sec to show off this good-looking creation to my friends. See you next time!
Check more on our BLOG: https://www.sunfounder.com/blog/smallfan/