Sei sulla pagina 1di 12

Session-Based Stationary Exercise Bike with

Odometer, Speedometer, Calories Burned


Counter, and Smartphone Charging Capability
Goran Y. Sapiandante, Ralph Laurenze N. Sari, Glenn V. Magwili
School of Electrical Electronics and Computer Engineering, Mapua University, Intramuros, Manila, Philippines
gysapiandante@mymail.mapua.edu.ph, rlnsari@mymail.mapua.edu.ph, gvmagwili@mapua.edu.ph

Abstract— Alternative Energy generated in ways that do not


deplete natural resources or harm the environment. Having to
relate it with exercise in terms of biking is very beneficial. In this
paper, we will discuss how we designed a Stationary Bike
Charger with Odometer, Speedometer and Calories Burned
Counter and how it works.

Keywords—Odometer, Speedometer, Calories, Arduino,

I. INTRODUCTION
Pedal power is the transfer of energy from a human source Figure 2.1: Arduino UNO.
using a foot pedal and crank system. This technology is most
used for transportation and has been used to propel bicycles 2.2 Hall Effect Sensor
for over a hundred years. Less commonly, pedal power is used
to power agricultural and hand tools and even to generate Hall Effect Sensors are devices which are activated by an
electricity. Some applications include pedal powered laptops, external magnetic field. We know that a magnetic field has two
pedal powered grinders and pedal powered water wells. Some important characteristics flux density, (B) and polarity (North
third world development projects currently transform used and South Poles). The output signal from a Hall effect sensor
bicycles into pedal powered tools for sustainable development. is the function of magnetic field density around the device.
The articles on this page are about the many wonderful When the magnetic flux density around the sensor exceeds a
applications for pedal power technology. certain pre-set threshold, the sensor detects it and generates an
output voltage called the Hall Voltage
The main objective of this study is to provide a relationship
between alternative energy and physical activity to sustain or Hall Effect Sensors consist basically of a thin piece of
improve health and fitness rectangular p-type semiconductor material such as gallium
arsenide (GaAs), indium antimonide (InSb) or indium arsenide
II. REVIEW OF RELATED LITERATURE
(InAs) passing a continuous current through itself. When the
device is placed within a magnetic field, the magnetic flux
2.1 Arduino Uno lines exert a force on the semiconductor material which
A microcontroller board based on the ATmega328 deflects the
(datasheet). It has 14 digital input/output pins (of which 6 can
be used as PWM outputs), 6 analog inputs, a 16 MHz ceramic
resonator, a USB connection, a power jack, an ICSP header,
and a reset button. It contains everything needed to support the
microcontroller; simply connect it to a computer with a USB
cable or power it with an AC-to-DC adapter or battery to get
started. The Uno differs from all preceding boards in that it
does not use the FTDI USB-to-serial driver chip. Instead, it
features the Atmega16U2 (Atmega8U2 up to version R2)
programmed as a USB-to-serial converter.

Figure 2.2 Hall Effect Sensor


2.3 Voltage Detection Sensor Module

Voltage Detection Sensor Module 25V module is based


on the principle of resistive voltage divider design, it can make
the red terminal connector input voltage to 5 times smaller.
Arduino analog input voltages up to 5 v. The voltage detection
module input voltage not greater than 5Vx5=25V (if using
3.3V systems, input voltage not greater than 3.3Vx5=16.5V).
Figure 2.5 12V DC Motor

2.6 DC to DC Buck Converter

A buck converter (step-down converter) is a DC-to-


DC power converter which steps down voltage (while
stepping up current) from its input (supply) to its output
(load). It is a class of switched-mode power supply (SMPS)
typically containing at least two semiconductors (a diode and
a transistor, although modern buck converters frequently
replace the diode with a second transistor used for
Figure 2.3 Voltage Detection Sensor Module synchronous rectification) and at least one energy storage
element, a capacitor, inductor, or the two in combination. To
2.4 20x4 LCD Display with I2C reduce voltage ripple, filters made of capacitors (sometimes in
combination with inductors) are normally added to such a
This is a 20x4 Arduino compatible LCD display module converter's output (load-side filter) and input (supply-side
with high speed I2C interface. It is able to display 20x4 filter)
characters on two lines, white characters on blue background.

Generally, LCD display will run out of Arduino pin


