Product Name:5pcs AD Keypad 1 AD port controll 4 buttons matrix keyboard Development Module for Arduiuo ADC
Packing list:
5 pcs 4 keyAD Keyboard
Description:
1 Power Supply Voltage : 2-5V
2 4 Buttons 1 Analog Output(AD Pin)
3 PCB Size : 30x12mm
4 Weight : 1.5g
Ideal for linking up to your Ardiuno UNO Mini Nano Mega2560 etc,or others MCU ( AVR STM32 ARM7 ARM9 ARM10 PIC AT89C51 STC MSP430 FPGA CPLD etc.)
Circuit schematics :
Connection with Arduiuo UNO :
Arduiuo uno/mega2560 Code
//******************************************************//
/*
Arduiuo_4 key analog Buttons
This example code is in the public domain.
*/
#define key1ValueMin 96
#define key1ValueMax 106
#define key2ValueMin 144
#define key2ValueMax 159
#define key3ValueMin 193
#define key3ValueMax 213
#define key4ValueMin 242
#define key4ValueMax 255
int adPin = A0, // select the input pin for the potentiometer
int keyValue,
int keyValue_r,
int keyValue_rr,
//key scan
int key_scan(void)
{
int adValue,
int key,
adValue = analogRead(adPin),//read ad Value
adValue = adValue / 4,
if(adValue >= key1ValueMin && adValue <= key1ValueMax)// k1
{
key = 1,
}
else if(adValue >= key2ValueMin && adValue <= key2ValueMax)// k2
{
key = 2,
}
else if(adValue >= key3ValueMin && adValue <= key3ValueMax)// k3
{
key = 3,
}
else if(adValue >= key4ValueMin)// k4
{
key = 4,
}
else //Invalid value
{
key = 0,
}
return key,
}
void setup() {
Serial.begin(9600),
}
void loop() {
//Save three key scan value
keyValue_rr = keyValue_r,
keyValue_r = keyValue,
keyValue = key_scan(),
//Three scanned values are the same, indicating that key is valid
if(keyValue > 0 && keyValue==keyValue_r && keyValue_r==keyValue_rr)
{
Serial.print(''keyValue = ''),
Serial.println(keyValue),
}
delay(100), //Each scan interval 100-200MS
}
//******************************************************//
Specifications
Material
PCB
Origin
Mainland China
Operating Voltage
2-5V
button
4
type
Analog Button