Amal Mathew
Published © GPL3+

How to Make a Customizable Punchable Keyboard Button

Angry at the office? Use this customizable keyboard button that you can punch.

BeginnerFull instructions provided30 minutes7,699

Things used in this project

Hardware components

Arduino Micro
Arduino Micro
You can use any ATmega32U4 based microcontroller such as Arduino Leonardo , which makes the microcontroller recognisable as a mouse or keyboard.
×1
Piezo Element
Piezo electric disks can be found in the speakers in some musical gift cards.
×1
Resistor 1M ohm
Resistor 1M ohm
To limit the voltage and current produced by the piezo and to protect the analog input.
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

spongy material
cloth (any colour)
To cover sponges and electronics inside.you can use a needle and thread to make a enclosure for sponges.

Story

Read more

Schematics

Fritzing file

Code

customizable_punchable_keyboard_button.ino

Arduino
#include <Keyboard.h>

const int knockSensor = A0; // the piezo is connected to analog pin 0
const int threshold = 100;  // threshold value 


// these variables will change:
int sensorReading = 0;      // variable to store the value read from the sensor pin


void setup() 
{
  
   Keyboard.begin();
}

void loop() 
{
  // read the sensor and store it in the variable sensorReading:
  

sensorReading = analogRead(knockSensor);

  // if the sensor reading is greater than the threshold:
 
 if (sensorReading >= threshold) 
{
   
// to customize key function change ASCII values below  , refer  https://www.arduino.cc/en/Reference/ASCIIchart

    Keyboard.write(32);      //ASCII value of Space bar is 32 ,
    delay(150);
    Keyboard.releaseAll();
    
  }

}

Credits

Amal Mathew

Amal Mathew

24 projects • 79 followers
Maker | Not much to boast about – just a human, open-source believer. Simple as that.

Comments