Fanduino - Cool Automatic Arduino Fan

by BoianM in Circuits > Arduino

8404 Views, 50 Favorites, 0 Comments

Fanduino - Cool Automatic Arduino Fan

Fanduino: Cool Automatic Arduino Fan with Visuino

While we in the northern hemisphere enjoy the winter chill, we can't help but feel sorry for those less fortunate suffering the horrible heat in the southern hemisphere... :-D

So, in the true Christmas spirit, I decided to share some of our cool, in the form of an Arduino controlled fan :-)

Components

577951384936d4f6ef001416.jpeg
577951442e7fb6107900080e.jpeg
5779516b4936d4f6ef001417.jpeg
577951782e7fb6086a0013ce.jpeg

Needed components:

  1. One Arduino (I use Mega because I have one available, but UNO is perfectly good for this project)
  2. One Breadboard
  3. One Texas Instruments LM35 Thermometer
  4. One Small Servo with a plastic arm (I used SG90 Servo)
  5. One Ultrasonic Ranger HC-SR04 or similar
  6. One large paperclip
  7. Few jumper wires
  8. One piece of paper to use for the flap
  9. Some Glue, and Adhesive Tape

Optional recommended components:

  1. 2 capacitors to reduce noise (I use 100 uF and 0.01 uF but you can use other values)
  2. One external power supply for the Servo. (You can power the servo with the Arduino board, but then there will be a lot of noise in the Thermometer readings)

Make the Flag

5779518667400cd672000817.jpeg
5779519b4936d4e56b0001bb.jpeg
577951bf67400cd672000819.jpeg
577951da50e1b6590f0011e8.jpeg
577951eb50e1b6590f0011e9.jpeg
5779521467400c70a8001401.jpeg
5779522f67400cd67200081b.jpeg
57795241deafa4826a00076b.jpeg
577952604936d4f6ef00141b.jpeg
57795274deafa4d3d50012e0.jpeg
  1. Fold the paper flap through the center as shown in Picture 1
  2. Shape the paper clip into an asymmetric U shape, and insert the 2 ends through the Servo arm (Picture 2)
  3. Insert the 2 ends through the fold in the paper flap(Picture 3)
  4. Bend the paper clip as shown on Picture 4 and 5
  5. Secure the clip to the paper with Adhesive Tape (Picture 6)
  6. Apply glue to the paper (Picture 7)
  7. Glue the 2 inner sides of the paper together to form the flag as shown on pictures 8 and 9

Connect the LM35 Thermometer

5779529950e1b6590f0011eb.jpeg
577952ae4fbadecbcd0007c0.jpeg
577953bb2e7fb6086a0013d3.jpeg
577953cd4936d4f6ef001421.jpeg
577952db67400c70a8001403.jpeg
577952f34936d4cec30007ac.jpeg
  1. Place the LM35 Thermometer on the Breadboard, and connect the Ground (Black wire), and Power (Red wire) to the power bus of the Breadboard as shown on Picture 1
  2. Optionally add a small capacitor between Ground and Power near the Thermometer, to reduce high frequency power noise as shown on Picture 2
  3. Optionally add a bigger capacitor between Ground and Power on the power bus to improve the power stability as shown on Picture 3
  4. Connect a wire (Green wire) to the middle pin of the Thermometer (Picture 4). This pin will output the analog temperature value measured by the LM35
  5. Connect Ground (Black wire) and Power (Red wire) wires to the power bus of the Breadboard to provide power from the Arduino Board (Picture 5)
  6. Connect the Temperature(Green wire) to the Arduino Analog 0 pin, the Power (Red wire) to the 5V Arduino Power pin, and the Ground(Black wire) to an Arduino Ground Pin (Picture 6)

Connect the Ultrasonic Ranger

5779530050e1b6590f0011ed.jpeg
5779531367400c70a8001405.jpeg
  1. Place the Ultrasonic Ranger on the Breadboard
  2. Connect the Power(Red wire), Ground(Black wire), Trigger(Yellow wire), and Ping/Echo(White wire) to the Ultrasonic Ranger. Connect the other end of the Power and Ground wires to the Power and Ground of the Power bus of the Breadboard (Picture 1)
  3. Connect the other end of the Trigger(Yellow wire) to Digital Pin 2 of the Arduino board, and Ping/Echo(White wire) to Digital Pin 3 of the Arduino board (Picture 2)

