glennedi
Published © GPL3+

Multistage "beep" fitness tester

Run this popular fitness test

BeginnerFull instructions provided521
Multistage "beep" fitness tester

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
LCD shield with keyboard
×1
Prototype shield (Stackable)
×1
Piezo sounder
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

How everything fits together

The piezo sounder

sounder wiring

Working view

Code

Beep fitness test code

C/C++
//  Beep fitness test using Robot LCD keypad shield
//  No ISR version
//  January 2021

//CHECK TO SEE IF LCD IS ONE OF THE FAULTY ONES
//MINE HAD PROBLEMS SO I DESOLDERED AND REMOVED THE FAULTY PIN 10
//REFERENCE - https://forum.arduino.cc/index.php?topic=96747.0 (Retrieved 7/June/2019)

#include <LiquidCrystal.h>

// select the pins used on the LCD panel
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
// these have been checked with http://www.robotshop.com/content/PDF/dfrobot-lcd-keypad-shield-schematic.pdf and the working example above


//------------------------------xxx
const int  buzzer_pin =3; //attach buzzer to this pin 
//------------------------------xxx

//#define test_me //Shortens the delays by a factor of 10 for test purposes


void setup()
{
//runs once - used for pin setup etc

//set up display
  lcd.begin(16, 2); // start the library
  lcd.setCursor(0,0);
  lcd.print("L----S----Vo2");
  
  //dash out vo2 display at start up
  lcd.setCursor(10,1);
  lcd.write("-----");
  
  pinMode (buzzer_pin,OUTPUT);

}


void loop()
{

//variables
bool buzzer_on = true;

//number of shuttle repeats per level
byte  shuttles[]={8, 8, 8, 9, 9, 10, 10, 11, 11, 11, 12, 12, 13, 13, 13, 14, 14, 15, 15, 16, 16, 16, 17, 17, 18};

//shuttle times in hundredth seconds
int shuttle_times[]={847, 800, 758, 720, 686, 655, 626, 600, 576, 554, 533, 514, 497, 480, 465, 450, 436, 424, 411, 400, 389, 379, 369, 360, 351};

//vo2 display data
float vo2[]={20.97, 23.86, 26.70, 29.84, 32.92, 36.28, 39.58, 43.12, 46.57, 49.94, 53.52, 57.00, 60.66, 64.20, 67.62, 71.17, 74.59, 78.09, 81.45, 84.85, 88.07, 91.12, 94.16, 96.99, 99.78};

const byte elements =25;//the number of elements in each of the arrays

//variable for vo2 data array counter
int k=0;

//variable for levels loop
int i=1;

//Start beep
tone(buzzer_pin,4000,100);//pin,frequency,duration in milliseconds

//levels loop
while (i<=elements)
{
  
//write levels (i) 
lcd.setCursor(0,1);
lcd.print(i); 


//variable for shuttles loop
int j=1;

//shuttles loop
while (j<=shuttles[i-1])
{

//write shuttles (j)
lcd.setCursor(5,1);
lcd.print(j);
lcd.print(" "); 

//do vo2 data write
if (i==k+1 && j==shuttles[k] && k<elements)
{
  lcd.setCursor(10,1);
  lcd.print(vo2[k]);
  k++;  
  }

//sound tone
tone(buzzer_pin,4000,100);//doesn't seem to affect timing of shuttle

//wait for timer to finish - the delay is shortened in test_me mode
#ifdef test_me
delay(shuttle_times[i]);
#else
delay((shuttle_times[i]*10));
#endif
 

//increment shuttle counter
j++;

}

//increment level counter
i++;

  }


//sound end beep
tone(buzzer_pin,4000,3000);

while(1){}//finished so just hold here
  
}//end of program

Credits

glennedi
5 projects • 23 followers
Contact

Comments

Please log in or sign up to comment.