resource. It needs 6 digital pins and 2 power pin for a LCD
display. If you want to build a robot project, it will be a
problem with Arduino UNO and LCD display.

Figure 2.6 DC to DC Buck Converter USB Output

III. METHODOLOGY

This chapter discusses the abstract content of the


design. It includes the conceptual framework of the
design, proposed design, the result during the data
Figure 2.4 20x4” LCD Display gathering for verification and accuracy analysis to
conform to the design objectives.3.1 Conceptual
2.5 12V DC Motor Framework of the System

A DC motor is any of a class of rotary electrical machines 3.1 Conceptual Framework of the System
that converts direct current electrical energy into mechanical
energy. The most common types rely on the forces produced
by magnetic fields. Nearly all types of DC motors have some
internal mechanism, either electromechanical or electronic, to
periodically change the direction of current in part of the
motor.
Figure 3.1 Conceptual Framework of the System

The system consists of a microcontroller, DC


motor, hall effect sensor module, buck converter, and
voltmeter sensor. Mechanical energy that is being done by
pedaling the bicycle which is connected to the shaft of a
12V DC Motor thus producing an electrical energy. After
which, the energy that is being attained from the motor
will be then fed to our Arduino by using the voltage sensor b. Smartphone Charging
module, as well as to the 5V DC-DC Buck Converter To charge a smartphone, we needed to be able to
which will constantly give us an output of 5V via USB achieve a steady 5V output via USB, since this is the
which is available for charging. requirement to charge a smartphone as well as it is the
maximum voltage that a standard USB can output.
3.2 Process Flow Chart
To achieve this, we used a 5V dc-dc buck converter
connected to our dc generator so that it can continuously
provide us with an output of 5V which can then be used
to charge the smartphone. To know the current that is
being transferred so that we can know that the phone will
charge, we used an application from the App Store to
measure the current.

c. Distance Travelled Computation


To compute for the distance travelled, we first need
to know how many revolutions our wheel had. To know
how many revolutions, the Hall Sensor is used so that
every time the wheel has 1 revolution, the sensor will
trigger in which it will integrate a revolution counter
inside the sketch.

Now, to compute for the distance, the system will


multiply the number of times the wheel revolved to the
circumference of the wheel which is 2.1206m and
dividing it by 1000 to get the value in kilometers.

(𝑟𝑒𝑣𝐶𝑜𝑢𝑛𝑡 ∗ 𝐶)
𝑐𝑢𝑟𝑟𝑒𝑛𝑡𝐷𝑖𝑠𝑡𝑎𝑛𝑐𝑒 =
1000

In which C is the circumference of the wheel of the


bike.

d. Speed Computation
Figure 3.2 Process Flow Chart To compute for the speed, we first need to know the
time that it takes to complete a revolution. This is also
done by the hall sensor and the Arduino code which
3.3 Working Principle records the current time as well as the last time the sensor
has been triggered. After having this, the system will now
a. Circuit Diagram compute the current speed using the formula:
Our circuit diagram consists of LCD as well as
voltage sensor and push buttons. The push buttons are 360000 𝐶
𝑆𝑝𝑒𝑒𝑑 = ( )∗( )
labeled as PAUSE/RESUME and toggle DISPLAY 𝑟𝑒𝑣𝑇𝑖𝑚𝑒 1000
MODE. Pressing these buttons will lead to an action
which will change what is currently being displayed in revTime = time it takes for 1 revolution
the LCD. C = circumference of the wheel

The system will also divide all the values by a factor


of 1000 to get the speed in kilometers per hour.

e. Ave. Speed Computation

For the average speed,

(𝑐𝑢𝑟𝑟𝑒𝑛𝑡𝐷𝑖𝑠𝑡𝑎𝑛𝑐𝑒)
𝐴𝑣𝑒. 𝑆𝑝𝑒𝑒𝑑 = (3600000)
𝑐𝑢𝑟𝑟𝑒𝑛𝑡𝑇𝑖𝑚𝑒

Figure 3.3 Circuit Diagram of LCD and Sensors