Connect the Servo

57795322deafa4d3d50012e2.jpeg
5779533850e1b6590f0011ee.jpeg
5779534545bceb79760007b3.jpeg
577953e615be4d257b000caf.jpeg
577953f9deafa43ec400018f.jpeg
5779540d4936d4f6ef001422.jpeg
5779541950e1b6590f0011f4.jpeg

For my Fan, I used external power for the Servo as recommended. It also reduces the power noise which affects the temperature measurements.

You can connect the Servo directly to the power of the Arduino board, but that is not recommended.

  1. Connect a jumper wire between the grounds of the two power buses on the breadboard as shown on Picture 1
  2. Add Ground(Black wire), Power(Red wire), and Control(Orange wire) to the Servo connector (Picture 2)
  3. Connect the other end of the Ground(Black wire), and Power(Red wire) to the separated power bus on the Breadboard(Picture 3) . If you decide to power the Servo directly from Arduino, connect to the same Breadboard power bus, where the Thermometer and the Ultrasonic Rangers are connected
  4. Connect the other end of the Control(Orange wire) to the Digital Pin 4 of the Arduino board (Picture 4)
  5. Add a Power Supply to the side of the breadboard where the Servo Power is connected (Pictures 5 and 6)
  6. Mount the Servo vertical using whatever convenient objects are around (In my case Spool of prototyping wire) (Picture 7)

Start Visuino, and Add Components to Read the LM35 Thermometer and Reduce the Noise

ComponentLM35.png
ComponentLM35Average.png
ComponentLM35Connect.png
ComponentLM35AverageValue.png

To start programming the Arduino, you will need to have the Arduino IDE installed from here: http://www.arduino.cc/ .

Please be aware that there are some critical bugs in Arduino IDE 1.6.6. Make sure that you install 1.6.7 or higher, otherwise this Instructable will not work!

The Visuino: https://www.visuino.com also needs to be installed.

  1. Start Visuino
  2. From the Component Toolbox expand the "Measurement" Category, then the "Analog" Sub Category, and select the "Texas Instruments Thermometer LM35" component as shown on the first picture, and drop it in the design area
  3. From the Component Toolbox expand the "Math" Category, and select the "Average Period" component (Picture 2), and drop it in the design area. The Average component will help reduce noise by averaging multiple readings
  4. Connect the components as shown on Picture 3
  5. Set the Average Period to 100000 (Picture 4)

In Visuino Add the Components to Read the Ultrasonic Ranger

ComponentRanger.png
ComponentRangerConnect.png
ComponentRangerAverageValue.png
  1. From the Component Toolbox expand the "Measurement" Category, then the "Analog" Sub Category, and select the "Ultrasonic Ranger" component as shown on the first picture, then drop it in the design area
  2. From the Component Toolbox expand the "Math" Category,and select the "Average Period" component, then you drop in in the design area, as you did with the Thermometer in the previous step. The Average component will help reduce noise by averaging multiple readings
  3. Connect the components as shown on (Picture 2)
  4. Set the value of the Period property of the AveragePeriod2 component to 2000000 (Picture 3)

In Visuino Add Components to Control the Servo

ComponentServoComponent.png
ComponentServoSineComponent.png
ComponentServoConnect.png
ComponentServoAmplitude.png
  1. From the Component Toolbox expand the "Motors" Category, and select the "Servo" component as shown on the first picture
  2. From the Component Toolbox expand the "Generators" Category, then the "Analog Generators" Sub Category, and select the "Sine Analog Generator" component as shown on the Picture 2, then drop it in the design area
  3. Connect the components as shown on Picture 3
  4. For the Sine Generator specify Amplitude of 0.3 (Picture 4)

Add Pins to the Sine Generator to Enable It, and Control Its Frequency

ComponentServoAddEnablePin.png
ComponentServoAddFrequencyPin.png

To Enable/Disable the Sine generator and control its frequency, we need to add pins to some of the properties:

  1. In the Object Inspector click on the Pin button at front of the Enabled property, and select "Boolean SinkPin" (Picture 1)
  2. In the Object Inspector click on the Pin button at front of the Frequency property, and select "Float SinkPin" (Picture 2)

