Heart Rate Sensor

Note how the Voltage rises above mid-point (512 in case of reading in through A0-A5 analog inputs) on every pulse.

Wiring & Coding

Pin Connections

My Blocks (aka Functions)

Whenever you have some pattern of code that you're going to want to repeat in your program, it is advisable to turn it into a Function.

A function is a a bunch of coding blocks that are bunched together and can be called with a single new block.

For instance, to reset the Heart Monitor, we need to:

All of that needs to happen at the begnning of our program, and every time the pen tip reaches the right edge of the monitor...

So, we can bundle it up in a My Block function, and call it in different places in our code.

First, create a new My Block:

Then, give your function a meaningful name that encompasses whet it's for:

Finally, define the new function by associating it with a sequence of other base blocks.

Once a function is defined in this way it can be used just like any other code block.