PROJECT Nº 1: Lion fan

Learn to build and program a friendly lion with a fan for a nose using the components of the Maker Control Kit and Maker Kit 2

This fan turns on and off automatically according to the ambient temperature. The temperature sensor, located on his back, will register the ambient temperature, and the DC motor will turn on or off depending on the instructions given by the program created.

Control the speed of the motor using the potentiometer, which is found on the lion’s tail. It’s that easy!

DIFFICULTY LEVEL: Intermediate.

DURATION OF THE EXERCISE: 120 min.

MATERIALS:

  • 1 DC motor with propeller
  • 1 Temperature sensor
  • 1 Potentiometer
  • 1 4in1 Build&Code board
  • 1 USB – Micro USB cable
  • Computer
  • Lion stencil
  • Material for the lion structure (a small cardboard box, sheets of poster board)
  • Adhesive or tape

What is a potentiometer?

A potentiometer is a variable resistor with values from 0 to 1023, depending on the degrees of rotation. That means that the potentiometer will give readings from 0 to 1023, depending on how much you make it turn.

BUILDING THE STRUCTURE:

The materials that you will use to build the lion fan are: a small cardboard box, sheets of poster board, the lion stencil, adhesive tape, and hot glue.

Download the lion stencil and the quick assembly guide. Follow the steps given:

  1. Color the whole lion (the torso, legs, and tail) with yellow adhesive paper. Then, use adhesive to glue all the parts of the lion and the electronic components.
  2. Connect all of the electronic components to the 4in1 Build&Code board, following the indications of the connections section below.
  3. Insert the micro-USB end of the USB cable through the lion’s body and connect it to the 4in1 Build&Code board.

CONNECTIONS:

  1. Connect the DC motor with a propeller to digital port 9 on the 4in1 Build&Code board.
  2. Connect the temperature sensor to analog port A0 on the 4in1 Build&Code board.
  3. Connect the potentiometer to analog port A5 on the 4in1 Build&Code board.

Look at the colors of the cables and the colors of the terminals on the 4in1 Build&Code board to guide you. Each cable should be connected to its color:

PROGRAMMING CODE:

Through the program, the DC motor with a propeller turns on and off depending on the ambient temperature. You will regulate the speed of the DC motor with a propeller with the potentiometer.

The temperature range for the DC motor with a propeller to be turned on is from -1ºC to +3ºC with respect to the set point. That is, if the set point is 27ºC, the DC motor will turn on when the temperature is between 26ºC and 30ºC. When the temperature value is outside the indicated range, the fan will stay off.

While the DC motor with a propeller is turned on, you can change its speed using the potentiometer.

You can do this activity by using Arduino and Bitbloq software, as well as other compatible block programming software. Below you will find the programming code needed for each software.

Arduino Code

  1. Download the Arduino software and go through the installation process.
  2. Open the Arduino program, and once in, copy the following program:
    /*TEMPERATURE */
    int STemp = 0;
    int SetPoint = 27; // 27ºC Set point
    int ReadTemp;
    float Voltaje;
    float Temp;
    /*POTENTIOMETER*/
    int PPot = 5;
    int ValuePot;
    /*FAN*/
    int PMotor = 9; // Speed
    int SpeedMotor;
    
    void setup() {
      // Put your setup code here, to run once:
      Serial.begin (9600);
      pinMode(13, OUTPUT);
      pinMode(PMotor, OUTPUT);
    }
    
    void loop() {
      // Put your main code here, to run repeatedly:
      Celcius(); // Calculation of temperature in Celsius
      if((Temp > (SetPoint - 1))&&(Temp < (SetPoint + 3))) // If the temperature is 1º under or 3º over SetPoint, we turn on the fan
      {
        for (int x = 0; x<20000; x++)
        {
          Speed(); // Calculation of the fan speed
          analogWrite(PMotor,SpeedMotor); // Fan = ON 
          digitalWrite(13, HIGH); // LED digital port 13 = ON
        }    
      }
      else // If the temperature is less than the SetPoint
      {
        analogWrite(PMotor, 0); // Fan = OFF
        digitalWrite(13, LOW); // LED digital port = OFF
      }  
     delay (2000);
    }
    
    void Celcius () // Calculation of the temperature in Celsius
    {
      ReadTemp = analogRead(STemp);
      Voltaje = (5.0/1024)*ReadTemp;
      Temp = ((Voltaje * 100) - 50);
      Serial.println (Temp);
    }
    
    void Speed() // Calculation of the fan speed
    {
      ValuePot = analogRead(PPot);
      SpeedMotor = map (ValuePot, 0, 1023, 50, 200); 
    }
    
  3. Configure and load the code. Below we show you which options you should select:
    3.1 Select the type of board that you are going to use. If using the 4in1 Build&Code board, you should select:

     Boards → Arduino Uno

    3.2 Select the port to which the 4in1 Build&Code board is connected:

    Connect → Serial Port → COM (the number where the board is connected) 

    3.3 Insert the communication program between the program and the 4in1 Build&Code board:

    Connect → Upgrade Firmware

  4. Then click the green flag to start the program.

Code for compatible block programming software 

  1. Download the software and go through the installation process.
  2. Open the program, and once in, copy the following code:
  3. Configure and load the code, following the instructions given in the document First Steps for the 4in1 Build&Code board.

BitBloq Code

  1. Get the BitBloq software.
  2. Open the BitBloq program, and once in, copy the following code:
    • Hardware
    • Software
  3. Configure and load the code, following the instructions given in the document First Steps for the 4in1 Build&Code board.

RESULT OF THE EXERCISE:

This fan in the shape of a lion turns on based on previously programmed values of ambient temperature. The ambient temperature is registered by the temperature sensor located in the upper part of the lion’s body.

When the fan is on, you can regulate its speed by turning the potentiometer located in the tail. Now you have your fan in the shape of a lion!

1 0

0