Want to keep tabs on your training with a big display smack in front of the mill? Or are you an exhibitionist who wants everybody to know how damn hard you鈥檙e running? Either way, it only takes a little soldering and electronics judo to create a giant heart rate display. For interval training, it鈥檚 a lot easier to read than a watch.
We grabbed some 5-inch digits from eBay and connected them to our Arduino board and heart rate signal receiver (warning: the following gets a bit techy). Because the segments require a whopping 13 volts, we needed to protect our controller board with transistors. It took about an hour to press 15 transistors, resistors, and various leads into the breadboard, but the chore left us with a Zen calm.
The nice thing about this project is that it works with any Polar heart strap (we鈥檙e thinking you have an old one knocking around in your closet somewhere). And you can use numerals of any size, limited only by your hubris at the gym.
Parts:
$60
$8
$10 each ($30 total)
$50
Transistors $4
Resistors $4
Polar Heart Rate Strap
Total Cost: $150 – $175
Here is the Arduino code. Enjoy.
//Arduino 1.0+ Compatible only
//Arduino 1.0+ Compatible only
//Arduino 1.0+ Compatible only
// Code to retrieve heartrate information from the Polar Heart Rate Monitor Interface via I2C
// Part:听http://www.sparkfun.com/products/8661
// Article: http://bildr.org/2011/08/heartrate-arduino/
#include “Wire.h”
#define HRMI_I2C_ADDR听听 127
#define HRMI_HR_ALG听听听 1 听// 1= average sample, 0 = raw sample
int led = 13;
byte seven_seg_digits[10][7] = { { 1,1,1,1,1,1,0 }, // = 0
听听听听听听听听听听听听听听听听听听听听听听听听听听听听 听{ 0,1,1,0,0,0,0 }, // = 1
听听听听听听听听听听听听听听听听听听听听听听听听听听听听 听{ 1,1,0,1,1,0,1 }, // = 2
听听听听听听听听听听听听听听听听听听听听听听听听听听听听 听{ 1,1,1,1,0,0,1 }, // = 3
听听听听听听听听听听听听听听听听听听听听听听听听听听听听 听{ 0,1,1,0,0,1,1 }, // = 4
听听听听听听听听听听听听听听听听听听听听听听听听听听听听 听{ 1,0,1,1,0,1,1 }, // = 5
听听听听听听听听听听听听听听听听听听听听听听听听听听听听 听{ 1,0,1,1,1,1,1 }, // = 6
听听听听听听听听听听听听听听听听听听听听听听听听听听听听 听{ 1,1,1,0,0,0,0 }, // = 7
听听听听听听听听听听听听听听听听听听听听听听听听听听听听 听{ 1,1,1,1,1,1,1 }, // = 8
听听听听 听听听听听听听听听听听听听听听听听听听听听听听听听{ 1,1,1,0,0,1,1 } 听// = 9
听听听听听听听听听听听听听听听听听听听听听听听听听听听听 听};
void setup(){
听蝉别迟耻辫贬别补谤迟惭辞苍颈迟辞谤(贬搁惭滨冲贬搁冲础尝骋);
听厂别谤颈补濒.产别驳颈苍(9600);
听pinMode(led, OUTPUT);听
听 pinMode(40, OUTPUT); 听
听pinMode(41, OUTPUT);
听pinMode(42, OUTPUT);
听pinMode(43, OUTPUT);
听pinMode(44, OUTPUT);
听pinMode(45, OUTPUT);
听pinMode(46, OUTPUT);
听pinMode(47, OUTPUT);
听听听 pinMode(22, OUTPUT); 听
听pinMode(23, OUTPUT);
听pinMode(24, OUTPUT);
听pinMode(25, OUTPUT);
听pinMode(26, OUTPUT);
听pinMode(27, OUTPUT);
听pinMode(28, OUTPUT);
听听pinMode(35, OUTPUT);
听
}
听
void sevenSegWrite(byte digit) {
听byte pin = 22;
听for (byte segCount = 0; segCount < 28; ++segCount) {
听 digitalWrite(pin, seven_seg_digits[digit][segCount]);
听 ++pin;}}
听 void sevenSegWriteB(byte digit) {
听byte pin = 40;
听for (byte segCount = 0; segCount < 45; ++segCount) {
听 digitalWrite(pin, seven_seg_digits[digit][segCount]);
听 ++pin;}}
void loop(){
听int heartRate = getHeartRate();
听Serial.println(heartRate);
听sevenSegWrite(heartRate%10);
听sevenSegWriteB((heartRate/10)%10);
听if (heartRate>=100) {digitalWrite(35, HIGH); }
听else
听{digitalWrite(35, LOW);}
听delay(100); //just here to slow down the checking to once a second
}
void setupHeartMonitor(int type){
听//setup the heartrate monitor
听Wire.begin();
听writeRegister(HRMI_I2C_ADDR, 0x53, type); // Configure the HRMI with the requested algorithm mode
}
int getHeartRate(){
听//get and return heart rate
听//returns 0 if we couldnt get the heart rate
听byte i2cRspArray[3]; // I2C response array
听i2cRspArray[2] = 0;
听writeRegister(HRMI_I2C_ADDR, 0x47, 0x1); // Request a set of heart rate values听
听if (hrmiGetData(127, 3, i2cRspArray)) {
听 return i2cRspArray[2];
听}
听else{
听 return 0;
听}
}
void writeRegister(int deviceAddress, byte address, byte val) {
听//I2C command to send data to a specific address on the device
听Wire.beginTransmission(deviceAddress); // start transmission to device听
听Wire.write(address);听听 听// send register address
听Wire.write(val);听听听 听// send value to write
听Wire.endTransmission();听 听// end transmission
}
boolean hrmiGetData(byte addr, byte numBytes, byte* dataArray){
听//Get data from heart rate monitor and fill dataArray byte with responce
听//Returns true if it was able to get it, false if not
听Wire.requestFrom(addr, numBytes);
听if (Wire.available()) {
听 for (int i=0; i 听听 dataArray[i] = Wire.read(); 听 } 听 return true; 听} 听else{ 听 return false;