# Meditation Trainer

## Overview

![](https://cdn-learn.adafruit.com/assets/assets/000/035/820/medium800/biometric_in_use.jpg?1474403163)

This project uses an Adafruit **Circuit Playground Classic** &nbsp;board along with a **Pulse Sensor Amped** to measure changes&nbsp;in heart rate variability (HRV). &nbsp;Because fewer changes in heart rate variability are associated&nbsp;with healthy,&nbsp;relaxed states,&nbsp;these measurements can be used as&nbsp;a way to reduce anxiety and increase meditative calm.

# What is HRV?

We normally think about our pulse as being a relatively constant value measured in beats per minute, but in reality, the interval&nbsp;between beats ( **inter-beat interval** or **IBI** ) usually fluctuates quite a bit. &nbsp;This variance between heart beat intervals&nbsp;is known as **heart rate variability** ( **HRV** ).

When breathing&nbsp;is slowed to a rate of ~12 cycles per minute (1 cycle = 1 inhale + 1 exhale), respiratory & cardiac rhythms tend to fall in sync with one another&nbsp;and HRV fluctuations become less erratic&nbsp;and more amplified resembling a sine wave. &nbsp;This synchronization is considered indicative of a relaxed, healthy state of being where&nbsp;anxiety is reduced and clear, calm thinking is enhanced.&nbsp;

So, if we measured and graphed the time between heartbeats of a stressed person, it might look something like this:

![](https://cdn-learn.adafruit.com/assets/assets/000/035/811/medium800/biometric_hrv---stressed.jpg?1474351598)

And the same type of measurement made on a zen master might look something like this:

![](https://cdn-learn.adafruit.com/assets/assets/000/035/812/medium800/biometric_hrv---calm.jpg?1474351612)

The goal of this project is to create a device which will help someone achieve a smoother, sinusoidal HRV pattern like the one above.

You can read more about HRV, coherence, and related topics here:

- [Wikipedia](https://en.wikipedia.org/wiki/Heart_rate_variability)
- [Coherence.com](http://www.coherence.com/science_full_html_production.htm)
- [HeartMath](http://www.heartmath.com/science-behind-emwave/)

Info: 

# What you'll need:

To build the relaxation trainer you'll only need the following:

- [Circuit Playground Classic](https://www.adafruit.com/products/3000)
- [Pulse Sensor Amped](https://www.adafruit.com/products/1093)
- [Alligator Clips](https://www.adafruit.com/products/1008)- **or** - [Soldering iron](https://www.adafruit.com/products/2163)&nbsp;& [solder](https://www.adafruit.com/products/1886)

![](https://cdn-learn.adafruit.com/assets/assets/000/034/817/medium800/biometric_cp_and_ps.jpg?1471347412)

# Meditation Trainer

## Wiring

![](https://cdn-learn.adafruit.com/assets/assets/000/037/635/medium800/biometric_meditation_trainer_wiring_schematic-updated.jpg?1480579208)

Wiring for this project is simple,&nbsp;there are only three connections which need to be made between the Pulse Sensor and Circuit Playground board:

- Pulse Sensor **Black&nbsp;wire** to Circuit Playground&nbsp; **GND**
- Pulse Sensor **Red wire** to Circuit Playground **VBATT**
- Pulse Sensor **Purple&nbsp;wire** to Circuit Playground&nbsp; **#6**

The Circuit Playground can be powered by either USB or the JST battery connector.

# Making connections

If you'd just like to experiment with or test this project, you can easily make the necessary connections using three alligator clips.&nbsp;

![](https://cdn-learn.adafruit.com/assets/assets/000/035/818/medium800/biometric_alligator-clipped.jpg?1474399177)

For a more permanent approach, you can&nbsp;securely solder the connections. &nbsp;Clip the male header pins from the pulse sensor leads and then strip and tin each lead before soldering to the terminals on the Circuit Playground board.

![](https://cdn-learn.adafruit.com/assets/assets/000/035/815/medium800/biometric_wire_stripping.jpg?1474398203)

![](https://cdn-learn.adafruit.com/assets/assets/000/034/821/medium800/biometric_soldering.jpg?1471347571)

# Meditation Trainer

## Software

Info: 

Danger: 

# Setup

If this is the first time you're programming&nbsp;a **Circuit Playground** board, you'll need to set up the **Arduino IDE** with support for it. &nbsp;Follow the [instructions found here](../../../../introducing-circuit-playground/arduino-1-dot-6-x-ide), and come back once you have everything working.

# Code

The code we'll be using is based on the example sketch written for the Pulse Sensor Amped. &nbsp;Code has been added&nbsp;to control the Circuit Playground's built-in&nbsp;Neopixel LEDs and record&nbsp;changes in interbeat interval values ( **IBI** ), and calculate a relaxation rating based on how often the IBI plots change direction.

Download the code from the project's GitHib repository here:

[Click to download Meditation Trainer](https://github.com/CollinCunningham/Meditation_Trainer/archive/master.zip)
Unzip&nbsp;the downloaded archive and rename the folder named " **Meditation\_Trainer-master**" to " **Meditation\_Trainer**". &nbsp;

Inside that folder, you'll find a file named&nbsp;" **Meditation\_Trainer.ino**" - open it in&nbsp;the Arduino IDE and upload it to your Circuit Playground board.

# Meditation Trainer

## Usage

The pulse sensor can be attached to either the ear lobe or fingertip. &nbsp;In my experience, attaching the sensor to the fingertip with the included velcro strip&nbsp;provides the most reliable reading.

![](https://cdn-learn.adafruit.com/assets/assets/000/035/814/medium800/biometric_ps_on_velcro-2up.jpg?1474397844)

Once the sensor is secured, connect the Circuit Playground board to power via the USB or battery connector and you should see the two LEDs near the USB jack begin to flash in time with your pulse.

If the LEDs don't light up, try readjusting the sensor until you have a secure fit.

![](https://cdn-learn.adafruit.com/assets/assets/000/034/823/medium800/biometric_in_use.jpg?1471347642)

# Using the LED Display
 **Breath Pacer:** Eight&nbsp;of the neopixel LEDs on the Circuit Playground are used to display a breath pacer which is helpful for ideal timing of inhale/exhale cycles. &nbsp;Breath in as the LEDs pulse toward one side, and breath out as they move back to the other side.

&nbsp;

**Pulse/Relaxation:** The remaining two LEDs flash with each pulse detected and their color indicates a basic HRV rating which roughly translates to the user's level of relaxation:

&nbsp;

**red = low&nbsp;relaxation**

**blue = moderate&nbsp;relaxation**

**green&nbsp;= high&nbsp;relaxation**

![biometric_led-legend3.jpg](https://cdn-learn.adafruit.com/assets/assets/000/035/813/medium640/biometric_led-legend3.jpg?1474396185)

# Breathe

Sit in a comfortable position and use the breath pacer to guide your breathing - breath in as it moves toward one side, and begin to breath out when it changes direction.

As you continue to breathe at this slow deliberate rate, you should notice the pulse LEDs change color to indicate smoother changes in heart rate variability and hopefully help you achieve a more deeply relaxed state.

Though the relaxation indicator is helpful, the most useful functionality here is actually the breath pacer. &nbsp;One of the most common techniques for achieving a meditative state is focussed breathing. Paying conscious attention&nbsp;to your own breathing is a simple but highly effective way to increase mindfulness.


## Featured Products

### Circuit Playground Classic

[Circuit Playground Classic](https://www.adafruit.com/product/3000)
Would you like to learn electronics, with an all-in-one board that has sensors and LEDs built in? **Circuit Playground** is here - and it's the best way to practice programming on real hardware with no soldering or sewing required!

This is the **Classic**...

In Stock
[Buy Now](https://www.adafruit.com/product/3000)
[Related Guides to the Product](https://learn.adafruit.com/products/3000/guides)
### Pulse Sensor Amped

[Pulse Sensor Amped](https://www.adafruit.com/product/1093)
Pulse Sensor Amped is a greatly improved version of the original Pulse Sensor, a plug-and-play heart-rate sensor for Arduino and Arduino compatibles. It can be used by students, artists, athletes, makers, and game & mobile developers who want to easily incorporate live heart-rate data into...

Out of Stock
[Buy Now](https://www.adafruit.com/product/1093)
[Related Guides to the Product](https://learn.adafruit.com/products/1093/guides)
### Small Alligator Clip Test Lead (set of 12)

[Small Alligator Clip Test Lead (set of 12)](https://www.adafruit.com/product/1008)
Connect this to that without soldering using these handy mini alligator clip test leads. 15" cables with alligator clip on each end, color coded. You get 12 pieces in 6 colors. Strong and grippy, these always come in handy! We often use these in conjunction with a multimeter so we...

Out of Stock
[Buy Now](https://www.adafruit.com/product/1008)
[Related Guides to the Product](https://learn.adafruit.com/products/1008/guides)

## Related Guides

- [Introducing Circuit Playground](https://learn.adafruit.com/introducing-circuit-playground.md)
- [Circuit Playground & Bluetooth Low Energy](https://learn.adafruit.com/circuit-playground-and-bluetooth-low-energy.md)
- [Circuit Playground Slouch Detector](https://learn.adafruit.com/circuit-playground-slouch-detector.md)
- [Circuit Playground Hourglass](https://learn.adafruit.com/circuit-playground-hourglass.md)
- [Circuit Playground Bike Light](https://learn.adafruit.com/circuit-playground-bike-light.md)
- [Circuit Playground Beep Beep](https://learn.adafruit.com/circuit-playground-beep-beep.md)
- [Circuit Playground Lesson #0](https://learn.adafruit.com/circuit-playground-lesson-number-0.md)
- [Glowing Smokey Skull ](https://learn.adafruit.com/glowing-smokey-skull.md)
- [Circuit Playground Sound-Controlled Robot](https://learn.adafruit.com/circuit-playground-sound-controlled-robot.md)
- [Circuit Playground Class Scheduler](https://learn.adafruit.com/circuit-playground-class-scheduler.md)
- [Circuit Playground's Motion Sensor](https://learn.adafruit.com/circuit-playgrounds-motion-sensor.md)
- [Ever-Burning Flame Painting](https://learn.adafruit.com/ever-burning-flame-painting.md)
- [NeoAnim: Using Bitmaps to Animate NeoPixels on Circuit Playground](https://learn.adafruit.com/circuit-playground-neoanim-using-bitmaps-to-animate-neopixels.md)
- [Circuit Playground PZ-1: Pizza Box DJ Controller](https://learn.adafruit.com/circuit-playground-pizza-box-dj-controller.md)
- [NeoPix Arcade Kit - 1D Arcade Game System - Circuit Playground](https://learn.adafruit.com/neopix-arcade-kit-1d-arcade-game-system-circuit-playground.md)
- [Fidget Spinner Tachometer](https://learn.adafruit.com/fidget-spinner-tachometer.md)
