This website uses cookies to ensure you get the best experience on our website.
Arduino Uno Resistance Training Rest Timer with Display
Arduino Uno Resistance Training Timer enclosure with display

Version 2 Arduino Uno Resistance Rest Period Timer with OLED Display. 

Arduino Uno resistance training rest timer with an OLED display. This is our version 2. This version displays the resistance training exercise sets done by the athletes 1 or 2. It simply helps us remember which set number we are busy with. It is programmed to count to 7. We normally don't do more than 7 sets of resistance training per exercise. If you start with a new exercise, reset and your count display starts all over again. Of course the original design of this timer still exists, meaning it will count the 2 minute rest period between sets and indicates time laps with the audible buzzer for each athlete. In our case it is my partner and I. The uno board and components will now be enclosed and should very much be mobile and ready for tough service in the gym.

#include <Wire.h>

#include <Adafruit_GFX.h>

#include <Adafruit_SSD1306.h>


// OLED display width and height

#define SCREEN_WIDTH 128

#define SCREEN_HEIGHT 64


// Declaration for an SSD1306 display connected to I2C (SCL, SDA pins)

#define OLED_RESET     -1 // Reset pin # (or -1 if sharing Arduino reset pin)

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);


// Pins for the buttons and the buzzer

const int athlete1ButtonPin = 2;

const int athlete2ButtonPin = 3;

const int buzzerPin = 9;


// Set the rest time in milliseconds

const unsigned long restTime = 120000;


// Variables to store start time and count for each athlete

unsigned long athlete1StartTime = 0;

unsigned long athlete2StartTime = 0;

int athlete1Count = 0;

int athlete2Count = 0;


void setup() {

  // Initialize the OLED display

  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {

    for(;;); // Don't proceed, loop forever

  }

  display.clearDisplay();

  display.setTextSize(6); // Large text size

  display.setTextColor(SSD1306_WHITE);


  // Initialize the button and buzzer pins

  pinMode(athlete1ButtonPin, INPUT_PULLUP);

  pinMode(athlete2ButtonPin, INPUT_PULLUP);

  pinMode(buzzerPin, OUTPUT);


  // Initialize the count display

  updateDisplay();

}


void loop() {

  // Check if athlete 1 button is pressed

  if (digitalRead(athlete1ButtonPin) == LOW) {

    delay(50); // Debounce delay

    if (digitalRead(athlete1ButtonPin) == LOW) {

      if (athlete1StartTime == 0) {

        athlete1StartTime = millis(); // Start rest time countdown

      }

      if (athlete1Count < 9) {

        athlete1Count++;

        updateDisplay();

      }

    }

  }


  // Check if athlete 2 button is pressed

  if (digitalRead(athlete2ButtonPin) == LOW) {

    delay(50); // Debounce delay

    if (digitalRead(athlete2ButtonPin) == LOW) {

      if (athlete2StartTime == 0) {

        athlete2StartTime = millis(); // Start rest time countdown

      }

      if (athlete2Count < 9) {

        athlete2Count++;

        updateDisplay();

      }

    }

  }


  // Check if 2 minutes have passed for athlete 1

  if (athlete1StartTime > 0 && millis() - athlete1StartTime >= restTime) {

    triggerBuzzer(1); // Single long buzz for athlete 1

    athlete1StartTime = 0; // Reset start time

  }


  // Check if 2 minutes have passed for athlete 2

  if (athlete2StartTime > 0 && millis() - athlete2StartTime >= restTime) {

    triggerBuzzer(2); // Double short buzz for athlete 2

    athlete2StartTime = 0; // Reset start time

  }

}


void updateDisplay() {

  display.clearDisplay();


  // Draw a vertical line to divide the display

  display.drawFastVLine(SCREEN_WIDTH / 2, 0, SCREEN_HEIGHT, SSD1306_WHITE);


  // Display athlete 1 count on the left

  display.setCursor(5, 10);

  display.print(athlete1Count);


  // Display athlete 2 count on the right

  display.setCursor(74, 10);

  display.print(athlete2Count);


  display.display();

}


void triggerBuzzer(int athlete) {

  if (athlete == 1) {

    // Single long buzz for athlete 1

    digitalWrite(buzzerPin, HIGH);

    delay(2000); // Buzzer on for 2 seconds

    digitalWrite(buzzerPin, LOW);

  } else if (athlete == 2) {

    // Double short buzz for athlete 2

    digitalWrite(buzzerPin, HIGH);

    delay(100); // Buzzer on for 100 milliseconds

    digitalWrite(buzzerPin, LOW);

    delay(100); // Off for 100 milliseconds

    digitalWrite(buzzerPin, HIGH);

    delay(100); // On again for 100 milliseconds

    digitalWrite(buzzerPin, LOW);

  }

}

Leave a Reply

Your email address will not be published. Required fields are marked *


Math Captcha
36 + = 41