Build it step by step
0 of 8 doneWire the pedal
One contact to D2, the other to GND.
Wire the display
VCC, GND, SDA to A4 and SCL to A5.
Wire the buzzer
Positive to D8, negative to GND.
Install the libraries
Adafruit SSD1306 and Adafruit GFX.
Upload the sketch
The screen shows Ready.
Tap the pedal
The clock starts with a chirp.
Tap to lap
Up to three laps show on the screen.
Hold for one second
The clock stops, tap again to reset.
How do you build a hands-free workbench timer?
A foot pedal starts, laps and stops a stopwatch shown on an OLED, so both hands stay on the work. You need Arduino Nano, Foot switch (momentary), SSD1306 OLED Display, Passive buzzer, Jumper wires male to male (40 pcs, 20 cm) and Breadboard 830 Tie Points. It takes 8 steps and about 100 minutes.
- Level
- Beginner
- Time
- About 100 min
- Parts
- 6
Parts list
- Development BoardsBuyArduino Nano × 1
- SwitchesBuy
- DisplaysBuy
- Motors & ActuatorsBuyPassive buzzer × 1
- PrototypingBuy
- PrototypingBuy
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| Foot switch contact 1 | Nano D2 | Pedal input, uses the internal pull-up |
| Foot switch contact 2 | Nano GND | Pedal pulls the pin low when pressed |
| OLED VCC | Nano 5V | Display power (check your module accepts 5 V) |
| OLED GND | Nano GND | Common ground |
| OLED SDA | Nano A4 | I2C data |
| OLED SCL | Nano A5 | I2C clock |
| Passive buzzer positive | Nano D8 | Tone output |
| Passive buzzer negative | Nano GND | Common ground |
Code
A bench timer is handy when both hands hold a probe and a part, and a foot pedal solves that. The pedal is just a normally open switch between pin D2 and ground, read with the internal pull-up so the pin is high at rest and low when pressed. One pedal needs to do three jobs, so the sketch tells a tap from a hold. A tap starts the clock, and a tap while running records a lap, which is the time since the previous lap. Holding the pedal for one second stops the clock, and a tap after that resets it. The sketch is a three-state machine: idle, running and stopped. Mechanical contacts bounce, so a change is accepted only if 30 milliseconds have passed since the last one. The time is measured with millis, so it keeps true time while the screen redraws ten times a second. The buzzer gives a short chirp for each action so you know the pedal registered without looking, and it beeps every minute while running, which is useful for timed etching, curing or soldering practice. Keep the pedal lead away from mains cables, and put the pedal on a mat so it does not slide.
Runs on a virtual Arduino Nano in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
Adafruit_SSD1306 oled(128, 64, &Wire, -1);
const int PEDAL = 2, BUZZ = 8;
const unsigned long DEBOUNCE = 30, HOLD_MS = 1000, BEEP_EVERY = 60000UL;
enum Mode { IDLE, RUNNING, STOPPED };
Mode mode = IDLE;
unsigned long startMs = 0, stopElapsed = 0, lastLapAt = 0;
unsigned long laps[3];
int lapCount = 0;
unsigned long beepsDone = 0;
bool pedalState = false, longHandled = false;
unsigned long lastChange = 0, downAt = 0, lastDraw = 0;
unsigned long elapsedNow() {
if (mode == IDLE) return 0;
if (mode == STOPPED) return stopElapsed;
return millis() - startMs;
}
void fmt(char *out, unsigned long ms) {
unsigned long t = ms / 100; // tenths of a second
snprintf(out, 16, "%02lu:%02lu.%lu", t / 600, (t / 10) % 60, t % 10);
}
void draw() {
char line[16];
oled.clearDisplay();
oled.setTextColor(SSD1306_WHITE);
oled.setTextSize(2);
oled.setCursor(0, 0);
fmt(line, elapsedNow());
oled.print(line);
oled.setTextSize(1);
oled.setCursor(0, 22);
oled.print(mode == IDLE ? "Ready: tap to start" : mode == RUNNING ? "Running: tap=lap, hold=stop" : "Stopped: tap to reset");
for (int i = 0; i < lapCount && i < 3; i++) {
oled.setCursor(0, 36 + i * 10);
fmt(line, laps[i]);
oled.print("Lap "); oled.print(i + 1); oled.print(" "); oled.print(line);
}
oled.display();
}
void shortPress() {
if (mode == IDLE) {
startMs = millis(); lastLapAt = 0; lapCount = 0; beepsDone = 0;
mode = RUNNING;
tone(BUZZ, 1200, 80);
} else if (mode == RUNNING) {
unsigned long now = elapsedNow();
if (lapCount < 3) laps[lapCount++] = now - lastLapAt;
else { laps[0] = laps[1]; laps[1] = laps[2]; laps[2] = now - lastLapAt; }
lastLapAt = now;
tone(BUZZ, 1800, 60);
} else {
mode = IDLE;
tone(BUZZ, 800, 80);
}
}
void longPress() {
if (mode == RUNNING) {
stopElapsed = elapsedNow();
mode = STOPPED;
tone(BUZZ, 600, 300);
}
}
void setup() {
pinMode(PEDAL, INPUT_PULLUP);
Serial.begin(9600);
if (!oled.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println("OLED not found, try address 0x3D");
while (true) {}
}
draw();
}
void loop() {
bool pressed = (digitalRead(PEDAL) == LOW);
if (pressed != pedalState && millis() - lastChange > DEBOUNCE) {
lastChange = millis();
pedalState = pressed;
if (pressed) { downAt = millis(); longHandled = false; }
else if (!longHandled) shortPress();
}
if (pedalState && !longHandled && millis() - downAt >= HOLD_MS) {
longHandled = true;
longPress();
}
if (mode == RUNNING && elapsedNow() / BEEP_EVERY > beepsDone) { // beep each minute
beepsDone++;
tone(BUZZ, 1000, 200);
}
if (millis() - lastDraw >= 100) {
lastDraw = millis();
draw();
}
}Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Power on | 00:00.0 and the Ready message |
| Tap once | Clock runs and the display updates |
| Tap while running | A lap line appears with the split time |
| Hold for 1 second | Clock stops with a long low tone |
| After one minute running | A beep sounds at 01:00.0 |
If it does not work
Blank screen
Check A4 and A5, and try address 0x3D in the sketch.
Pedal acts twice
Increase the DEBOUNCE value a little.
Pedal does nothing
Check the wires reach D2 and GND, some pedals are normally closed.
Stop never happens
Hold the pedal for a full second without releasing.
No sound
Check the buzzer is a passive type on D8.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the hands-free workbench timer?
Arduino Nano, Foot switch (momentary), SSD1306 OLED Display, Passive buzzer, Jumper wires male to male (40 pcs, 20 cm) and Breadboard 830 Tie Points.
How long does the hands-free workbench timer take to build?
About 100 minutes for a beginner maker, in 8 steps.
How do I know the hands-free workbench timer works?
Power on: 00:00.0 and the Ready message. Tap once: Clock runs and the display updates. Tap while running: A lap line appears with the split time.
Blank screen: what should I check?
Check A4 and A5, and try address 0x3D in the sketch.
Pedal acts twice: what should I check?
Increase the DEBOUNCE value a little.
Pedal does nothing: what should I check?
Check the wires reach D2 and GND, some pedals are normally closed.
Stop never happens: what should I check?
Hold the pedal for a full second without releasing.
