# Circuit Playground Express Compass

## Overview

![](https://cdn-learn.adafruit.com/assets/assets/000/063/402/medium800/express_red_demo.jpg?1539216006)

The Circuit Playground Express has a 3-axis LIS3DH accelerometer on board which can be used for all sorts of projects. This chip has the advantage of being very small and fits nicely at the center of the Circuit Playground boards. Sometimes, though, "just" being a 3-axis accelerometer is a disadvantage. Times like those when you need compass-like capabilities. An accelerometer **only** tells you how the board is moving (the forces acting on it, to be precise), but not how it's oriented relative to the magnetic north pole of whichever planet you're on. For that, a **magnetometer** is needed.

Magnetometers do come as separate chips (the BBC Micro:bit has one, for example) but it doesn't seem as easy to find on a breakout board. However, breakouts containing a single chip with both an accelerometer and a magnetometer are easy to find. Specificity, there are breakouts containing the LSM303 in both the usual rectangular header-strip format as well as a Flora breakout.

In this guide we'll add the Flora LMS303 breakout to a Circuit Playground Express and use it to build a compass.

Coding in C (Arduino), you can actually use any breakout whose supporting library conforms to the Adafruit Unified Sensor Library and provides magnetometer readings. The project is also programmable in CircuitPython and demonstrates use of the accelerometer.

The NeoPixels on the Circuit Playground Express will be used to indicate North.

## Calibration

During calibration (when all the pixels are green) move the box in a figure eight and rotate it around the x, and y axes multiple times.

By sampling a range of readings. we can get a sense of the expected range of values. Using that, we can calculate the center on the range on both the X and Y axes. The distance of that from (0, 0) can be used to correct subsequent readings to be relative to (0, 0).

When calibrating from the original code (i.e. you haven't tweaked the min/max arrays) or if you ask for a recalibration (by pressing button A until the pixels turn green) the result will be printed on the console. You can copy these two lines and replace the similar ones near the top of the code. Rebuild it (if using the Arduino code) and load it onto your compass.

## Operation

We can then map each corrected reading to the range -100 to +100, and pass these normalized values to the atan2 function that gives us a heading, the angle as shown in the range -Pi to Pi.

Then we find which 30 degree wedge the heading falls into. We start by adding 180 to the angle from above, giving us something between 0 and 360. We add 15 (because the lowest segment is centered on zero) and divide by 30.&nbsp;

And that's how we know which NeoPixel to light up.

## Parts
Featured
### Circuit Playground Express

[Circuit Playground Express](https://www.adafruit.com/product/3333)
 **Circuit Playground Express** is the next step towards a perfect introduction to electronics and programming. We've taken the original Circuit Playground Classic and made it even better! Not only did we pack even more sensors in, we also made it even easier to...

Out of Stock
[Buy Now](https://www.adafruit.com/product/3333)
[Related Guides to the Product](https://learn.adafruit.com/products/3333/guides)
![A Black woman's manicured hand holds a round microcontroller with lit up LEDs.](https://cdn-shop.adafruit.com/640x480/3333-05.jpg)

Featured
### JST PH 2-Pin Cable – Male Header 200mm

[JST PH 2-Pin Cable – Male Header 200mm](https://www.adafruit.com/product/3814)
For a really long time we assumed that the JST PH didn't have a free-hanging male header version. But then we found this **JST-PH 2-pin Male Cable,** and we were like,&nbsp;_this is perfect!_ It's not a genuine JST connector, but it's 100%...

In Stock
[Buy Now](https://www.adafruit.com/product/3814)
[Related Guides to the Product](https://learn.adafruit.com/products/3814/guides)
![Top view shot of JST PH 2-Pin Cable - Male Header - 200mm.](https://cdn-shop.adafruit.com/640x480/3814-02.jpg)

Featured
### JST PH 2-Pin Cable - Female Connector 100mm

[JST PH 2-Pin Cable - Female Connector 100mm](https://www.adafruit.com/product/261)
Red and black tinned wires with a 2-pin JST PH connector on the end. 4" / 100mm long. Matches up nicely with our Lipoly chargers!

[We have the socket 'mating' version of this cable](https://www.adafruit.com/product/3814) over here, <a...></a...>

In Stock
[Buy Now](https://www.adafruit.com/product/261)
[Related Guides to the Product](https://learn.adafruit.com/products/261/guides)
![Top view shot of a red and black JST PH 2-Pin Cable to Female Connector - 100mm.](https://cdn-shop.adafruit.com/640x480/261-01.jpg)

Featured
### Breadboard-friendly SPDT Slide Switch

[Breadboard-friendly SPDT Slide Switch](https://www.adafruit.com/product/805)
These nice switches are perfect for use with breadboard and perfboard projects. They have 0.1" spacing and snap in nicely into a solderless breadboard. They're easy to switch no matter what size fingers you have, but not so easy that they'll get flipped by accident. Work great as...

Out of Stock
[Buy Now](https://www.adafruit.com/product/805)
[Related Guides to the Product](https://learn.adafruit.com/products/805/guides)
![Small, black, SPDT slide switch.](https://cdn-shop.adafruit.com/640x480/805-03.jpg)

Featured
### Lithium Ion Polymer Battery - 3.7v 150mAh

[Lithium Ion Polymer Battery - 3.7v 150mAh](https://www.adafruit.com/product/1317)
Lithium-ion polymer (also known as 'lipo' or 'lipoly') batteries are thin, light, and powerful. The output ranges from 4.2V when completely charged to 3.7V. This battery has a capacity of 150mAh for a total of about 0.6 Wh. If you need a larger battery, <a...></a...>

In Stock
[Buy Now](https://www.adafruit.com/product/1317)
[Related Guides to the Product](https://learn.adafruit.com/products/1317/guides)
![Angle Shot of Lithium Ion Polymer Battery 3.7v 150mAh with JST 2-PH connector](https://cdn-shop.adafruit.com/640x480/1317-03.jpg)

Featured
### Silicone Cover Stranded-Core Wire - 2m 26AWG Blue

[Silicone Cover Stranded-Core Wire - 2m 26AWG Blue](https://www.adafruit.com/product/1878)
Silicone-sheathing wire is super-flexible and soft, and its also strong! Able to handle up to 200°C and up to 600V, it will do when PVC covered wire wimps out. We like this wire for being extremely supple and flexible, so it is great for wearables or projects where the wire-harness has to...

In Stock
[Buy Now](https://www.adafruit.com/product/1878)
[Related Guides to the Product](https://learn.adafruit.com/products/1878/guides)
![Top shot of Blue Silicone Cover Stranded wire ](https://cdn-shop.adafruit.com/640x480/1878-01.jpg)

## Supplies and Tools

- Hot Glue & Glue Gun
- Solder and Soldering Iron

For the build described here, you'll probably want a case for the Circuit Playground Express. If you have a 3D printer or have access to 3D printing facilities, [this guide](https://learn.adafruit.com/case-for-circuit-playground) shows how to produce a nice one.

# Circuit Playground Express Compass

## Hardware

## Adding the LSM303
Wiring the LSM303 is easy - like most sensors, it uses I2C - so&nbsp; you just need to wire up:

- 3.3V to 3.3V
- GND to GND
- SDA to SDA
- SCL to SCL

pretty easy!

Start by hot gluing the LSM303 to the back of the Circuit Playground Express such that the boards are back to back. Be sure to position the LSM303 in the center of the Circuit Playground Express with the X axis running between the USB and power connections.

&nbsp;

Once the glue cools, you can wire the breakout. The arrangement of power, ground and I2C matches up with that of the Circuit Playground Express neatly.

&nbsp;

While that's really all that's needed to make a working compass, we can go the next step and package it nicely.

![express_IMG_2503.jpg](https://cdn-learn.adafruit.com/assets/assets/000/062/983/medium640/express_IMG_2503.jpg?1538659404)

![express_one_one.png](https://cdn-learn.adafruit.com/assets/assets/000/124/335/medium640/express_one_one.png?1694528156)

## Putting it in a Case
![](https://cdn-learn.adafruit.com/assets/assets/000/124/337/medium800/express_one_one.png?1694528380)

Start with a case.&nbsp;[This](https://learn.adafruit.com/case-for-circuit-playground)&nbsp;is a good one: it provides space for a small LiPo battery and an on-off switch, as well as access to the USB connector.

&nbsp;

To connect the battery you will need male and female JST cables and a slide switch. Cut the wires on the JST connectors to fit neatly in the case, under the Circuit Playground Express. Connect the black wires together and connect the red wires to two adjacent connections of the switch. Using a bit of heat shrink on each of the connections is almost always a good idea: it helps avoid accidental shorts.

&nbsp;

Next, secure the switch to the case with a little hot glue. Once it cools, connect the battery and Circuit Playground Express and tuck everything into place.

![express_IMG_2511.jpg](https://cdn-learn.adafruit.com/assets/assets/000/062/985/medium640/express_IMG_2511.jpg?1538659645)

![express_IMG_2513.jpg](https://cdn-learn.adafruit.com/assets/assets/000/062/987/medium640/express_IMG_2513.jpg?1538659700)

![express_IMG_2514.jpg](https://cdn-learn.adafruit.com/assets/assets/000/062/988/medium640/express_IMG_2514.jpg?1538659833)

![express_IMG_2515.jpg](https://cdn-learn.adafruit.com/assets/assets/000/062/990/medium640/express_IMG_2515.jpg?1538660501)

Secure the board as appropriate for the case you're using.

All that's left is to snap the cover into place and load up the software.

![](https://cdn-learn.adafruit.com/assets/assets/000/061/070/medium800/circuitpython_IMG_2516.jpg?1536274590)

# Circuit Playground Express Compass

## Arduino

We'll use the Arduino IDE for the compass code -&nbsp;[download & install it](https://learn.adafruit.com/ladyadas-learn-arduino-lesson-number-0/download-software)&nbsp;if you haven't already.&nbsp;

If you're new to Arduino, check out the&nbsp;[Getting Started with Arduino guide](https://learn.adafruit.com/lesson-0-getting-started).

# Install Libraries

Along with Arduino IDE, we'll need to install the following [three libraries](http://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use).

Open up the Arduino IDE and from the top menu, go to&nbsp; **Sketch --\> Include Library --\> Manage Library** , search for&nbsp; **Unified Sensor&nbsp;** and install the latest version of the&nbsp; **Adafruit Unified Sensor&nbsp;** library **.**

Next follow the&nbsp; **same steps as above** &nbsp;to install the Unified&nbsp; **LSM303** &nbsp;library (or the library to match the accel/mag sensor you are using) and the Adafruit **NeoPixel** libraries.

![](https://cdn-learn.adafruit.com/assets/assets/000/061/480/medium800/express_unified_lib.png?1536694133)

![](https://cdn-learn.adafruit.com/assets/assets/000/061/481/medium800/express_lsm303_lib.png?1536694154)

![](https://cdn-learn.adafruit.com/assets/assets/000/061/482/medium800/express_neopixel_lib.png?1536694165)

# Install Board Support Package

Additionally, go to&nbsp; **Tools --\> Board: --\> Board Manager** &nbsp;and update the&nbsp; **Adafruit SAMD boards** &nbsp;library if you haven't already.&nbsp; Additional info for installing boards in the Arduino IDE is available&nbsp;[here](https://learn.adafruit.com/add-boards-arduino-v164/installing-boards).

## Upload Code

Go to&nbsp; **Tools --\> Board** , and choose&nbsp; **Adafruit Circuit Playground Express**. Then go to&nbsp; **Tools --\> Port** &nbsp;and choose the corresponding port for your board.

Create a&nbsp; **new sketch** ,&nbsp; **copy the code** &nbsp;you see below, and&nbsp; **paste** &nbsp;it into that new sketch.

https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/CPX_Compass/CPX_Compass.ino

Click the&nbsp; **Upload** &nbsp;button and wait for the process to complete. Once you see&nbsp; **Done Uploading** &nbsp;at the bottom of the window, the Circuit Playground Express should warm up and enter calibration (be sure to open the serial monitor first).

# Compass Calibration

The compass needs to be calibrated before use. This adapts it to the variation in the chip as well as the local magnetic environment.&nbsp; Simply spin the compass when the NeoPixels are green. If the compass acts erratically, pressing the left button (A) will do an additional calibration phase, which will hopefully improve the calibration. Be sure to spin it a couple full rotations for the widest range of values.

To calibrate you need the serial console open in order to get the calibrated values if you wish to set them in the code.

![](https://cdn-learn.adafruit.com/assets/assets/000/064/382/medium800/express_arduino_calibration_screenshot.png?1540495411)

There are a few ways to run a calibration. If the compass has never been calibrated (the `raw_mins` array contains all 1000.0) it will be calibrated. Additionally it will be done if the A/left button is pressed when the power is turned on or **reset** is pressed. In both these cases it is assumed that you have a USB serial connection. When calibration completes, two lines are output, similar to:

```auto
float raw_mins[2] = {-181.30, 216.09};
float raw_maxes[2] = {-136.96, 262.61};
```

Copy these into the code, replacing the two that look the same (other than the values), rebuild, and load onto the Circuit Playground Express. Subsequently powering on or resetting will then skip calibration.

# A Guided Tour

The `warm_up` function is used when starting up to make multiple reads from the magnetometer. Experience showed that the initial reads were unreliable; the magnetometer needs to warm up it would seem. The NeoPixels are set to blue during this phase.

```auto
void warm_up(void)
{
  sensors_event_t event;
  fill(0, 0, 64);
  for (int ignore = 0; ignore < 100; ignore++) {
    mag.getEvent(&event);
    delay(10);
  }
}
```

Calibration works by making about 1000 readings, and keeping track of the lowest and highest values along the X and Y axes. At the end, the origin offset is calculated by finding the center point of the readings (averaging the minimum and maximum values). Now we have the offset for readings as well as the expected value ranges. If the SAMD21 had EEPROM this could be stored and subsequent automatic calibration could be skipped, without having to rebuild the code.

```auto
    void calibrate(bool do_the_readings)
{
  sensors_event_t event;
  float values[2];

  fill(0, 64, 0);

  if (do_the_readings) {
    unsigned long start_time = millis();
    while (millis() - start_time < 5000) {

      mag.getEvent(&event);
      values[0] = event.magnetic.x;
      values[1] = event.magnetic.y * -1;
      if (values[0] != 0.0 && values[1] != 0.0) { /* ignore the random zero readings... it's bogus */
        for (int i = 0; i < 2; i++) {
          raw_mins[i] = values[i] < raw_mins[i] ? values[i] : raw_mins[i];
          raw_maxes[i] = values[i] > raw_maxes[i] ? values[i] : raw_maxes[i];
        }
      }
      delay(5);
    }
  }

  for (int i = 0; i < 2; i++) {
    corrections[i] = (raw_maxes[i] + raw_mins[i]) / 2;
    mins[i] = raw_mins[i] - corrections[i];
    maxes[i] = raw_maxes[i] - corrections[i];
  }
  fill(0, 0, 0);
}
  
```

The main loop runs about 20 times per second. It starts by checking for the left button being pushed. If it is, more calibration is done. Next the magnetometer values are read for X and Y.&nbsp;

```auto
    if (digitalRead(BUTTON_A)) {
    calibrate(true);
  }

  sensors_event_t event;
  mag.getEvent(&event);

  float x = event.magnetic.x;
  float y = event.magnetic.y * -1;
  
```

Notice that the Y value is negated since the breakout is mounted upside down, flipping the Y axis.

Occasionally there will be a problem and the read values will both be zero. If so the reading is ignored.

```auto
if (x == 0.0 && y == 0.0) {
  return;
}
```

Assuming the values are good, they are normalized. This is a simple mapping of the value from the range that resulted from calibration, to the range from -100 to +100.

```auto
float normalize(float value, float in_min, float in_max) {
  float mapped = (value - in_min) * 200 / (in_max - in_min) + -100;
  float max_clipped = mapped <  100 ? mapped : 100;
  float min_clipped = max_clipped > -100 ? max_clipped : -100;
  return min_clipped;
}
```

Once we have normalized values the `atan2` function is used to compute the angle of the vector made by those values. The angle will be in radians (ranging from -pi to +pi). That gets converted to degrees by multiplying by _180/pi_. Now we have a value in degrees that ranges from -180 to +180. That gets 180 added to it to give a value from 0 to 360. This is then divided by 30 to give the number of a wedge which corresponds to 1 of 10 NeoPixel positions. Because the wedge at the top is defined by the angles at +/-15 degrees, 15 is added (and the result clipped to 360 by using the modulus operator %) before the division.

```auto
  float normalized_x = normalize(x - corrections[0], mins[0], maxes[0]);
  float normalized_y = normalize(y - corrections[1], mins[1], maxes[1]);

  int compass_heading = (int)(atan2(normalized_y, normalized_x) * 180.0 / 3.14159);
  // compass_heading is between -180 and +180 since atan2 returns -pi to +pi
  // this translates it to be between 0 and 360
  compass_heading += 180;

  // We add 15 to account to the zero position being 0 +/- 15 degrees.
  // mod by 360 to keep it within a circle
  // divide by 30 to find which pixel corresponding pie slice it's in
  int direction_index = ((compass_heading + 15) % 360) / 30;

```

The final step is to update the NeoPixels. The `led_patterns` array that is defined at the top of the code is used to specify which pixels correspond to each wedge. Notice that two of the wedges specify two pixels, while the other 10 use only one. This is because the Circuit Playgrounds only have 10 NeoPixels; the top and bottom positions are used for the USB and battery connectors. To work around this, the two adjacent NeoPixels are used.

```auto
  int *leds;
  leds = led_patterns[direction_index];
  for (int pixel = 0; pixel < 10; pixel++) {
    if (pixel == leds[0] || pixel == leds[1]) {
      strip.setPixelColor(pixel, 4, 0, 0);
    } else {
      strip.setPixelColor(pixel, 0, 0, 0);
    }
  }
  strip.show();
```

The complete code is below:

https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/CPX_Compass/CPX_Compass.ino

# Circuit Playground Express Compass

## CircuitPython

![](https://cdn-learn.adafruit.com/assets/assets/000/063/409/medium800/express_circuitpython_blinka-small.png?1539287531)

We'll be using CircuitPython for this project. Are you new to using CircuitPython? No worries,&nbsp;[there is a full getting started guide here](https://learn.adafruit.com/welcome-to-circuitpython).

Adafruit suggests using the Mu editor to edit your code and have an interactive REPL in CircuitPython.&nbsp;[You can learn about Mu and its installation in this tutorial](https://learn.adafruit.com/welcome-to-circuitpython/installing-mu-editor).

In addition, the LSM303 module is required. We have a [great guide on that](https://learn.adafruit.com/adafruit-lis3dh-triple-axis-accelerometer-breakout). Make sure you have the latest version of this module.

# A Guided Tour

The `warm_up` function is used when starting up to make multiple reads from the magnetometer. Experience showed that the initial reads were unreliable; the magnetometer needs to warm up it would seem. The NeoPixels are set to blue during this phase.

```auto
def warm_up():
    fill(BLUE)
    for _ in range(100):
        _, _, _ = compass.magnetic
        time.sleep(0.010)
```

## Compass Calibration

The compass needs to be calibrated before use. This adapts it to the variation in the chip as well as the local magnetic environment.&nbsp; Simply spin the compass when the NeoPixels are green. If the compass acts erratically, pressing the left button (A) will do an additional calibration phase, which will hopefully improve the calibration. Be sure to spin it a couple full rotations for the widest range of values.

![](https://cdn-learn.adafruit.com/assets/assets/000/064/385/medium800/express_cp_calibration_screenshot.png?1540512447)

There are a few ways to run a calibration. If the compass has never been calibrated (the `raw_mins` array contains all 1000.0), it will be calibrated. Additionally, it will be done if the A/left button is pressed when the power is turned on or **reset** is pressed. In both these cases, it is assumed that you have a USB serial connection. When calibration completes, two lines are output, similar to:

```auto
raw_mins = [-2.45455, 2.81818]
raw_maxes = [-1.72727, 3.54545]
```

Copy these into the code, replacing the two that look the same (other than the values), and load onto the Circuit Playground Express. Subsequently powering on, resetting, or restarting will then skip calibration.

Calibration works by spending 10 seconds making readings, and keeping track of the lowest and highest values along the X and Y axes. At the end, the origin offset is calculated by finding the center point of the readings (averaging the minimum and maximum values). Now we have the offset for readings as well as the expected value ranges.

```auto
def calibrate(do_the_readings):
    values = [0.0, 0.0]
    start_time = time.monotonic()

    fill(GREEN)

    # Update the high and low extremes
    if do_the_readings:
        while time.monotonic() - start_time < 10.0:
            values[0], values[1], _ = compass.magnetic
            values[1] *= -1                           # accel is upside down, so y is reversed
            if values[0] != 0.0 and values[1] != 0.0: # ignore the random 0 values
                for i in range(2):
                    if values[i] < raw_mins[i]:
                        raw_mins[i] = values[i]
                    if values[i] > raw_maxes[i]:
                        raw_maxes[i] = values[i]

    # Recompute the correction and the correct mins/maxes
    for i in range(2):
        corrections[i] = (raw_maxes[i] + raw_mins[i]) / 2
        mins[i] = raw_mins[i] - corrections[i]
        maxes[i] = raw_maxes[i] - corrections[i]

    fill(BLACK)
```

The main loop runs about 20 times per second. It starts by checking for the left button being pushed. If it is, more calibration is done. Next the magnetometer values are read for X and Y.&nbsp;

```auto
    if not calibrate_button.value:
        calibrate(True)

    x, y, _ = compass.magnetic
    y = y * -1
```

Notice that the Y value is negated since the breakout is mounted upside down, flipping the Y axis.

Occasionally there will be a problem and the read values will both be zero. If so the reading is ignored.

```auto
    if x != 0.0 and y != 0.0:
```

Assuming the values are good, they are normalized. This is a simple mapping of the value from the range that resulted from calibration, to the range from -100 to +100.

```auto
def normalize(value, in_min, in_max):
    mapped = (value - in_min) * 200 / (in_max - in_min) + -100
    return max(min(mapped, 100), -100)
```

Once we have normalized values the `atan2` function is used to compute the angle of the vector made by those values. The angle will be in radians (ranging from -pi to +pi). That gets converted to degrees by multiplying by _180/pi_. Now we have a value in degrees that ranges from -180 to +180. That gets 180 added to it to give a value from 0 to 360. This is then divided by 30 to give the number of a wedge which corresponds to 1 of 10 NeoPixel positions. Because the wedge at the top is defined by the angles at +/-15 degrees, 15 is added (and the result clipped to 360 by using the modulus operator %) before the division.

```auto
        normalized_x = normalize(x - corrections[0], mins[0], maxes[0])
        normalized_y = normalize(y - corrections[1], mins[1], maxes[1])

        compass_heading = int(math.atan2(normalized_y, normalized_x) * 180.0 / math.pi)
        # compass_heading is between -180 and +180 since atan2 returns -pi to +pi
        # this translates it to be between 0 and 360
        compass_heading += 180

        direction_index = ((compass_heading + 15) % 360) // 30
```

The final step is to update the NeoPixels. The `led_patterns` array that is defined at the top of the code is used to specify which pixels correspond to each wedge. Notice that two of the wedges specify two pixels, while the others use only one. This is because the Circuit Playgrounds only have 10 NeoPixels; the top and bottom positions are used for the USB and battery connectors. To work around this, the two adjacent NeoPixels are used.

```auto
        pixels.fill(BLACK)
        for l in led_patterns[direction_index]:
            pixels[l] = RED
        pixels.show()
```

The complete code is below:

https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/CPX_Compass/code.py


## Guide Products

### Circuit Playground Express

[Circuit Playground Express](https://www.adafruit.com/product/3333)
 **Circuit Playground Express** is the next step towards a perfect introduction to electronics and programming. We've taken the original Circuit Playground Classic and made it even better! Not only did we pack even more sensors in, we also made it even easier to...

Out of Stock
[Buy Now](https://www.adafruit.com/product/3333)
[Related Guides to the Product](https://learn.adafruit.com/products/3333/guides)
### FLORA Accelerometer/Compass Sensor - LSM303

[FLORA Accelerometer/Compass Sensor - LSM303](https://www.adafruit.com/product/1247)
Add motion and direction sensing to your wearable FLORA project with this high precision 3-axis Accelerometer+Compass sensor. Inside are two sensors, one is a classic 3-axis accelerometer, which can tell you which direction is down towards the Earth (by measuring gravity) or how fast the board...

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/1247)
[Related Guides to the Product](https://learn.adafruit.com/products/1247/guides)
### JST PH 2-Pin Cable – Male Header 200mm

[JST PH 2-Pin Cable – Male Header 200mm](https://www.adafruit.com/product/3814)
For a really long time we assumed that the JST PH didn't have a free-hanging male header version. But then we found this **JST-PH 2-pin Male Cable,** and we were like,&nbsp;_this is perfect!_ It's not a genuine JST connector, but it's 100%...

In Stock
[Buy Now](https://www.adafruit.com/product/3814)
[Related Guides to the Product](https://learn.adafruit.com/products/3814/guides)
### JST PH 2-Pin Cable - Female Connector 100mm

[JST PH 2-Pin Cable - Female Connector 100mm](https://www.adafruit.com/product/261)
Red and black tinned wires with a 2-pin JST PH connector on the end. 4" / 100mm long. Matches up nicely with our Lipoly chargers!

[We have the socket 'mating' version of this cable](https://www.adafruit.com/product/3814) over here, <a...></a...>

In Stock
[Buy Now](https://www.adafruit.com/product/261)
[Related Guides to the Product](https://learn.adafruit.com/products/261/guides)
### Breadboard-friendly SPDT Slide Switch

[Breadboard-friendly SPDT Slide Switch](https://www.adafruit.com/product/805)
These nice switches are perfect for use with breadboard and perfboard projects. They have 0.1" spacing and snap in nicely into a solderless breadboard. They're easy to switch no matter what size fingers you have, but not so easy that they'll get flipped by accident. Work great as...

Out of Stock
[Buy Now](https://www.adafruit.com/product/805)
[Related Guides to the Product](https://learn.adafruit.com/products/805/guides)
### Lithium Ion Polymer Battery - 3.7v 150mAh

[Lithium Ion Polymer Battery - 3.7v 150mAh](https://www.adafruit.com/product/1317)
Lithium-ion polymer (also known as 'lipo' or 'lipoly') batteries are thin, light, and powerful. The output ranges from 4.2V when completely charged to 3.7V. This battery has a capacity of 150mAh for a total of about 0.6 Wh. If you need a larger battery, <a...></a...>

In Stock
[Buy Now](https://www.adafruit.com/product/1317)
[Related Guides to the Product](https://learn.adafruit.com/products/1317/guides)
### Silicone Cover Stranded-Core Wire - 2m 26AWG Blue

[Silicone Cover Stranded-Core Wire - 2m 26AWG Blue](https://www.adafruit.com/product/1878)
Silicone-sheathing wire is super-flexible and soft, and its also strong! Able to handle up to 200°C and up to 600V, it will do when PVC covered wire wimps out. We like this wire for being extremely supple and flexible, so it is great for wearables or projects where the wire-harness has to...

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

## Related Guides

- [Adafruit Circuit Playground Express](https://learn.adafruit.com/adafruit-circuit-playground-express.md)
- [HalloWing Light Paintstick](https://learn.adafruit.com/hallowing-light-paintstick.md)
- [Circuit Playground Express Sugar Glider](https://learn.adafruit.com/cpx-sugar-glider.md)
- [LED Noodle Shop Sign](https://learn.adafruit.com/led-noodle-shop-sign.md)
- [Thanksgiving Robotic Turkey Hand with Circuit Playground Express and Crickit](https://learn.adafruit.com/talking-turkey-hand.md)
- [Mount for CRICKIT](https://learn.adafruit.com/mount-for-crickit.md)
- [Machine Learning with Marshmallows and Tiny Sorter](https://learn.adafruit.com/machine-learning-with-marshmallows-and-tiny-sorter.md)
- [Makey Paper Craft ](https://learn.adafruit.com/makey-paper-craft.md)
- [How to Choose a Microcontroller](https://learn.adafruit.com/how-to-choose-a-microcontroller.md)
- [Making oscilloscope images with DACs](https://learn.adafruit.com/dac-oscilloscope-images.md)
- [Fiber Optic Whip](https://learn.adafruit.com/fiber-optic-whip.md)
- [Trash-Built Robotic Fish](https://learn.adafruit.com/trash-robo-fish.md)
- [A NeoPixel Pomodoro Timer](https://learn.adafruit.com/a-neopixel-pomodoro-timer.md)
- [Capacitive Touch Unicorn Horn](https://learn.adafruit.com/capacitive-touch-unicorn-horn.md)
- [Paper Airplane Launcher](https://learn.adafruit.com/paper-airplane-launcher-with-crickit.md)
- [Holiday Tree with Feather RP2040 Scorpio](https://learn.adafruit.com/holiday-tree-with-scorpio.md)
