Sitting lion fan – Learning path project 10

Our Learning Path is an itinerary designed to teach all the foundaments and a little more about electronics, coding and robotics.

When you complete all the projects you will be able to develop almost any project you can imagine. In each chapter new concepts are introduced. You will learn by doing in a funny way.

It’s a lion, and also a smart fan!! Discover how to control a DC motor.

Project 10

Make a funny fun with the DC motor module and stay cool!!



4in1 board
Battery holder & wires
Battery holder & wires
Battery holder & wires

1 - Build&Code 4in1 board
1 - DC Motor with propeller
1 - Temperature sensor

1 - Switch button module
1 - Rotary Potentiometer module
Battery holder, USB cable and wires.

10 - DC Motor and Temperature sensor

The DC Motor is the way to make things spin fast. We can define rotation direction according polarity, but not position as servos. There are many different types and powers, but always will be less strong than a servo, you should use a reduction gearbox to get it strong, and slower. Is the more common part to convert electrical energy into mechanical energy.

There are a lot of applications were we need to know temperature. The temperature sensor is the way to go! In most cases it's a resitance that varies with temperature. So it must be read as the potentiometer. We have to know the curve, or relation between resistance values and temperature. According materials used on the sensor, they can have better accuracy in some particular range. Ebotics sensor have these specs:

Precision: ±2°C
Linear degree:±0.5°C
Operating voltage:+2.7 V to +5.5 V DC

Measuring range: -40°C to +125°C.
Correlation coefficient: +10 mV/°C

10. Lion fan sitting - Circuit

DC motors requires more current than a LED, so we cannot use digital output as source directly. The module includes a transistor, so digital port gives signal, and power pins supply current.

Connect wires from 4in1 board to components:
- DIO4 to Button
- DIO6 to DC Motor
- A1 to Potentiometer

10.1 DC Motor

First of all, we are going to run our fan pressing the button. It wil go faster if we maintain pressed the button!

Block Coding
Arduino Coding
//Lets fun
void setup() {
  pinMode(6, OUTPUT);
  pinMode(4, INPUT);

void loop() {
    for (int x = 0; x < 255; x=x + 10)
      analogWrite(6, x );
      delay (250);
    analogWrite(6, 0 );  }
10.2 Vary speed with the potentiometer

To be able to change speed, we use also PWM output signal. According duty cycle, the transistor in the module lets pass more or less current, as if it were a tap

Block coding
Arduino code
int cd_motor = 6;
int potenciometro = 1;

int valorpot;
int valor;
int valor1;

void setup() {
  pinMode(cd_motor, OUTPUT);

void loop() {
  valorpot = analogRead(potenciometro);
  valor = map(valorpot, 0, 1023, 0, 255);
  valor1 = map(valorpot, 0, 1023, 255, 0);
  analogWrite(cd_motor, valor);
  analogWrite(cd_motor, valor1);

How do you do to start or stop the fan depending on the ambient light? Try it!! When light appears, the fan automatically runs!!

Final project - Lion fan sitting

Now you are ready to make a nicer fan! Try to build our lion fan sitting with the cardboard template You can to use the temperature sensor module so it will move air automatically when it's too hot!!

Block coding
Arduino code
int PPot = 5; // Analog pin for potentiometer
int ValuePot; // variable for potentiometer measure
int PMotor = 9; // Digital pin for motor fan
int SpeedMotor; // Variable for motor fan speed

void setup() {
  // put your setup code here, to run once:
  Serial.begin (9600);
  pinMode(PMotor, OUTPUT); // motor configuration as an output signal

void loop() {
  // put your main code here, to run repeatedly:
  Speed(); // call the engine speed function
  analogWrite(PMotor,SpeedMotor); // Motor fan = ON and speed = potentiometer

void Speed() // Function to calculate engine speed
  ValuePot = analogRead(PPot); // measure potentiometer reading
  SpeedMotor = map (ValuePot, 0, 1023, 0, 200); // scale potentiometer measurements

previous arrow
next arrow

The Mega Maker Kit fits perfectly with the Learning Path, you can build all projects with it, but if you have other kits, you can also follow the entire itinerary and finish some projects, or buy the missing components. You can check in our Learning Path page.

0 0