Skip to content

upperboundcom/AnalogKeypad

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 

AnalogKeypad

Project page: http://upperbound.com/projects/12-button-keypad/

This is an Arduino library for a 12 button keypad that uses just one analog pin and ground connection.

The library debounces the 12 buttons and maps the voltage levels to integer values defined in the AnalogKeypad.h file.

Put the .h and .cpp file in your Arduino libraries/ folder.

Demo

/*
 * A simple test and demonstration of the AnalogKeypad library
 * This keypad uses only one analog pin and ground connection.
 * 
 * Copyright 2017 Upperbound.com
 * 
 */

#include <AnalogKeypad.h>

/* Processes button presses from a 12-button keypad with this configuration:

  +--------------+
  | 1  |  2  | 3 |
  +--------------+  
  | 4  |  5  | 6 |
  +--------------+
  | 7  |  8  | 9 |
  +--------------+
  | 10 | 11 | 12 |
  +--------------+
*/
  
// We'll use analog input 5
const int inputPin = A5;

AnalogKeypad keypad(inputPin);

void setup() {

  Serial.begin(9600);
  Serial.println("The buttons correspond to this layout:");
  Serial.println("+--------------+");
  Serial.println("| 1  |  2  | 3 |");
  Serial.println("+--------------+");
  Serial.println("| 4  |  5  | 6 |");
  Serial.println("+--------------+");
  Serial.println("| 7  |  8  | 9 |");
  Serial.println("+--------------+");
  Serial.println("| 10 | 11 | 12 |");
  Serial.println("+--------------+");
  Serial.println("Press a button!");

}

void loop() {

  int reading =keypad.read();
  
  if (reading <13) {
    
    Serial.print(reading);
    Serial.println(" pressed");  
  }
  delay(150);
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages