SparkFun will be closed Nov 26th and 27th for the Thanksgiving holiday. Orders placed after 2:00pm MT on the 25th will ship out Monday the 30th.

Member #151249

Member Since: September 15, 2010

Country: United States

  • Added a few lines to Casey’s excellent processing code to give multiline, 200ms tick marks, and screenshotting

    Demo Program for AD8232 Heart Rate sensor.
    Casey Kuhns @ SparkFun Electronics
    Some mods by Humphrey Gardner  humphrey@hapitek.com
    Now five lines of EKG, tick marks every 200ms, click on frame to save to the executable's directory
    The AD8232 Heart Rate sensor is a low cost EKG/ECG sensor. This example shows
    how to create an ECG with real time display. The display is using Processing.
    This sketch is based heavily on the Graphing Tutorial provided in the Arduino
    IDE. http://www.arduino.cc/en/Tutorial/Graph
    This program requires a Processing sketch to view the data in real time.
    Development environment specifics:
    IDE: Arduino 1.0.5
    Hardware Platform: Arduino Pro 3.3V/8MHz
    AD8232 Heart Monitor Version: 1.0
    This code is beerware. If you see me (or any other SparkFun employee) at the
    local pub, and you've found our code helpful, please buy us a round!
    Distributed as-is; no warranty is given.
    import processing.serial.*;
    Serial myPort; // The serial port
    int xPos = 1; // horizontal position of the graph
    int tick=millis();
    float height_old = 0;
    float height_new = 0;
    float inByte = 0;
    int baseheight=100;
    void setup () {
      // set the window size:
      size(1600, 800);
      // List all the available serial ports
      // Open whatever port is the one you're using.
      myPort = new Serial(this, Serial.list()[1], 9600);
      // don't generate a serialEvent() unless you get a newline character:
      // set inital background:
    void draw () {
      // everything happens in the serialEvent()
    void serialEvent (Serial myPort) {
      // get the ASCII string:
      String inString = myPort.readStringUntil('\n');
      if (inString != null) {
        // trim off any whitespace:
        inString = trim(inString);
        // If leads off detection is true notify with blue line
        if (inString.equals("!")) {
          stroke(0, 0, 0xff); //Set stroke to blue ( R, G, B)
          inByte = 512; // middle of the ADC range (Flat Line)
        // If the data is good let it through
        else {
          stroke(0xff, 0, 0); //Set stroke to red ( R, G, B)
          inByte = float(inString);
         //Map and draw the line for new data point
         inByte = map(inByte, 0, 512, 0, height/16);
         height_new = inByte;
         line(xPos - 1, baseheight-height_old , xPos, baseheight-height_new);
         height_old = height_new;
         //tickmark for 200 mseconds
         if (tick+200<=millis()){
           stroke(0, 0xff, 0); //Set stroke to green ( R, G, B)
           line(xPos, baseheight-20, xPos,baseheight+20);
        //screen print if wished
        if(mousePressed) { 
          // at the edge of the screen, go back to the beginning:
          if (xPos >= width) {
            xPos = 0;
          if (baseheight>height-100){
            xPos = 0;
          else {
            // increment the horizontal position:
  • Aug 2013 - Quick build, beautifully compact, instructions are accurate. Running mine off a 9v battery with no problems.

No public wish lists :(