SparkFun Forums 

Where electronics enthusiasts find answers.

General project discussion / help
Did you make a robotic coffee pot which implements HTCPCP and decafs unauthorized users? Show it off here!
By bmanz
#195535
Hello people of the forum!

I have been having some serious difficulties in making this work, I've followed all the guidelines...

https://learn.sparkfun.com/tutorials/ad ... okup-guide

I'm at the point where I'm reading the sensor, but the numbers I'm getting are mad, I've tried swapping electrodes to different branded ones and different pads but it is all still the same. I've tried different parts of the body that are recommended but the analogue input is crazy and nothing like a heart beat...

I've literally followed the above guide precisely and then tried to problem solve my own ways and then returned to the guide, and I'm just getting such fast fluctuating inputs that seem nothing like heart rate....

This is the code that I started with:


void setup() {
// initialize the serial communication:
Serial.begin(9600);
pinMode(10, INPUT); // Setup for leads off detection LO +
pinMode(11, INPUT); // Setup for leads off detection LO -

}

void loop() {

if((digitalRead(10) == 1)||(digitalRead(11) == 1)){
Serial.println('!');
}
else{
// send the value of analog input 0:
Serial.println(analogRead(A0));
}
//Wait for a bit to keep serial data from saturating
delay(100);
}


This is the code I've used to send the data to max which basically just does the same as the last code except causes max to receive the data...

int x = 0; // a place to hold pin values
int ledpin = 13;

void setup()
{
Serial.begin(115200); // 115200 is the default Arduino Bluetooth speed
pinMode(10, INPUT); // Setup for leads off detection LO +
pinMode(11, INPUT); // Setup for leads off detection LO -
digitalWrite(13, HIGH); ///startup blink
delay(1200);
digitalWrite(13, LOW);
pinMode(13, INPUT);
}



void loop()
{

if (Serial.available() > 0) { // Check serial buffer for characters

if (Serial.read() == 'r') { // If an 'r' is received then read the pins

for (int pin = 0; pin <= 5; pin++) { // Read and send analog pins 0-5
x = analogRead(pin);
sendValue (x);
}



for (int pin = 2; pin <= 13; pin++) { // Read and send digital pins 2-13
x = digitalRead(pin);
sendValue (x);
}

Serial.println(); // Send a carriage returnt to mark end of pin data.
delay (100);
delay (100);

}

}
}

void sendValue (int x) { // function to send the pin value followed by a "space".
Serial.print(x);
Serial.write(32);
}



Please help... I don't see what I'm doing wrong anymore...!

If you've read this and don't know what could be wrong, could you at least try recommend me a HR monitor (could be prebuilt) that works well with Max MSP!!!

Thanks everyone!!

- Bev