# 10.3 Pulse Monitor

## Hardware Wiring

![Pulse Monitor](/files/-LCFEE6mO7K0CPlVb5FL)

## Sketch

The code can be found at [Examples\_Arduino - sensor-kit-for-arduino - \_035\_PulseMonitor - \_035\_PulseMonitor.ino](https://github.com/LongerVisionRobot/Examples_Arduino/blob/master/sensor-kit-for-arduino/_035_PulseMonitor/_035_PulseMonitor.ino).

```
int ledPin=13;
int sensorPin=0;

double alpha=0.75;
int period=20;
double change=0.0;

void setup()
{
  pinMode(ledPin,OUTPUT);
}

void loop()
{
  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<0.0&&oldChange>0.0));

  oldValue=value;
  oldChange=change;
  delay(period);
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://longer-vision-robot.gitbook.io/arduino-full-stack/10_other_sensors/035_pulsemonitor.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
