| 
  • If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • You already know Dokkio is an AI-powered assistant to organize & manage your digital files & messages. Very soon, Dokkio will support Outlook as well as One Drive. Check it out today!

View
 

ButtonShield

Page history last edited by Chris 11 years, 10 months ago

 

The ButtonShield is an Arduino shield for keyboard input programmable through the Arduino IDE.

 

I always used my blackberry as the starting point of how I think about modular, open source hardware. It’s got a screen (some have a touchscreen), a motherboard, battery, wireless communication and buttons. Well, Touchscreen = TouchShield Slide , Motherboard = Arduino , Battery = Lithium Backpack , Wireless = Xbee , and…buttons with the Buttonshield. So here it is… it’s a shield built for the Arduino profile that has 32 buttons on it. It has a mode A or B selector, so you can wire up two of these directly to an Arduino, a lot like the InputShield , and still have pins for the TouchShield. And for everything you need to make your own “openberry”, check out the OpenBerry kit over here

 

The ButtonShield is a shield built for the Arduino profile that has 32 buttons on it. It has a mode A or B selector, so you can wire up two of these directly to an Arduino, a lot like the InputShield, and still have pins for the TouchShield display.

 

The ExtenderShield for Arduino modularity

Here is an example of how to mount the ButtonShield onto an Arduino using a DoubleWide ExtenderShield. The DoubleWide ExtenderShield allows the TouchShield Slide display, Lithium Backpack, and ButtonShield to be added to form a more complex Arduino gadget.

 

ButtonShield mounted to a DoubleWide ExtenderShield

 

Key value map

The ButtonShield occupies six Arduino digital pins. These pins report back the currently pressed key. The ButtonShield has a Lock button with LED, similar to a caps lock button. When the lock button is pressed, the key values change.

 

   

Return codes (lock key not pressed)
Return codes (lock key pressed)

 

The key value is the pin read as 6-bits, here's an example:

 

1 = 000001

2 = 000010

...

63 = 111111

 

Here's some sample code to use the ButtonShield on the Arduino.

 

Read the key press

 This routine assumes you've previously set the mode to A or B. See setMode() for details.

 

int ButtonShield::readButtons() {
    uint8_t button = 0;
    for (uint8_t pin=0; pin<6; pin++) {
        button |= digitalRead(pinList[pin]) << pin;
    }
    return button;
}

 

Change the mode

The mode control switch is on the backside of the shield.

 

Two ButtonShields could be mounted to a single Arduino by changing the occupied pins.

 

Mode A (pins: 4,5,6,7,18,19)

Mode B (pins: 8,9,10,11,16,17)

 

Flip the mode switch, then execute the following code.

 

uint8_t pinList[6];

/* Mode A = 0, Mode B = 1*/ 

void ButtonShield::setMode(uint8_t mode) {

    /* Which mode? */
    if (mode == 0 ) {
        //Mode A
        pinList[0] = 4;
        pinList[1] = 5;
        pinList[2] = 6;
        pinList[3] = 7;
        pinList[4] = 18;
        pinList[5] = 19;
    } else {
        //Mode B
        pinList[0] = 8;
        pinList[1] = 9;
        pinList[2] = 10;
        pinList[3] = 11;
        pinList[4] = 16;
        pinList[5] = 17;
    }

    for (uint8_t pin=0; pin<6; pin++) {
        pinMode(pinList[pin],INPUT); //pin as input
        digitalWrite(pinList[pin],HIGH); //enable internal pullup
    }
}

 

Specs

  • 32 key buttons
  • 1 caps lock with dual LEDs
  • 1 space bar
  • Underglow LED
  • 2 Operating Modes, A & B
  • Fits squarely on top of Arduino

 

Media

Here’s a video showing what the ButtonShield looks like passing through values to the Arduino

 

 

 

 

Resources

 

Comments (0)

You don't have permission to comment on this page.