Help with arduino project that uses a keypad

Hey everyone this is my first post on this forum. I recently purchased an arduino uno and im still learning. Currently working on the following project:

Breadboard Layout | Arduino Lesson 13. DC Motors | Adafruit Learning System.

Basically the pwm signal to one of the pins is altered between 0-255 which in turn changes the voltage,thus reducing or increasing the speed of the motor.So my question is if there is a way to use a hex keypad (4x4) to enter the speed in the serial monitor remotely rather than always having a computer connected to the uno and changing the speed from there.

Im also using an LCD to display the speed entered.

These are the keypads i have available :

The code looks like this

    #include <LiquidCrystal.h>
    LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
    int motorPin = 3;
    void setup() 
      lcd.begin(16, 2);
      pinMode(motorPin, OUTPUT);
      while (! Serial);
      Serial.println("Speed 0 to 255");
    void loop() 
      if (Serial.available())
        int speed = Serial.parseInt();
        if (speed >= 0 && speed <= 255)
          analogWrite(motorPin, speed);
          lcd.print("The Speed is");
          lcd.print(" ");

Any articles that you know of or examples will be greatly appreciated.
Thank you for your time and efforts

Do you own any of those two keypads to do testing? Have you looked for Keypad + Arduino yet, because there is a nice keypad library you can play with and it also comes with examples.

Let me know what you find.

Ill look at those libraries thanks for the help :slight_smile:

Ill look at those libraries thanks for the help :slight_smile:

You need to look at the keypads,not the libraries. It's like looking at a photo of Ice cream and eating the ice cream actually.

Unless the keypad has a built-in shift register, they are all pretty much the same. Some have 12 keys, others 16, and on the off chance 20 or 24 (very rare, unless custom made)

The keypad library can handle all of them. You can even use my OnewireKeypad library. I don't recommend it for anything larger than 4x4 keypads, but it uses a voltage divider so in theory it can work for large keypads too.

Do you want to use a keypad, or do you want to change the speed of the motor without using a computer. It might be easier to use a pot connected to the Arduino.

If you do decide a keypad might be for you then check out my YouTube video #13 which goes into some detail on the benefits of using one (not least the number of pins you'll save).

URL in the sig of this post.