Introduction
This ADKey board with 10 keys can be used to drive your DFPlayer Pro, DFPlayer Mini, or Voice Recorder Module without programming or using various resistors. It offers 20 delicate key caps with comfortable hand feel, easy to be integrated in projects. You can also connect your favorite keys to the board through the welding pad on both sides. In addition, this ADkey board can be used as the ADkey input of a main-controller, by which it could expand 10 keys for your main-board via only one analog port.
Application
- Drive DFPlayer PRO
- Drive DFPlayer Mini
- Drive Voice Recorder Module
- Main-controller Button Expansion
Specification
- Power Supply: 3.3~5V
- Key Size: 6×6×7mm
- Product Size: 40×40mm/1.57×1.57”
Board Overview
Key | Series Resistance | Key | Series Resistance | |
---|---|---|---|---|
K0 | 0R | K1 | 3K | |
K2 | 6.2K | K3 | 9.1K | |
K4 | 15K | K5 | 24K | |
K6 | 33K | K7 | 51K | |
K8 | 100K | K9 | 220K |
Schematics
Tutorial
NOTE: When using this board to drive modules like DFPlayer Pro, DFPlayer Mini or Voice Recorder module, please do not connect VCC to the board since these modules have been pulled up 22K internally.
Requirements
- Hardware
- DFRduino UNO R3 (or similar) x 1
- ADKey board x1
- Jumper wires
- Software
Connection Diagram
Sample Code 1-Read Data
Press down a key, serial print a value.
#define ADPIN A0 //Read Pin
void setup() {
Serial.begin(115200);
}
void loop() {
// read the value from the sensor:
Serial.println(analogRead(ADPIN));
delay(10);
}
Expected Results
Sample Code 2-Read Key Value
Press a key on the board, serial print the corresponding key value.
#define RESOLUTION 10 //ADC resoltuion
#define MAXVALUE pow(2,RESOLUTION) //Resolution corresponding value
#define PRECISION 10 //Admissible error
#define ADPIN A0 //Read pin
uint32_t ADKeyVal[10] = {0}; //Corresponding key value
uint32_t ADCKeyIn = 0;
void setup() {
Serial.begin(115200);
ADKeybegin();
}
void loop() {
ADCKeyIn = analogRead(ADPIN);
if(ADCKeyIn < (MAXVALUE-PRECISION)){
Serial.print("K = ");
Serial.println(getKey());
}
delay(10);
}
void ADKeybegin(){
float RESValue[10] = {0, 3, 6.2, 9.1, 15, 24, 33, 51, 100, 220}; //Resistor resistance
for(uint8_t i = 0; i < 10; i++){
ADKeyVal[i] = RESValue[i]/(RESValue[i]+22)*MAXVALUE;
}
}
int8_t getKey(){
for(uint8_t i = 0; i < 10;i++){
if(ADCKeyIn > ADKeyVal[i]){
if((ADCKeyIn - ADKeyVal[i]) < PRECISION){
return i;
}
} else{
if((ADKeyVal[i] - ADCKeyIn) < PRECISION){
return i;
}
}
}
return -1;
}
Expected Results
Connection with DFPlayer Pro
Key | Series Resistance | Tap | Long-press |
---|---|---|---|
K0 | 0R | Pause & Play | |
K1 | 3K | Last | Volume+ |
K2 | 6.2K | Next | Volume- |
K3 | 9.1K | Playback mode switch | |
K4 | 15K | Fast Forward 10s | |
K5 | 24K | Pause & Play | Next |
K6 | 33K | Volume- | Volume- |
K7 | 51K | Volume+ | Volume+ |
K8 | 100K | Fast Backward 10s | |
K9 | 220K | Play the first song, set volume to 10 |
Connection with DFPlayer Mini
Left:
Key | Series Resistance | Tap | Long-press |
---|---|---|---|
K0 | 0R | First song | |
K1 | 3K | Second song | |
K2 | 6.2K | Third song | |
K3 | 9.1K | Fourth song | |
K4 | 15K | Last | Volume+ |
K5 | 24K | Next | Volume- |
K6 | 33K | Pause & Play | Volume- |
K7 | 51K | Repeat all | |
K8 | 100K | U/SD/SPI | |
K9 | 220K | Playback mode |
Right:
Key | Series Resistance | Tap | Long-press |
---|---|---|---|
K0 | 0R | Fifth song | |
K1 | 3K | Sixth song | |
K2 | 6.2K | Seventh song | |
K3 | 9.1K | Eighth song | |
K4 | 15K | Ninth | |
K5 | 24K | Tenth | |
K6 | 33K | Eleventh | |
K7 | 51K | Twelveth | |
K8 | 100K | Thirteenth | |
K9 | 220K | Fourteenth |
Connection with Voice Recorder Module
Key | Series Resistance | Tap | Long-press |
---|---|---|---|
K0 | 0R | Pause & Play | |
K1 | 3K | Last | Volume+ |
K2 | 6.2K | Next | Volume- |
K3 | 9.1K | Playback mode switch | |
K4 | 15K | REC | |
K5 | 24K | PLAY | |
K6 | 33K | Volume- | Volume- |
K7 | 51K | Volume+ | Volume+ |
K8 | 100K | Working mode switch | |
K9 | 220K | Delete currently playing file |
FAQ
For any questions, advice or cool ideas to share, please visit the DFRobot Forum.