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’re running? Either way, it only takes a little soldering and electronics judo to create a giant heart rate display. For interval training, it’s 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’re 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(){
ٳܱٲѴDzԾٴǰ(ѱ崡);
.(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;