5PCS 3-5V 4 Buttons AD Keypad keyboard Analog output button for Arduino nano uno raspberry pi 3 breadboard stm32 starter kit

8.56

9965 in stock

SKU: 32710263291 Categories: ,

Product Name: 5PCS 3-5V 4 Buttons AD Keypad keyboard Analog output button for Arduiuo nano uno raspberry pi 3 breadboard stm32 starter kit

Packing list:

5 p cs 4 key Analog Buttons( With Pin Header )

Description:

1 Power Supply Voltage : 3-12V
2 4 Buttons 1 Analog Output(AD Pin)
3 PCB Size : 30x12mm
4 Weight : 1.8g
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 raspberry pi 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
}
//******************************************************//
Model Number

KC11B04*5

is_customized

Yes

Operating Voltage

3-5V

button

4

type

Analog Button

Reviews

There are no reviews yet.

Be the first to review “5PCS 3-5V 4 Buttons AD Keypad keyboard Analog output button for Arduino nano uno raspberry pi 3 breadboard stm32 starter kit”

Your email address will not be published. Required fields are marked *