SparkFun gator:particle Hookup Guide

Pages
Contributors: santaimpersonator, Englandsaurus
Favorited Favorite 0

MakeCode Example

Now that you have added the gator:particle extension to the Editor, lets start with some example code. Plug the micro:bit into your computer using an USB micro-B cable after you have assembled your hardware with the instructions from the previous section. The micro:bit should appear on your computer as a removable storage device.

USB Drive
The micro:bit showing up as a USB drive on a Windows computer. Click to enlarge.

To upload new code, this is where you will be copying the downloaded .hex file to later.

Block Functions

initialize gator:particle sensor
This block should be pretty self explanatory, it sets the sensor up to be used. You should use this within the on start block.

get _____ value
This is a value block as indicated by the block's shape. The output is an integer value from 0 to 262,143 for the sensor's detection of the specified wavelength. There is a drop down menu with selectable options for the sensor reading for the block. Below is a description of the available menu options:

  • red- An 18-bit integer value for sensor detection in the IR wavelength (0 and 262,143).
  • infrared- An 18-bit integer value for sensor detection in the IR wavelength (0 and 262,143).
  • With the default LED intensity, I was only able to see a maximum of approximately 120,000. To get higher values, the LED intensity needs to be turned up.

detect heartbeat in _____
This is a value block as indicated by the block's shape. There is a drop down menu with selectable options for the output value of the block. Below is a description of the available menu options:

  • BPM- Outputs a single heart-rate measurement in beats per minute (BPM).
  • AVG- Outputs the average of the last four heart-rate readings in BPM.

Set LED mode to read _____
This block should allows users to designate the LED modes. There are only two opions:

  • red- Only the red LED is used or on.
  • red & infrared- Both the red and IR LEDs are on.
  • There is no option to use only the IR LED.

Change strength of _____ to _____
This block should allows users to control the brightness or intensity of the LEDs.

  1. LED- Users designate which LED to control.
    • red
    • infrared
  2. Strength- Users specify the intensity of the LED. Enter an integer.
    • 0 to 255

Basic Read

Below, is a simple example of how to take simple measurements from the sensor. To use this example, there are multiple options for accessing the .hex file:

  • Replicate the block functions from the display below to copy the example project. Then download the .hex file.
  • Expand the display widow to pull up the example project. Then download the .hex file.
  • Use this link to pull up the example project. Then download the .hex file.
  • Download the .hex file from the button below or the link on the bottom of the display.

The output is redirected over the serial port to avoid conflicts on pins P0 and P1, which are also used for serial communication. To read the sensor values, pull up your favorite serial terminal emulator. Then, connect to the serial port that the micro:bit is on; the default baud rate is 115200 bps. Below, is an example of the sensor output for the example code.

Sample Readings
Example of readings from the sensor.