f. Calories Burned (Estimate) 3.5 Testing and Calibration
METS, or metabolic equivalents, are a highly
effective way for personal trainers to measure their a. Time needed to obtain 1% of charge
clients’ progress. Treadmills and other gym equipment
will often display METS and they are a useful method of Time
Type of Avg. Speed Voltage Current
working out how many calories are burned during a Elapsed
workout. Pedaling reading thru reading Reading
the sensor thru the
The basic formula for calculating calories burned is sensor
defined by the following: Light 6 kph 6V 400 mA ~5mins and
30secs
Total Calories Burned =duration(in
minutes)*(MET*3.5*weight in kg)/200 Moderate 14 kph 8V 800mA ~2mins and
10secs
Since cycling has a MET value of 10, we can use this
formula to estimate the calories burned during the
Intense 23 kph 11V 1200mA ~1min
use of our system. Substituting the formulas, we used
65 kilograms for average weight here in the
Philippines. The formula that we used for calculating
the total calories burned will be

Total Calories Burned = ((currentDuration /


1000) * (10 * 3.5 * 65)) / (200)(60)

3.4 System Design

3.5 Materials Used

Materials Quantity Price

12V DC Motor 1 600

Arduino Uno 1 400


Hall Effect Sensor 1 60

Voltmeter Sensor 1 60 Figure 3.4 Sample Charging thru the smartphone app

5V DC to DC 1 60 As we can see in the smartphone application, we


Converter have charged 1% for 1 minute and 54 seconds of biking. This
means that the charger is functional and is strong enough or
20x4 LCD 1 250
giving enough current so that it will surpass the discharge
3D Printed case 1 1000 current of the smartphone which is 400mA. The maximum
current that we attained during this biking is 1217 mA for
Miscellaneous 400 intense biking while 400mA for light biking.
TOTAL P 2830
b. For Moderate Pedaling (>10kph)
Time Avg. Speed Voltage Ampere Percentage Kcal
Marked reading reading Reading Charged Burned

1 14 kph 8V 1190 mA 0% 11.6


minute kcal

3 14 kph 7V 1155mA 1% 34.23


minutes kcal

5 15 kph 8V 1043mA 2% 57.44


minutes kcal
7 14 kph 7V 1119mA 3% 79.74
minutes kcal

Figure 3.5 Screenshot of the charge monitoring app


3.6 Total Sessions 3.7 Sample pictures of the prototype

The prototype also comes with a maximum of 99


session-based counter in which it will store all your previous
exercise data (provided that you don’t turn off the system)
so that you can compare your results especially if you need
to do other things and you want to keep track of your
exercise routine.

Below is an example of 2 sessions recorded in the


microcontroller as well as the totals for all the values of the
previous sessions.

Figure 3.6 Sample Session Counter


IV. INTERPRETATION OF RESULTS VI. APPENDICES

An in-depth interpretation of our series of tests and Program Code


calibrations to understand what the test result may signify
which may help us develop relationship between pedal power #include <LiquidCrystal_I2C.h>
and based on Table A, light pedaling will only give us 6V and
400mA of current which is a low current for charging. We can LiquidCrystal_I2C lcd(0x27, 20, 4);
also see that intense pedaling will produce the highest voltage
which is 11V and a current of 1.2A, which is capable of // Circumference of bicycle wheel expressed in meters
charging a smartphone or a device. This means that as we float bicycleWheelCircumference = 2.1206;
increase the pedaling power, the voltage and current will
increase as well. const int pauseButton = 2;
boolean lastPauseButton = LOW;
As we further analyze our test and results in table B, we can boolean currentPauseButton = LOW;
see that as we pedal longer, we can charge the smartphone
more. As we can see from the provided graphs, the average const int displayModeButton = 3;
current that can be attained when doing moderate pedaling boolean lastDisplayModeButton = LOW;
(which is >10kph) plays around 7-8V and 1A which is boolean currentDisplayModeButton = LOW;
acceptable and is also capable of charging the smartphone
same as the wall charger. Furthermore, the system will help us const int revolutionButton = 4;
exercise because we can easily track our calories burned right boolean lastRevolutionButton = LOW;
after we are done pedaling or exercising. Although it is only boolean currentRevolutionButton = LOW;
an estimate, it can greatly help in improving your exercise
routine as well as your diet or gym routine if for example, you boolean startShown = HIGH;
don’t have enough time to go to the gym.
boolean paused = LOW;
boolean pausedShown = LOW;
V. CONCLUSION AND RECOMMENDATION unsigned long pausedStartTime = 0;

