loading

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.

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>()            
{
  pinMode(ledPin,OUTPUT);
  <strong>Serial</strong>.begin(115200);
}

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;
    delay(period);
}





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.

<p>@</p><p><a href="https://www.instructables.com/member/Custodium/" rel="nofollow"></a><a href="https://www.instructables.com/member/Custodium/" rel="nofollow">Custodium</a></p>
<p>not for noobs</p>
<p>Hi!</p><p>You need Custom IoT board and arduino IDE for upload the code.</p><p>Regards.</p>
<p>I don't know how to load the code,could you elaborate it?</p>
<p>Thanks for sharing this!</p>

About This Instructable

2,022views

20favorites

License:

More by Custodium:Heart Rate with Custom IoT 
Add instructable to: