Heart Rate With Custom IoT




In this example we will measure the heartbeat with the light provides a Led and a photo-transistor. The phototransistor detects the light that passes our finger from LED. The oxygen in our blood will prevent light comes the photo-transistor and from there will draw the information to detect heartbeat.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Neccesary Components

→ 1 CustomIoT board

→ 1 Red Led

→ 1 Green Led

→ 1 photo-transistor

Step 2: Code

Load the attached code on the board.

We read the sensor value via pin A0 and calculate the current value measured by this and previous one, giving more importance to the previous (alpha = 0.75). We make the difference to see if this value has changed a lot and we send it to flicker green led to the same frequency as the heartbeat.

int ledPin = 4;
int sensorPin = A0;
<br>double alpha = 0.75;
int period = 20;
double change = 0.0;

void <strong>setup</strong>()            

void <strong>loop</strong>()             
    static double oldValue =0;
    static double oldChange =0;
    int rawValue =analogRead(sensorPin);
    double value =alpha * oldValue + (1 - alpha) * rawValue;
    change = value-oldValue;
    digitalWrite(ledPin, change);
    oldValue = value;

Step 3: Hardware Connections

We employed a module like you see in the picture below (sensor + red Led). Connect the output of this sensor with A0 pin from our board CustomIoT. The green LED will be connected to pin 4 from the board.

Be the First to Share


    • Made with Math Contest

      Made with Math Contest
    • Multi-Discipline Contest

      Multi-Discipline Contest
    • Robotics Contest

      Robotics Contest

    5 Discussions


    4 years ago on Introduction


    You need Custom IoT board and arduino IDE for upload the code.