With the series of tests and calibrations that we performed to boolean wheelTurningShown = LOW;
record the data; we recorded a trend of data which gives us the unsigned long wheelTurningStartTime = 0;
information to With the series of tests and calibrations that we
performed to record the data; we can safely assume that the boolean cycleSafelyShown = LOW;
use of pedal-powered generator to charge your smartphone can unsigned long cycleSafelyStartTime = 0;
be easily executed with the right materials and the right codes.
Although the only materials that you will need for the charging unsigned long lastRevolutionStartTime = 0;
side are just the bike, dc motor, and converter, we think that unsigned long revolutionTime = 0;
the information provided is not enough so we tried to innovate
this basic system more by adding speedometers, odometers, int currentDisplayMode = 0;
voltage sensors, as well as calculating your calories burned for int showsession = 0;
the duration since cycling is one way of exercising. This means int sessionCurrentlyShown = 100;
that the project can be beneficial for those who are always int currentsession = 0;
working out and wants to charge their phone as they work out
since sometimes, the smartphone is used for listening to music float currentDistance;
while working out. unsigned long currentDuration;
int currentMaximumKPH;
We recommend using an actual gym stationary bike exercise int currentAverageKPH;
to feel the resistance when pedaling since in our system, we int currentKPH;
didn’t add resistance to the wheels. Also, we recommend using float currentCalories;
a more accurate or high-frequency hall effect sensor since in
our system, we had to compensate for the slowness of our hall
sensor which is A3144 Hall Sensor by adding more magnets float arrayDistance[100];
on the wheels. Also, having a bigger motor with more unsigned long arrayDuration[100];
windings will help in achieving more current easily without int arrayMaximumKPH[100];
having to put in too much effort pedaling. int arrayAverageKPH[100];
float arrayCalories[50];

unsigned long revolutionCount = 0;


unsigned long currentTime = 0;
unsigned long sessionStartTime = 0;