In Visuino Add Components to Control the Speed of the Fan

ComponentSubtract.png
ComponentMultiply.png
ComponentSubtractSet.png
ComponentMultiplySet.png
ComponentAnalogSnapshot.png
ComponentClock.png
ComponentClockConnect.png
ComponentClockGenFrequency.png
ComponentAnalogSnapshotConnectStart.png
ComponentAnalogSnapshotConnectEnd.png

We want the temperature to control the speed of the fan. To do that we need to calculate frequency from the temperature.

  1. Type "subtr" in the Filter box of the Component Toolbox, then select the "Subtract Value" component (Picture 1), and drop it in the design area
  2. Type "mul" in the Filter box of the Component Toolbox, then select the "Multiply By Value" component (Picture 2), and drop it in the design area.
  3. In the Object Inspector set the Value of the Subtract component to 18 (Picture 3)
  4. In the Object Inspector set the Value of the Multiply component to 0.3 (Picture 4)

We also want to update the speed only once every 10 seconds. For this we will add a snapshot component and a clock component to send clock to the snapshot once every 10 seconds.

  1. Type "sna" in the Filter box of the Component Toolbox, then select the "Analog Snapshot" component (Picture 5), and drop it in the design area
  2. Type "clock" in the Filter box of the Component Toolbox, then select the "Clock Generator" component (Picture 6), and drop it in the design area.
  3. Connect the components as shown in Picture 7
  4. In the Object Inspector, set the value of the "Frequency" property of the Clock Generator to 0.1 (Picture 8) This way, the generator will generate a clock once every 10 seconds
  5. Connect the "Out" pin of the AnalogSnapshot1 component (Picture 9) to the "Frequency" input pin of the SineAnalogGenerator1 (Picture 10)

In Visuino Add Components to Enable/disable the Fan

ComponentCompareAnalog.png
ComponentCompareAnalogPlaced.png
ComponentCompareAnalogPlaced2.png
ComponentCompareAnalogConnect.png
ComponentAnd.png
ComponentAndConnect1.png
ComponentAndConnect2Start.png
ComponentAndConnect2End.png
  1. Type "compare" in the Filter box of the Component Toolbox, then select the "Compare Analog Value" component (Picture 1), and drop two of them in the design area
  2. In the Object Inspector for CompareAnalogValue1 set the CompareType property to ctBigger and the Value property to 20 (Picture 2)
  3. In the Object Inspector for CompareAnalogValue2 set the CompareType property to ctSmaller and the Value property to 80 (Picture 3)
  4. Connect the Compare components as shown on Picture 4
  5. Type "and" in the Filter box of the Component Toolbox, then select the "Boolean And" component (Picture 5), and drop it in the design area
  6. Connect the "Out" pints of the CompareAnalogValue2 components to the inputs of the And1 component as shown in Picture 6
  7. Connect the "Out" pin of the And component (Picture 7) to the "Enabled" input property of the SineAnalogGenerator1 (Picture 8)

And Chill...

5779544f2e7fb6086a0013d8.jpeg
5779545f4936d4f6ef001424.jpeg
5779547a50e1b6182a00079f.jpeg
566a64cb50e1b6d8e30017a0.jpeg

On the pictures you can see the completed fan.

To generate the Arduino code, press F9 in Visuino. This will generate the Arduino code, and will open the Arduino IDE, where you can compile and upload the code to the Arduino board.

If you stand at front of the Sonic Ranger, and if the temperature in the room is above 20 degrees Celsius, the fan will start working.

If the temperature gets higher, the fan will wave faster.

In Picture 4 you can see the complete Visuino connection diagram,

You can change the starting temperature setting by modifying the Value property of the CompareAnalogValue1 component.

You can change the starting distance from the Ultrasonic Ranger setting by modifying the Value property of the CompareAnalogValue2 component.

By changing the values of the SubtractValue1 and MultiplyByValue1 components you can adjust how the speed of the fan will depend on the temperature.

I have also attached the Visuino project for this Instructabe, as well as a PDF file with the Visuino flag :-) .

You can download and open the project in Visuino : https://www.visuino.com

Enjoy the cool! :-)