Use An Arduino Leonardo and a Button for a USB Foot Pedal

It is possible to use an Arduino Leonardo and a Button for a USB Foot Pedal.  Here is the story on how one was built.

A long time ago, my daughter used to transcribe audio cassette tapes using a transcribing machine. It had a nice foot pedal to start, stop and rewind the cassette tape. Recently, she decided to get back into transcribing. Instead of audio from cassette tapes, she is transcribing MP3 audio files on the computer. She choose a software program called ‘Express Scribe Transcription Software’ from NCH Software for that purpose. It allows her to use any sort of word processing software to key in the text transcription while she listens to the audio it plays. Express Scribe allows her to map keys, which it intercepts, to stop and restart playing the audio. A nice feature that it has, is that it automatically goes back several seconds when stopped so no ‘rewind’ is really needed.

Here is a screen shot of what that software looks like:

Express Scribe Transcription Software
The Express Scribe Software also works with several different USB foot pedals.  The USB foot pedal acts as an extra keyboard and sends keystrokes when the pedal is pressed. If you have ever done any transcribing, you will know how handy using your foot is, versus using the keyboard for stopping and starting the audio.

Rather than buying a USB foot pedal, Dad was asked if there was an Arduino solution. Dad of course took up the challenge.

The first step in the process was to set up a prototype of the process. An Arduino Leonardo was chosen (due to Dad having several around) and due to the Leonardo being able to plug into the computer and function as a USB keyboard.

Every USB device is assigned a device class, which defines what exactly its general purpose is. The Leonardo can  be programmed  to act  like a mouse, keyboard or other HID (Human Interface Device) class USB device, so it is just right for this project.

A simple circuit was constructed to test the functionality of the Leonardo sending keystrokes when a button is pressed.

Here is the circuit (just a basic button circuit):

 

You can get the Fritzing code used to create that diagram HERE.

The Express Scribe software was configured to use the ` key for stopping playback (and rewinding) and the Tab key was configured to start the playback. So the Arduino Leonardo sketch was coded to send those keys when a button was pressed.

Here is the sketch (i.e. the code which is compiled via the Arduino IDE and loaded into the Leonardo):

#include "Keyboard.h"

const int buttonPin = 4;
int previousButtonState = HIGH;
int counter = 0;

void setup() {
  pinMode(buttonPin, INPUT);
  Keyboard.begin();
}

void loop() {
  int buttonState = digitalRead(buttonPin);
  if ((buttonState != previousButtonState)
      && (buttonState == HIGH)) {
    counter++;
    if (counter == 1) {
     Keyboard.print("`");
    }
    else {
     Keyboard.print("\t");
     counter = 0;
    }
    delay(500);`
  }
  previousButtonState = buttonState;
}

You will notice that only one button is used. There is not a separate button for stop and start. There is really no need. The sketch keeps track of what comes next. Pressing the button alternates between sending the Stop and Start keystrokes. Since the software takes care of the rewind (on stop) there is no need for that function via the button.

That code and the sample circuit was plugged into the PC via a USB cable to the Arduino Leonardo for testing and worked very well. The next step was to build something that could function as a foot pedal (i.e. allowing the foot to press the button).

An important consideration in this project is that whatever is used as a ‘button’ for the foot pedal be easy to push and still function as a ‘button’.   Here are some pictures of the large ‘gaming’  type buttons that works well for our purpose:

 

 

 

 

 

 

 

To use an Arduino Leonardo and a Button for a USB Foot Pedal we also needed something to house the Arduino and keep the button stable on the floor.  Here is where the brother (or son depending on who’s view you are looking from) comes into the picture.   The brother is adept at wood work so he was tasked with coming up with that.

Leave a Reply

Your email address will not be published.