Skip to content

4.2.5. Keypad Speed Controlled Fan

| Description In Project 95, learners will construct an expert interactive system titled 'Keypad Speed Controlled Fan'. This manual details the complete synthesis of 4x4 Matrix Keypad + DC Motor + Fan Blade + L298N Driver + 7-Segment Display into an intuitive, high-performance automated control platform.|------------------|----------------------------------------------------------------| | Use case |This project connects to real-world industrial and IoT applications such as: Project 95 equips students with professional skills in embedded human-machine interface (HMI) design and automated motion control.|

Components (Things You will need)

Arduino Uno Arduino USB Cable Bread Board Jumper Wires DC Motor Motor Driver 4x4 Keypad 8x8 Dot Matrix Fan Blades

Building the circuit

Things Needed:

  • Arduino Uno Core Board
  • 4x4 Matrix Keypad
  • DC Motor
  • Fan Blade
  • USB Cable & Jumper Wires
  • Bread Board
  • Motor Driver

Mounting the component on the breadboard and wiring the circuit

Step 1: Connect the Arduino 5V pin to the breadboard's positive (+) power rail and the Arduino GND pin to the negative (-) power rail.

Step 2: Place the 4x4 Matrix Keypad on the breadboard. - Connect the 8 row and column pins to Digital Pins 9, 8, 7, 6, 5, 4, 3, and 2 respectively

Step 3: Place the DC Motor (with Fan Blade) and Motor Driver (e.g., L298N/L293D) on the breadboard. - Connect the driver's VCC to the 5V power rail on the breadboard - Connect the driver's GND to the ground rail on the breadboard - Connect the ENA pin to Digital Pin 10 - Connect the IN1 and IN2 pins to Digital Pins 11 and 12 respectively - Connect the motor leads to the corresponding output terminals

Step 4: Ensure all components share a common GND connection, then verify all wiring before connecting the Arduino Uno to your computer using the USB cable.

Components on breadboard

Step 5: After confirming that all connections are correct, connect the USB cable to the Arduino Uno board and the computer to power the circuit.

Make sure to connect the Arduino USB cable to the Arduino board.

PROGRAMMING

Step 1: Open your Arduino IDE. See how to set up here: Getting Started.

Step 2: Write the complete program implementing the system logic with appropriate pin definitions, setup configuration, and the main control loop.

#include <Keypad.h>

const byte ROWS = 4; const byte COLS = 4;
char keys[ROWS][COLS] = {{'1','2','3','A'},{'4','5','6','B'},{'7','8','9','C'},{'*','0','#','D'}};
byte rowPins[ROWS] = {2, 3, 4, 5}; byte colPins[COLS] = {6, 7, 8, 9};
Keypad kpd = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);

int enA = 10; int in1 = 11; int in2 = 12;

void setup() {
  pinMode(enA, OUTPUT); pinMode(in1, OUTPUT); pinMode(in2, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  char key = kpd.getKey();
  if (key) {
    if (key == '1') analogWrite(enA, 100);
    else if (key == '2') analogWrite(enA, 200);
    else if (key == '3') analogWrite(enA, 255);
    else if (key == '0') analogWrite(enA, 0);
    digitalWrite(in1, HIGH); digitalWrite(in2, LOW);
  }
}

Step 7: Save your code. See the Getting Started section

Step 8: Select the arduino board and port See the Getting Started section:Selecting Arduino Board Type and Uploading your code.

Step 9: Upload your code. See the Getting Started section:Selecting Arduino Board Type and Uploading your code

CONCLUSION

Operating physical input devices instantly modifies actuator behavior and updates visual indicators in real time.