Handheld Vibrating Timer Prototype using Trinket

There are times while exercising when it would be useful to have a simple one-button hand-held 30-second timer that vibrates. At least that's what my wife tells me. This seemed like a good excuse to play with Adafruit's mini microcontroller called "Trinket". These are an $8 tiny board built around the Atmel ATtiny85.

The idea of the device is simple. You press the button, and it vibrates quickly to notify you that it is armed. Then after 30 seconds it vibrates again to say the time is up. I might modify it later so that two quick pushes sets a 60 second timer, but I'm starting simple.

I haven't settled on the batteries yet. For the prototype it's just using a 4-AA pack. But that's a little bulky. I'm using the 3.3V Trinket, and I've tested that I can drive it from 3-AA, so I might do that. I also want to test with 2x 3V coin cell batteries, although I suspect the battery life would not be ideal. Another option is a rechargeable Lipo battery.

Currently the prototype is just built on a breadboard. Next step will be to mount on a small circuit board, and fit into a hand-held enclosure. I have a small tin that I'm planning to try and squeeze it all into.

Here's the part list for the circuit diagram shown below

The circuit diagram is drawn using the open source Fritzing program. Adafruit have made available a library of their components - including the Trinket. Here is a How-To on Installing the Adafruit Fritzing Library.

Lastly, here's the code running on the Trinket.

/* Vibrating Timer */
int vibrator = 1; 
int button = 0;
boolean primed = false;
boolean running = false;
unsigned long timer;

void setup() {
  pinMode(vibrator, OUTPUT);
  pinMode(button, INPUT);

void vibrate(int length) {
  digitalWrite(vibrator, HIGH);
  digitalWrite(vibrator, LOW);

void loop() {
  int buttonState = digitalRead(button);
  // holding the button down "primes" the process
  if (buttonState == HIGH) {
    primed = true;
    running = false;
  // releasing the button starts the timer and vibrates
  if (buttonState == LOW && primed == true) {
    timer = millis() + 30000; 
    running = true;
    primed = false;
  // when the timer expires, reset and vibrate
  if (running == true && millis() > timer) {
    running = false;
    primed = false;


  1. How will this circuit simply using a PIC16F628? I await advice. Thanks a lot.

    1. I've never used a PIC16F628. Good luck getting it to work.