float km = 0.00;
float kph = 0.00;
int intHours;
int intMinutes; // Compute millis it took for this latest revolution
int intSeconds; if (lastRevolutionStartTime > 0) {

unsigned long milliSecondsInSecond = 1000; revolutionTime = currentTime -


unsigned long milliSecondsInMinute = 60000; lastRevolutionStartTime;
unsigned long milliSecondsInHour = 3600000;
// Compute current speed in kilometers per hour based on
void setup() time it took to complete last wheel revolution
{ kph = (3600000 / revolutionTime) *
bicycleWheelCircumference / 1000;
// Configure digital input pins for push buttons and Hall currentKPH = kph;
sensor
pinMode (revolutionButton, INPUT); // If current speed is new maximum speed for this session
pinMode (pauseButton, INPUT); then store it
pinMode (displayModeButton, INPUT); if (currentMaximumKPH < currentKPH) {
currentMaximumKPH = currentKPH;
// Initialize maximum KPH in totals as this may not be }
calculated if no maximum was computed for sessions }
// and there may be random data in memory location lastRevolutionStartTime = currentTime;
arrayMaximumKPH[0] = 0; }
}
// Initialize LCD screen & show "PRESS BUTTON TO lastRevolutionButton = currentRevolutionButton;
START"
lcd.begin(20, 4); // Read PAUSE/RESUME push button
lcd.init(); currentPauseButton = debounce(lastPauseButton,
lcd.backlight(); pauseButton);
lcd.setCursor(4, 0); if (lastPauseButton == LOW && currentPauseButton ==
lcd.print("PRESS BUTTON"); HIGH) {
lcd.setCursor(6, 1);
lcd.print("TO START"); // If "PRESS BUTTON TO START" message has been
lcd.setCursor(0, 2); showing then we now need to start 1st session/period
lcd.print("made by"); if (startShown) {
lcd.setCursor(0, 3);
lcd.print("sapiandante &"); startShown = LOW;
lcd.setCursor(16, 3);
lcd.print("sari"); // Show "CYCLE SAFELY!" message
showCycleSafely();
} cycleSafelyShown = HIGH;
cycleSafelyStartTime = currentTime;
void loop() {
currentsession = 1;
// Get current millis resetsessionVariables();
currentTime = millis(); currentDisplayMode = 1;

// Read revolution Hall sensor }


currentRevolutionButton = debounce(lastRevolutionButton, else {
revolutionButton);
if (lastRevolutionButton == HIGH && // Otherwise if pause is active then we need to take it out
currentRevolutionButton == LOW) { of pause and start new session/period
if (paused) {
// If initial "PRESS BUTTON TO START" is not displayed
and not currently paused... paused = LOW;
if (!startShown && !paused) {
// Show "CYCLE SAFELY!" message
// Increase wheel revolution count showCycleSafely();
revolutionCount++; cycleSafelyShown = HIGH;
cycleSafelyStartTime = currentTime;
// Display "+" to show that one revolution was recorded
lcd.setCursor(0, 0); // Increment session counter
lcd.print("+"); currentsession++;
wheelTurningShown = HIGH;
wheelTurningStartTime = currentTime;
// If we are starting a 100th session/period then we should // In case "SESSION START!" has been showing, turn it
write data into 99th array position (overwriting this session) off now since we want to show "PAUSED!" message
// as we can only keep track of 99 sessions/periods in total // and we don't want it to be removed when "CYCLE
if (currentsession > 99) { SAFELY!" times out
currentsession = 99; cycleSafelyShown = LOW;
// Pretend session 100 (out-of-bounds value) is currently
shown (even though 99 is currently shown) // Show "PAUSED!" message
// to force display of new data for session 99 showPaused();
sessionCurrentlyShown = 100; pausedShown = HIGH;
} pausedStartTime = currentTime;

resetsessionVariables(); // We will need to show data for session which was just
currentDisplayMode = 1; finished
} showsession = currentsession;
currentDisplayMode = 3;
// Otherwise pause is not currently active so we need to
save session/period data and activate pause // Set out-of-bounds value to sessionCurrentlyShown to
else { force session data to be shown
sessionCurrentlyShown = 100;
paused = HIGH; }
}
// Calculate duration }
currentDuration = currentTime - sessionStartTime; lastPauseButton = currentPauseButton;

// If session duration is less than 2 seconds (which means // Read DISPLAY MODE push button
user pressed the pause button while "CYCLE SAFELY!" currentDisplayModeButton =
message debounce(lastDisplayModeButton, displayModeButton);
// was shown) then do not store the session/ignore it if (lastDisplayModeButton == LOW &&
if (currentDuration < 2000) { currentDisplayModeButton == HIGH) {
currentsession--;
} // If "PRESS BUTTON TO START" message has been
// Otherwise store the session showing then we now need to start 1st session/period
else { if (startShown) {

// Compute distance and average and calories startShown = LOW;


if (revolutionCount > 0) {
currentDistance = revolutionCount * // Show "SESSION START" message
bicycleWheelCircumference / 1000; showCycleSafely();
currentAverageKPH = currentDistance * 3600000 / cycleSafelyShown = HIGH;
currentDuration; cycleSafelyStartTime = currentTime;
}
currentsession = 1;
// Store data for session/period into array resetsessionVariables();
arrayDistance[currentsession] = currentDistance; currentDisplayMode = 1;
arrayDuration[currentsession] = currentDuration;
arrayAverageKPH[currentsession] = }
currentAverageKPH; else {
arrayMaximumKPH[currentsession] =
currentMaximumKPH; // Otherwise if "CYCLE SAFELY!" message is not shown
arrayCalories[currentsession] = currentCalories; nor is "PAUSED!" message shown...
if (!cycleSafelyShown && !pausedShown) {
// Update totals for all sessions/periods
arrayDistance[0] = arrayDistance[0] + currentDistance; // If not currently paused (so session is ongoing)...
arrayDuration[0] = arrayDuration[0] + currentDuration; if (!paused) {
arrayCalories[0] = arrayCalories[0] + currentCalories;
arrayAverageKPH[0] = arrayDistance[0] * 3600000 / // Flip between the two different display modes
arrayDuration[0]; available
if (currentMaximumKPH > arrayMaximumKPH[0]) { if (currentDisplayMode == 1) {
arrayMaximumKPH[0] = currentMaximumKPH; currentDisplayMode = 2;
} }
} else {
currentDisplayMode = 1;
}
currentDistance = revolutionCount *
// Clear display and show appropriate labels bicycleWheelCircumference / 1000;
showLabels(currentDisplayMode);
} // Compute average kilometers per hour since start of
session
// Otherwise we are in paused mode so cycle through currentAverageKPH = currentDistance * 3600000 /
session data available, including totals page currentDuration;
else {
currentDisplayMode = 3; //Compute Calories
showsession++; currentCalories = ((currentDuration / 1000) * (10 * 3.5 *
if (showsession > currentsession) { 65)) / 12000;
showsession = 0; // Show totals }
} }
} //Voltage
} int volt = analogRead(A0);
} double voltage = map(volt, 0 , 1023, 0 , 2500);
} voltage /= 100;
lastDisplayModeButton = currentDisplayModeButton; // If no messages are currently showing then update data on
display
// If wheel revolution indicator has been showing, take if off if (!startShown && !cycleSafelyShown && !pausedShown)
if it has been 250 millis or more {
if (wheelTurningShown && !startShown && !paused &&
(currentTime >= (wheelTurningStartTime + 250))) { if (currentDisplayMode < 3) {
wheelTurningShown = LOW; lcd.setCursor(1, 0);
lcd.setCursor(0, 0); lcd.print("DIST");
lcd.print(" "); lcd.setCursor(1, 1);
} lcd.print(currentDistance);
lcd.print(" km");
// If wheel revolution indicator has been showing, take if off
if it has been 250 millis or more lcd.setCursor(12, 0);
if (!startShown && !paused && (currentTime >= lcd.print("SPEED");
(lastRevolutionStartTime + 10000)) && currentKPH > 0) {
currentKPH = 0; lcd.setCursor(12, 3);
} lcd.print(voltage);
lcd.print("V");
// If "Cycle Safely!" has been showing, take it off if it has
been 2 seconds or more lcd.setCursor(16, 1);
if (cycleSafelyShown && (currentTime >= if (currentKPH < 10) {
(cycleSafelyStartTime + 2000))) { lcd.print(" ");
cycleSafelyShown = LOW; }
showLabels(currentDisplayMode); lcd.print(currentKPH);
}
computeHMS(currentDuration);
// If "Paused!" has been showing, take it off if it has been 2 lcd.setCursor(1, 2);
seconds or more lcd.print("TIME");
if (pausedShown && (currentTime >= (pausedStartTime + lcd.setCursor(1, 3);
2000))) { if (intHours < 10) {
pausedShown = LOW; lcd.print("0");
showLabels(currentDisplayMode); }
} lcd.print(intHours);

// If "PUSH BUTTON TO START" is not showing and not lcd.print(":");


currently paused... if (intMinutes < 10) {
if (!startShown && !paused) { lcd.print("0");
}
// Compute milliseconds since start of session lcd.print(intMinutes);
currentDuration = currentTime - sessionStartTime;
lcd.print(":");
// Compute distance and average kilometers per hour if if (intSeconds < 10) {
bicycle has moved lcd.print("0");
if (revolutionCount > 0) { }
// Compute kilometers traveled lcd.print(intSeconds);
// Circumference of wheel is in meters
lcd.setCursor(12, 2); if (arrayMaximumKPH[showsession] < 10) {
lcd.print("A"); lcd.print(" ");
}
if (currentDisplayMode == 1) { lcd.setCursor(10, 2);
lcd.setCursor(12, 2); if (arrayDistance[showsession] == 0) {
lcd.print("A"); lcd.print("0.00");
lcd.setCursor(16, 2); }
if (currentAverageKPH < 10) { else
lcd.print(" "); lcd.print(arrayCalories[showsession]);
}
lcd.print(currentAverageKPH); lcd.setCursor(15, 2);
} lcd.print(" kcal");
else { lcd.setCursor(10, 1);
lcd.setCursor(12, 2); lcd.print(arrayDistance[showsession]);
lcd.print("M"); lcd.setCursor(15, 1);
lcd.setCursor(16, 2); lcd.print(" km");
if (currentMaximumKPH < 10) {
lcd.print(" ");
} computeHMS(arrayDuration[showsession]);
lcd.print(currentMaximumKPH); lcd.setCursor(10, 3);
} if (intHours < 10) {
} lcd.print("0");
}
// Otherwise device is paused so show historical session lcd.print(intHours);
information
else { lcd.print(":");

// Update display only if we need to show data for different if (intMinutes < 10) {
session to that currently shown lcd.print("0");
// this way display is not constantly cleared and refreshed }
with same data which would lcd.print(intMinutes);
// cause display to flicker and is not needed anyway as data
is not changing lcd.print(":");
if (sessionCurrentlyShown != showsession) {
if (intSeconds < 10) {
sessionCurrentlyShown = showsession; lcd.print("0");
}
lcd.clear(); lcd.print(intSeconds);
lcd.setCursor(10, 0); }
lcd.print("SUMMARY"); }
}
lcd.setCursor(0, 0); }
if (showsession == 0) {
lcd.print("TOTAL"); // Compute hours, minutes and seconds for given duration
} expressed in milliseconds
else { void computeHMS(unsigned long duration) {
lcd.print("SESSION ");
lcd.print(showsession); float floatHours;
} float floatMinutes;
lcd.setCursor(0, 1); float floatSeconds;
lcd.print("SPEED");
lcd.setCursor(0, 2); intHours = 0;
lcd.print("Avg"); intMinutes = 0;
lcd.setCursor(4, 2); intSeconds = 0;
lcd.print(arrayAverageKPH[showsession]);
if (arrayAverageKPH[showsession] < 10) { if (duration >= 1000) {
lcd.print(" "); floatSeconds = duration / milliSecondsInSecond % 60;
} intSeconds = floatSeconds;

lcd.setCursor(0, 3); floatMinutes = duration / milliSecondsInMinute % 60;


lcd.print("Max"); intMinutes = floatMinutes;
lcd.setCursor(4, 3);
lcd.print(arrayMaximumKPH[showsession]); floatHours = duration / milliSecondsInHour % 24;
intHours = floatHours; }
}
} // Show appropriate labels for current mode
void showLabels(int currentDisplayMode) {
// Reset all variables used for calculating current/ongoing
session lcd.clear();
void resetsessionVariables() { switch (currentDisplayMode) {
revolutionCount = 0; case 1:
lcd.setCursor(12, 1);
sessionStartTime = currentTime; lcd.print("Cur");
lcd.setCursor(12, 2);
currentDistance = 0; lcd.print("Avg");
currentDuration = 0; break;
currentMaximumKPH = 0; case 2:
currentAverageKPH = 0; lcd.setCursor(12, 1);
currentCalories = 0; lcd.print("Cur");
} lcd.setCursor(12, 2);
lcd.print("Max");
// Show "SESSION START!" break;
void showCycleSafely() { }
lcd.init(); }
lcd.backlight();
lcd.clear(); //A debouncing function that can be used for any button
lcd.setCursor(6, 1); boolean debounce(boolean last, int pin)
lcd.print("SESSION"); {
lcd.setCursor(7, 2); boolean current = digitalRead(pin);
lcd.print("START!"); if (last != current) {
} delay(5);
current = digitalRead(pin);
// Show "SESSION STOP" }
void showPaused() { return current;
lcd.init(); }
lcd.backlight();
lcd.clear();
lcd.setCursor(3, 1);
lcd.print("SESSION STOP");
lcd.setCursor(2, 2);
lcd.print("SHOWING SUMMARY");
delay(2000);

VII. USER’S MANUAL REFERENCES:

1. Ensure that there is a 9V Battery connected [1] https://www.quora.com/In-the-Philippines-what-are-


inside the box or power up the Arduino with the-average-male-and-female-heights-in-each-
adapter of your choice. archipelago-Luzon-Visayas-and-Mindanao.
2. Turn on the system using the toggle switch
[2] https://www.cmsfitnesscourses.co.uk/blog/using-mets-
located at the back
to-calculate-calories-burned/.
3. An introductory message will be shown
4. Press START/STOP button [3] https://www.verywellfit.com/how-many-calories-you-
5. Once pressed, start cycling and pedal with the burn-during-exercise-4111064.
intensity of your choice [4] http://mathcentral.uregina.ca/QQ/database/QQ.09.08/h/
6. Press the DISPLAY/BROWSE button to dennis2.html.
switch the display between your AVERAGE [5] https://learn.sparkfun.com/tutorials/what-is-an-
SPEED or MAXIMUM SPEED arduino/all.
7. Once done pedaling, press the START/STOP
button again.
8. Session summary will be shown
9. Press the START/STOP button to start another
session or DISPLAY/BROWSE button to
toggle between your sessions and totals.

Potrebbero piacerti anche