Our final project for the 60-223 Physical Computing is to create an assistive device for our client Jill, who has cerebral palsy and uses a wheelchair. We met Jill through CLASS, an organization that provides support and services for people with disabilities. In order to ensure the Exercise Counter was personalized for Jill, we conducted several interviews to better understand her needs and created prototypes to answer design questions before creating the final device.
The documentation for the interviews can be found here: https://sites.google.com/andrew.cmu.edu/60-223-f24/final-project-assistive-device-for-a-person-with-disability/interview-documentation/team-almonds
The Exercise Counter aims to give Jill a way to keep track of her reps of exercises without having to rely on fitness bands, which typically rely on pedometer data in order to give health feedback. As a wheelchair user, Jill would not utilize a pedometer and thus, wanted a more specific device for her arm exercises. The Exercise Counter consists of a wristband and a main control panel which can be attached to the arm of her wheelchair. Once the wristband is worn, Jill selects which exercise she is doing, completes her exercise set, and then presses the finish button, where the device will report through a speaker how many reps were completed.
Narrative Sketch
Jill heads to the gym after work, excited for another day of hitting the weights. She pulls the Exercise Counter out of her gym bag where she attaches the main control panel to the wheelchair using the adjustable straps to clip on to her wheelchair arm. Her trainer helps her put on the band on her forearm, securely but comfortably strapping the velcro.
Jill then begins her workout, warming up with bicep curls. She presses the button labelled "BICEP CURLS", and begins exercising. The exertion of so many reps makes it hard to keep track of how many she's done so far, but after reaching her limit, she presses the finish button and the box announces "17 Reps". Satisfied, she moves on to the next exercise knowing that she can put her full focus on exercising and still receive accurate feedback.
3/4ths view of both components of the exercise counter, showing the buttons of the main control panel and the wristband.
Closeup of the top control panel where our client can select which exercise she is doing and when she finishes it. The panel is sloped so that Jill is more easily able to see the lights and reach the buttons.
View of the side with straps that attaches to the wheelchair arm. The straps are two adjustable side squeeze buckles and were measured for Jill's wheelchair arm size.
Closeup of the outer side of the wristband that contains a pocket for the accelerometer, or data reading device. The band consist of two velcro straps that slide into loops that hold the strap in place while the user adjusts the tightness. The outer material is a sweat wicking athletic material that is blue for Jill's favorite color. The trapezoidal shape indicates which side should be attached to the wrist and which should be around the forearm.
View of the other side of the wristband. This side has a softer sweat wicking material that makes contact with the skin. The velcro straps on this side are the softer parts in order to ensure comfort for the wearer.
Closeup of the stitching for the velcro and loops.
Demonstration of how the wristband would fit on the user. In an interview Jill told us that self attachment was not necessary because she uses a personal trainer who could help her with putting on the wristband. However, we still wanted to make it as comfortable and easy to put on as possible.
View of the underside of the control panel which opens to the battery slots. This is so Jill can continuously use the device and replace batteries herself.
In this video, we demonstrate how the device is used in lateral raise mode.
Starting by putting on the wristband, the user then selects the exercise (lateral raise), completes a desired amount of reps (four) and then presses the finish button, prompting the device to say the number of reps completed (four).
These two videos demonstrate the other two exercises, bicep curls and pulldowns, that our client requested to be available. Once the exercise is selected, an indicator light turns on, and when the finish button is pressed, the lights turn off and the speaker plays an mp3 for the amount of reps, which ranges from 1 - 25. We chose these numbers as Jill normally works in the 1-15 range, but we wanted to account for times she wanted to challenge herself. For each video, the counter accurately announces how many reps were completed with two for both pulldowns and bicep curls.
Our initial vision of the wristband and the box controller. The wristband looks similar to the prototype where a pouch would be used to store the rep measuring devices.
The outer side portion of the wristband that wraps around Jill's arm.
The under side portion of the wristband displaying the stretchy and comfortable material used within the wristband sleeve.
This prototype was designed to help answer the design question: What is the most comfortable and effective way for Jill to put on the wristband?
This prototype had us explore the different materials and feels for the wristband. We wanted to prototype how Jill would put on the wristband and how comfortable it was when wearing it. We didn't want the wristband to be scratchy when worn and it should feel snug when exercising.
Us carefully putting together the prototype and the placement of the electronics on the wristband.
The accelerometer attached to a makeshift wristband with the code in the background. This is demonstrating where the accelerometer will be placed and checking if it counts exercise reps.
Jill using our wristband prototype where we also recorded the flexed and relaxed positions of her exercises. In this video, she is doing bicep curls.
Jill using our wristband prototype where we also recorded the flexed and relaxed positions of her exercises. In this video, she is doing lateral raises.
This prototype was designed to help answer the design question: Can we accurately calculate when Jill completes a rep?
We wanted to test out the functionability of the accelerometer on the wristband and if it could accurately calculate a rep that is similar to Jill's. By relying on exercise data given to us by Jill, we used it to understand when one rep has been made.
The first sketch made of how we would sit the box controller on Jill's wheelchair after a couple of interviews. However, after careful considerations and talking with Jill, we wanted to look for an alternative way to place the box without it getting in her way on the arm rest
A quick cardboard prototype of how the box controller would hang on the side of Jill's wheelchair. We prototyped this after discussing different options on how we would hang the box
A prototype of our box with the preset exercise buttons and slits for the straps
This prototype was designed to help answer the design question: How can we design a box controller that sits well on Jill's wheelchair?
This prototype went through multiple revisions from the sketch to the final product. We wanted to see how the box can fit comfortably on Jill's wheelchair without interfering with her gym experience and not hindering her with more work (such as reaching around to hit the buttons). By testing out a prototype that hangs on the side of her arm rest, we were able to discover that its easy for her to reach down and switch exercises or complete an exercise just by clicking the button.
A picture of the bottom of our soldered components together alongside the battery packed placed within its acrylic holding. Surprisingly, the holes to screw in the battery pack were too far apart so we had to redo the CAD files to ensure that they holes matched the battery pack
The Almonds using the power of friendship to glue together the acrylic housing for the box controller. It was quite the joint effort as well had someone glueing the pieces together and two others holding the pieces down for stability
The insides of the box controller being politely shoved into the acryllic housing (it all fit comfortably!)
The Prototyping Process
From the prototyping process, we were able to confirm that we could answer all of the questions with our theorized solutions. For example, the wristband prototype that aimed to be snug on Jill's arm was easy to put on and felt well fit to not just Jill but anyone who tried the wristband on. To continue, we found that the accelerator worked when counting the reps as we were able to tweak the code such that being in a certain rangle of an angle correlated with a rep being done by the accelerator. We also added a delay after a rep is counted such that being in the range in quick succession does not imply multiple reps beings made by the user. Finally, our box controller prototype demonstrated that we needed to be creative with our solution. The hanging box was the first step but making it slanted such that it can be clicked on with comfortability was a wise decision we made based on our discoveries with Jill.
From the first critiques, we decided to integrate several of those changes into our team's final design. First, we wanted to find the best way to display exercise rep information and we received questions on how we would go about this. We thought of using an LCD screen or some sort of screen to show the number of reps. However, we were told by Jill that she would rather hear the reps rather than look at a screen while exercising. Thus, we decided to display the exercise rep information via playing audio of the total number of reps. Jill gave us valuable feedback in that she wanted to use two wristbands rather than one as she may do different reps on both arms. But due to technical complications, we were unfortunately unable to do this and created only one wristband. Finally, we received critique on how we could make this project reliable and long lasting. Since this is a portable item that will be multiple times a week in a gym, we gave both the wristband and the box controller replaceable battery packs and ensured durability with the materials.
We received feedback about how we counted reps and whether we should only give the total reps or state the individual reps as well. We were given points where maybe the client would want to know whether or not they completed a rep and by hearing the rep number count up, it would not only give them information on completing the rep but also encourage them to keep going. In the end, we ignored this feedback as Jill told us that she would prefer to only hear the total. Both her and our team agreed that hearing the reps count aloud in the gym may also be a public distraction.
During our prototyping process, a lot of the surprises that were faced were hardware issues. There were a lot of ideas that we could have implemented but were unable to get to because of hardware malfunctions. For example, we had working wireless transceivers where the wristband was able to communicate with the box controller just fine and the wristband was wireless. We wanted to have the wristband be wireless so that there was less potential restrictions of movement while she exercises. However, after Thanksgiving break, all wireless transceivers stopped working for us and we had to quickly pivot to a wired wristband.
Us testing the final prototype where the wristband is connected to the box controller via wires. The wires are wrapped in shrink to ensure durability. Clicking on the buttons would light up a button signifying that the exercise was chosen. Clicking on the 'Final' button (rightmost button in the picture) will blink a light and then state the total number of reps from that exercise
One of the first meetings we had with Jill where we were showing her several ideas that could help bring her joy in her everyday life.
The first sketch Saylor made of the wristband and box controller.
The process was initially quite difficult because it seemed that our client, Jill, had no 'issues' or 'problems' that needed any fixing. It took roughly two interviews until we were able to laser focus onto a potential area in her life that could use physical computing. We found that when she goes to the gym or does exercises, she occasionally loses track of the number of reps she is counting and needs a reminder of the total of reps she did after an exercise.
With this, we pivoted from our first ideas of creating platforms or trays-- which were more mechanical in nature-- to a wireless wristband that would help track her reps and then display them on a box.
We wanted to make a product that:
Found the best way to display exercise rep information
Have two wristbands that connected to the displaying device
Was comfortable to wear
Ensured longevity and reliability of the device to best suit Jill's needs
When Jill visited us in the Physical Computing Lab, we took down her flexed and relaxed position. This spreadsheet contains those positions of the accelerometer and also the calculated angle values from the Cartesian to Polar equation.
The components of the box controller and wristband slowly growing. We tested first with breadboards before soldering.
The components of the box controller after soldering them together, labrling the buttons, and slowly adding them into their acrylic housing.
Once we started prototyping, all felt well and good. We did our first prototype critique and felt that we were making great progress. The wireless wristband was collecting data and sending it to the box controller and the wristband fit comfortably on Jill. We continued building out the prototype and it quickly became an amalgamation of wires and electronic components. Despite this, we prevailed on. After adding a new component, we diligently checked if it worked with the already existing components to ensure that nothing broke during our creation. Once verifying this, we then started soldering and believed we were in a great place. By the time we were off to Thanksgiving break, we had a fully soldered wristband that had the accelerometer, wireless transceiver, and a powerboost 500 to power/recharge the wristband, as well as the hardware for the main control panel with working lights and buttons. All that was left was to put it all together in its' final wearable/box forms.
However, as mentioned earlier, when coming back from Thanksgiving break, our wireless transceivers stopped working! We tested out multiple transceivers, desoldered our components, replaced Arduinos, used basic code, checked library documentation, and double checked our wiring-- nothing seemed to get the wireless transceivers to talk to one another.
After spending long hours in the Physical Computing Lab trying to fix this hardware issue, we decided to give up on wireless and switched to a wired solution. Since the wired solution was super last minute, we did not have the chance to measure Jill's arm length to appropriately make the wire connecting the wristband and box controller long enough for her comfortability.
We're all experts at soldering! This is the components of the wireless wristband being soldered together, before we pivoted to a wired wristband.
Saylor and Hannah posing with the heat gun while using a heat shrink tubing tube on the wired connection between the wristband and box controller.
Many lessons were learned the nights leading up to Final Critique as we raced against the clock to implement our pivot. Since pivoting towards a wired device meant less components, we had to redo all of our components and wiring to reflect that. On the bright side, the wired wristband only needed an accelerometer and everything else would be within the box controller. At first, the wristband had a micro arduino, accelerometer, wireless transceiver, and rechargable battery inside of it. Making it just an accelerometer made integrating the accelerometer within the wristband easier. With this, the code we had to write was simplified from having two files to just one. We were able to consolidate all of our code into one file, which was held in the box controller.
Before, we had our wristband code calculating just the angles and sending the angles to the box controller for determining whether that angle counted for an exercise rep for that specific exercise setting. Due to the consolidation of components, we just did all of the computing together in the box controller as the wristband only had the accelerometer to deliver x,y, and z values.
When it came to writing the code for the acceleromter. We went through different iterations of how we could best take down accurate reps. With many discussions between the team and our professor, Zach, we were able to use the cartesian to polar equation for calculating angles such that the accelerometer did not have to heavily rely on position. Rather, we can pick the direction in which the accelerometer would face and it would stay consistent for the entire time it is used.
A week and a bit before final critique, with Jill's data inputted into the accelerometer, we tested out the flexed angle position with the incorporated delay and boolean for detecting whether or not the accelerometer is in the range of the flexed angle position.
The night before final critique, the Almonds tested out the lateral raises and went through a successful run through. You can tell it was successful because they looked relieved at the end. The box controller did in fact say the right number of reps after hitting the 'finish' button!
We also ran into some trouble with coding the accelerometer and having it count the amount of reps correctly even after having the angles being calculated from cartesian to polar. When we first started coding the wristband, it would count a rep twice: when entering Jill's range of flexed exercise angle and then existing Jill's range of flexed exercise angle. In order to mitigate this issue, we added both a check to see if her arm was within the range using a boolean and also a delay. This delay helped the issue of Jill's wristband counting a rep more than once when flexed. We also believed that Jill would not be furiously moving her arm up and down when exercising so having the delay helped pace her reps.
Based on this schedule, we followed it faithfully until after Thanksgiving break where we had to pivot. This divergence was brought by the hardware malfunctions we were facing and could not figure out for the life of us. Other than that, we were pretty on top of scheduling and dividing up work amongst one another.
From class, we received two critiques that we found valuable:
Alter the product to become similar to a training module. Users don't need to have a personal trainer since the product can help correct the user on their form if not in the correct angle range, it can count down, and it could give encouraging words or phrases during exercising.
If the product is kept wired, the wire should be retractable and can slink inside and outside of the box controller such that it does not limit the movement of the arm.
For these two pieces of critiques, we found them highly valuable. If we had more time to work on the exercise counter, we would have added more cosmetic touches to it; such as the training module. Since Jill sometimes exercises at home, having the training module implemented within the product will help her train without her personal trainer. It would be able to act as her trainer, going at her own pace, at home. In regards to the second piece of advice, it becomes more of a mechanical engineering and design problem. Since the wired connection was so last minute, we did not have the opportunity to explore different ways of testing that function. However, if given the time, we would have looked into the mechanics and how we could design around that problem
We are happy with the way our project came out! Despite the challenges we met and the multiple pivots we had to make, the product came out great. If we had another week, we could have made the project wireless and did more user testing with Jill. But given the time constraints, we have satisfied our own goals. Throughout this project, we learned so much about physical computing and deepened our knowledge on using different components. We learned multiple strategies on researching and debugging these components. Overall, we found that this was a fun and rewarding experience.
Through the process of working on this project, we realized that time is very very precious and hardware malfunctions do not care about that. We found that working with hardware is extremely hard to debug because they usually do not give any feedback on their issues whereas in software, it tells the user exactly where an issue is occuring. Sometimes, we would even occur problems where no one (even the internet!) has no idea what's going on with it (i.e. wireless transceivers that suddenly stop sending information to one another.)
Next time, we would most likely follow the same process. It seemed that we were on schedule but the difficult bugs with hardware severely held us back. If it weren't for the bugs, our product would be more robust. We found ourselves getting hung up on debugging hardware issues and sinking multiple hours into trying to understand why a component wasn't working. But, if we knew that it would have not worked, we would have given up on using wireless transceivers awhile ago and put more of our focus into other aspects of the product.
For our next steps, if we were to continue building upon this product, we would look into the training module aspect mentioned earlier. We received feedback that we should submit this product to several conferences and competitions because it would be a valuable tool for physical therapy if were to include a training module that could help users exercise. Since the exercise counter is specific to Jill, each exercise counter would be personalized to its respective user-- making the experience of exercising by themselves more valuable as they would be exercising in their optimal form without a personal trainer.
We would also want to look into making the wristband wireless from the box controller. Although it was not working previously, we would still want to give it a shot!
How many almonds does it take to glue together a box controller?
Our entire block diagram with the wrist band diagram on the top connecting to the box controller on the bottom
A close up of our block diagram of the wrist bands
A close up of our block diagram of the box controller
Our entire schematic diagram with the wrist band diagram on the top connecting to the box controller on the bottom
/*
Exercise Counter
Saylor Frankel
Hannah Park
Janelle Tecson
This code is for the Exercise Counter. The user first turns on the
box controller and puts on the wristband. Afterwards, they can select
one of three exercises to do. Pressing on one of the buttons lights up
its corresponding LED, signaling which exercise the user is doing. Once
they are done, clicking the Finish button lights up its LED and a speaker
states the total number of reps done by the user.
Code for calculating angles of cartesian to polar is credited to:
john212 on Github
https://gist.github.com/john212/15ad4e677318fe365e7d
pin mapping:
Arduino pin | role | description
___________________________________________________________________
2 input button for bicep exercise detection
3 input button for lats rep exercise detection
4 input button for pull up exercise detection
6 input button for finish detection
11 output LED for pull up exercise confirmation
12 output LED for lats rep exercise confirmation
13 output LED for bicep exercise confirmation
9 output LED for finish confirmation
A0 input Gathering X value from accelerometer
A1 input Gathering Y value from accelerometer
A2 input Gathering Z value from accelerometer
14 input connecting to speaker RX
15 input connecting to speaker TX
Code released to the public domain by the authors, 12/13/2024
Saylor Frankel, srfranke@andrew.cmu.edu
Hannah Park, hannahpa@andrew.cmu.edu
Janelle Tecson, jtecson@andrew.cmu.edu
*/
#include <math.h> //Auduino code library for math operations
#include <Wire.h>
//SPEAKER SETUP
#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"
static const uint8_t PIN_MP3_TX = 14; // Connects to module's RX
static const uint8_t PIN_MP3_RX = 15; // Connects to module's TX
SoftwareSerial softwareSerial(PIN_MP3_RX, PIN_MP3_TX);
DFRobotDFPlayerMini player;
// time for counting exercises
unsigned long lastCountTime = 0; // Stores the last time an angle was counted
const unsigned long debounceInterval = 4000;
//BUTTON SETUP
const int BUTTON1 = 2;
const int BUTTON2 = 3;
const int BUTTON3 = 4;
const int BUTTON6 = 10;
int button_one = 0;
int button_two = 0;
int button_three = 0;
int button_six = 0;
bool B1state = false;
bool B2state = false;
bool B3state = false;
bool B6state = false;
//LED SETUP
const int LED1 = 13;
const int LED2 = 12;
const int LED3 = 11;
bool L1state = false;
bool L2state = false;
bool L3state = false;
const int LED4 = 9;
//COUNT SETUP
int count = 0;
float theta;
int ANGLE_MIN = 0;
int ANGLE_MAX = 0;
bool inRange = false;
bool motionUp = false;
float valX, valY, valZ; //raw analog values for x, y, and z axis readings.
float accX, accY, accZ; //analog readings converted to acceleration, in g's.
float angleX, angleY, angleZ; //angle of inclination with x,y, and z axis.
float absAngleX, absAngleY, absAngleZ; //positive incline angles
void setup() {
Serial.begin(9600);
//INITIALIZING SPEAKER
softwareSerial.begin(9600);
if (player.begin(softwareSerial)) {
Serial.println("OK");
player.volume(30);
} else {
Serial.println("Connecting to DFPlayer Mini failed!");
}
//INITIALIZING BUTTONS
pinMode(BUTTON1, INPUT);
pinMode(BUTTON2, INPUT);
pinMode(BUTTON3, INPUT);
pinMode(BUTTON4, INPUT);
pinMode(BUTTON5, INPUT);
pinMode(BUTTON6, INPUT);
//INITIALIZING LEDS
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
pinMode(LED3, OUTPUT);
pinMode(LED4, OUTPUT);
Wire.begin();
//constrain analog x, y, z readings to actual measured ranges
constrain(valX,260,392);
constrain(valY,259,391);
constrain(valZ,284,418);
}
void loop() {
static unsigned long lastDebounceTime = 0;
static const unsigned long debounceDelay = 50; // 50ms debounce time
button_one = digitalRead(BUTTON1);
button_two = digitalRead(BUTTON2);
button_three = digitalRead(BUTTON3);
button_four = digitalRead(BUTTON4);
button_five = digitalRead(BUTTON5);
button_six = digitalRead(BUTTON6);
//read the accelerometer x, y, and z axis values
valX = analogRead(A0); // read analog input pin A0
valY = analogRead(A1); // read analog input pin A1
valZ = analogRead(A2); // read analog input pin A2
delay(10); // short delay to allow readings to stabilize
//map the analog sensor readings to a g value between -1 g to + 1 g
//to match the values in AN-1057, the z readings were reversed.
accX = mapf(valX,260.0,392.0,+1.0,-1.0); //user defined mapf function
accY = mapf(valY,259.0,391.0,+1.0,-1.0); //user defined mapf function
accZ = mapf(valZ,284.0,418.0,-1.0,+1.0); //user defined mapf function
//calculate the angle of inclination with each axis.
angleX = atan2(accX,(sqrt(pow(accY,2)+pow(accZ,2))))*(180/PI);
angleY = atan2(accY,(sqrt(pow(accX,2)+pow(accZ,2))))*(180/PI);
angleZ = atan2((sqrt(pow(accX,2)+pow(accY,2))),accZ)*(180/PI);
//use fabs() "f"loating point absolute value vs abs()
absAngleX = fabs(angleX);
absAngleY = fabs(angleY);
absAngleZ = fabs(angleZ);
// theta
theta = absAngleY;
if ((millis() - lastDebounceTime) > debounceDelay) {
//CHANGING BUTTON SETTINGS
if (button_one == HIGH) {
B1state = true;
B2state = false;
B3state = false;
B6state = false;
Serial.println("press b1");
lastDebounceTime = millis();
}
if (button_two == HIGH) {
B2state = true;
B1state = false;
B3state = false;
B6state = false;
Serial.println("press b2");
lastDebounceTime = millis();
}
if (button_three == HIGH) {
B3state = true;
B1state = false;
B2state = false;
B6state = false;
Serial.println("press b3");
lastDebounceTime = millis();
}
if (button_six == HIGH) {
B6state = true;
B1state = false;
B2state = false;
B3state = false;
Serial.println("pressed b6");
}
}
// biceps
if (B1state == true) {
// Turn LED1 on
digitalWrite(LED1, HIGH);
digitalWrite(LED2, LOW);
digitalWrite(LED3, LOW);
// Bicep angle range
ANGLE_MIN = 53.07;
ANGLE_MAX = 100.07;
// Determine motion state
if (theta >= ANGLE_MIN && theta <= ANGLE_MAX) {
if (!inRange) {
// Entering the range for the first time
inRange = true;
// Indicate upward motion
motionUp = true;
}
} else {
if (inRange && motionUp) {
// Reset motion direction
motionUp = false;
unsigned long currentTime = millis();
if (currentTime - lastCountTime > debounceInterval) {
count++;
Serial.print("Count: ");
Serial.println(count);
lastCountTime = currentTime;
delay(1000);
}
}
// Reset inRange to allow detection of the next motion cycle
inRange = false;
}
}
// lats
if (B2state == true) {
//turning LED1 on
digitalWrite(LED2, HIGH);
digitalWrite(LED1, LOW);
digitalWrite(LED3, LOW);
//lateralraise angle
ANGLE_MIN = 34.11;
ANGLE_MAX = 100;
// Determine motion state
if (theta >= ANGLE_MIN && theta <= ANGLE_MAX) {
if (!inRange) {
// Entering the range for the first time
inRange = true;
// Indicate upward motion
motionUp = true;
}
} else {
if (inRange && motionUp) {
// Reset motion direction
motionUp = false;
unsigned long currentTime = millis();
if (currentTime - lastCountTime > debounceInterval) {
count++;
Serial.print("Count: ");
Serial.println(count);
lastCountTime = currentTime;
delay(1000);
}
}
// Reset inRange to allow detection of the next motion cycle
inRange = false;
}
}
// pull downs
if (B3state == true) {
//turning LED1 on
digitalWrite(LED3, HIGH);
digitalWrite(LED1, LOW);
digitalWrite(LED2, LOW);
//cable angle
ANGLE_MIN = 6.06;
ANGLE_MAX = 100;
// Determine motion state
if (theta >= ANGLE_MIN && theta <= ANGLE_MAX) {
if (!inRange) {
// Entering the range for the first time
inRange = true;
// Indicate upward motion
motionUp = true;
}
} else {
if (inRange && motionUp) {
// Reset motion direction
motionUp = false;
unsigned long currentTime = millis();
if (currentTime - lastCountTime > debounceInterval) {
count++;
Serial.print("Count: ");
Serial.println(count);
lastCountTime = currentTime;
delay(1000);
}
}
// Reset inRange to allow detection of the next motion cycle
inRange = false;
}
}
if (B6state == true) {
delay(500);
// plays whatever rep, doesnt matter which exercise preset
player.play(count);
// light up LED for final
digitalWrite(LED4, HIGH);
// resets everything
digitalWrite(LED1, LOW);
digitalWrite(LED2, LOW);
digitalWrite(LED3, LOW);
delay(1000);
B6state = false;
Serial.println("audio played");
count = 0;
}
}
/********************************************************************
//function mapf to mimic map function but it uses floating point numbers
*******************************************************************/
float mapf(float x_, float in_min, float in_max, float out_min, float out_max)
{//****start mapf function****
return (x_ - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}//****endof mapf function****