Creative Commons images are CC BY-NC-SA 3.0

14.95

added to your
shopping cart

quantity
In stock 51 in stock
14.95 1+ units
13.46 10+ units
11.96 100+ units

Description: This is the VKey Voltage Keypad, a simple board that adds a keypad to your microcontroller project without using multiple I/O pins. This keypad has 12 pushbutton switches in a 3x4 array. The VKey operates by outputing an analog voltage to encode which key has been pressed, which can be read by an analog to digital converter on a microcontroller on a single input pin.

Traditional digital keypad interfacing techniques can require a large number of digital I/O lines. On a small controller, there may not be many I/O pins left for other tasks. The VKey operates at a voltage of 3.3-5.5V and features a dual opamp which is used as a current source and buffer amplifier.

Documents:

Comments 17 comments

  • It did not run correctly on any of my boards (Leonardo, Due). Thus, I dumped the library, determined the analogRead values for every key (which might be different per board), increase them a little bit (about 10 points) and use the following program adapted from DFrobot example code to use the five buttons on the Romeo, but added a threshold of 20, because the keyboard is noisy:

    int key=-1;
    int oldkey=-1;
    int adc_key_val [12] = {45,85,125,170,215,260,300,345,380,425,470,510};
    int adc_key_in;
    
    
    void setup()
    {
     Serial.begin(9600);  
    }
    
    void loop(){ 
      delay(50);   
      adc_key_in=analogRead(0);
      key=get_key(adc_key_in);
     if ((key != oldkey) && (key !=-1)){ Serial.println(key);}
     oldkey=key;
    }
    
    
     int get_key(unsigned int input){
     int k;
    for (k=0; k<12; k++){
      if (input<20){k=-1; return k;}
      if (input<adc_key_val[k]){k=12-k; return k;}
      if (k>=12){k=-1;return k;}
      }
    }
    
  • Hooked this up and am having trouble with the default library settings. Basically the 1 key doesn’t register a key press at all, 2 key reports as 1, 3 reports a 2, 4 reports 3, 5 reports 4. Then there is a gap (no 5 key), and the 6 key through 12 key work fine. I’m running this on a RedBoard with a measured Vcc of 4.987 volts. Looks like the VScaleKey table may need to be tweaked further for production variances. Here are the Vout readings for each key: 1 - 2.488v, 2 - 2.280v, 3 - 2.073v, 4 - 1.867v, 5 - 1.660v, 6 - 1.453v, 7 - 1.246v, 8 - 1.038v, 9 - 0.831v, 10 - 0.623v, 11 - 0.414v, 12 - 0.207v, Open - 0.061v. Is anyone else having similar problems with this board?

    • It looks like your samples are spaced a little wider than the boards I used to get the firmware running.

      In the calibration table, try the following values

      • min = 21
      • step = 43
      • max = 496

      I just used the spreadsheet in the github repo called ADC.ods. Using your VDC measurements, I estimated the ADC value (ADC = (Vin/Vref)*1024), and plugged that into the spreadsheet.

      You might get better values by using readAnalog() to capture the ADC value that each key yields, and putting those values into the green area of the spreadsheet. The min, step and max for those voltages show up in the light blue cells.

      • The results were about the same with min/step/max of 21/43/496. The ADC readings are as follows: No Key - 10, K1 - 504, K2 - 462, K3 - 420, K4 - 378, K5 - 336, K6 - 293, K7 - 251, K8 - 209, K9 - 166, K10 - 124, K11 - 82, K12 - 40. Plugging those into the spreadsheet and it shows min/step/max of 18.9/40/497.9 so I used 19/40/498 with similar results. Something still not right here.

        • Yeah…something doesn’t quite jive there. You report a max reading of 504, we somehow both arrived at a max of 496. I just put your measurements into the spreadsheet, and here’s the resulting table.

          18.9    min
          42  step
          Key #   lower threshold mid point   upper threshold
          12  18.9    39.4    59.9
          11  60.9    81.4    101.9
          10  102.9   123.4   143.9
          9   144.9   165.4   185.9
          8   186.9   207.4   227.9
          7   228.9   249.4   269.9
          6   270.9   291.4   311.9
          5   312.9   333.4   353.9
          4   354.9   375.4   395.9
          3   396.9   417.4   437.9
          2   438.9   459.4   479.9
          1   480.9   501.4   521.9
          

          That gives me a min/step/max of 18/42/522. The values you measured are within 3 counts of the midpoint of each bin there, so you should be squarely within each.

          Please give that a try.

          • Replacing the original (5v) min/step/max of 17/40/496 with 18/42/522 did the trick; the keys all decode perfectly now. Wondering if there is a way to have the Arduino auto-calibrate itself so these settings could be generated automatically as part of initialization? Also curious why your development keyboard varied from my production keyboard so much since the divider circuit on both boards is coming from a well regulated 5v source.

  • More than 20 years ago Microchip published an I/O app guide, a little 3x5in. sized printed pamphlet (remember those?) that was included with the development boards. Most of Microchip’s business was low pin count parts back then, so I/O was at a premium. This guide showed how to get more bang from each I/O - using one I/O to drive 2 LEDs, PWM for DAC output, etc. This is very similar to one of those app note circuits except as I remember that one used a simple voltage divider rather than a current source. Funny how nothing ever really changes.

  • Just port the Arduino Library to NETMF (Netduino Board) with a KeyPress Event and synchronous ReadKey() method that will block until a key is pressed - I don’t have the Keypad to test (but 90% sure it will work) so, am wondering if anybody have a Netduino and the Keypad to test the code for me before I upload it CodePlex

  • if you remove the opamp current source it would work across all voltage ranges (the buffer can take) … your comparing it against the supply voltage anyway so it would save a ton of pain!

  • With 12 keys on analog voltage, I’m thinking: map the 12 tones of the musical scale for an analog keyboard/synth. There’s a MIDI application in this. I want one.

  • Interesting concept! I wonder if a ‘digital’ version is planned?

    An MCU (micro controller) in place of the op amp, reading switch closures, using key-scanning of a matrix, could then output serial data of key closures. This would require only two signal pins (plus supply and ground) for the popular I2C (or TWI) protocol.

    Having an MCU allows programming of behavior, and resolution of the multiple button press issue. Or, to distinguish between a button “tap” (< a second) and a button “hold” (> a few seconds)

  • according to my calcs this design will only work when limited to +/- 10C of temperature change. due to the diode drop changing with temp. maybe add some temp comp, either in software or hardware. the old analog mono synths used a similar circuit and had temp comp to combat this issue.

    • Like many things in engineering, the temperature dependence was a tradeoff, so this can have a relatively constant output voltage regardless of the supply voltage (granted, around room temperature).

      If we can constrain the problem to a single supply voltage, then a simple resistor divider could be used to set the current. Or we could forward bias the diode more strongly – It looks like the Vf/Temperature curves track more closely above 100mA. Make that a lot more strongly.

      There might be some really clever ways to make self-calibrating software, too. If you put a jumper in place of button 1, the thing would idle at it’s max output voltage. Dividing that by 12 would tell you how big each step needed to be.

      And don’t get me started on monosynths, or we’ll be here all day!

  • if all you need is 1 key at a time it saves a lot of pins. wonder about temperature effects however.

  • Can it detect multiple button presses?

    • Not according to the “Hookup Guide” - “One situation to consider is when more than one key is pressed at the same time. The VKey implements high-key number (or low voltage) priority – when more than one of the switches is closed at a time, the output will indicate the higher key number. For instance, if you hold down 5 and 9 together, the output will indicate key 9 is pressed.”


Related Products