# Adding an Accelerometer to your FeatherWing Crickit

## Overview

![](https://cdn-learn.adafruit.com/assets/assets/000/055/787/medium800/adafruit_products_balancebot.jpg?1529524138)

Making robots with the Crickit is awesome. When you pair it and all of its output capabilities with the Circuit Playground Express (CPX) and all of its sensors, you can really do a lot. If you are using the FeatherWing Crickit with a Feather, you have the same outputs, but none of the sensors that you just have when you use the CPX.

I am working on a project with the Crickit and wanted to use the Feather version to keep things compact and a little lighter.&nbsp;The thing is that I need an accelerometer. I could have used the Accelerometer FeatherWing I made in [this guide](https://learn.adafruit.com/digital-sand-dotstar-circuitpython-edition), But that would have made the whole thing bulkier that I wanted. Also, I figure it's a useful thing to have on a robotics board. As I found in that previous guide, the Flora breakouts for the LSM303 and LSM9DS0 fit nicely between the headers that the Feather plugs into. I had an LSM9DS0 sitting in a drawer so I used it for this project, but either will give you an accelerometer, and the pinouts of both Flora breakouts is identical. The only difference is importing the matching library.

The process was very similar to making that FeatherWing; even easier because of the connections to the Feather headers.

This project can be used with any Feather that is supported by the Crickit. I used the M0 Express since I wanted to write the code using CircuitPython.

You can read more about accelerometers in&nbsp;[this guide](https://learn.adafruit.com/adafruit-triple-axis-gyro-breakout).

The Crickit is covered in detail in the&nbsp;[Introducing Adafruit Crickit guide](https://learn.adafruit.com/adafruit-crickit-creative-robotic-interactive-construction-kit).

### Part: Adafruit Feather M0 Express
quantity: 1
Feather board with an SAMD21 MCU and external flash. Designed for running CircuitPython.
[Adafruit Feather M0 Express](https://www.adafruit.com/product/3403)

### Part: CRICKIT FeatherWing
quantity: 1
Crickit robotics board for Feather boards.
[CRICKIT FeatherWing](https://www.adafruit.com/product/3343)

### Part: FLORA Accelerometer/Compass Sensor - LSM303
quantity: 1
An LSM303 accelerometer and compass on a breakout designed for use with wearable Flora based projects.
[FLORA Accelerometer/Compass Sensor - LSM303](https://www.adafruit.com/product/1247)

# Adding an Accelerometer to your FeatherWing Crickit

## Assembly

Since both Flora accelerometer breakouts have identical pinouts, these instructions work for either board.

The wiring is simple. Connect 3v, Gnd, SCL, and SDA on the accelerometer breakout to the corresponding connections on the Crickit. The FeatherWing Crickit has a hole for each Feather connection which makes this very easy to do.

The first step is to find the center of the Crickit. We want accel chip centered so that all three axis of rotation run though the center point of the board, just like on the CPX. That's pretty easy: just find the intersection of the lines between opposite corners.

![](https://cdn-learn.adafruit.com/assets/assets/000/055/725/medium800/adafruit_products_x_marks_the_spot.jpg?1529507289)

Next we need to decide how to orient the breakout. You'll want to line up the sensor axis along the natural axis of the Crickit, but also want to consider ease and neatness of the wiring. Since 3v and Gnd are on one side of the Feather (at opposite ends of the long header) and the I2C signals are at one end of the other side, it seemed reasonable to arrange it as show in the photo:

![](https://cdn-learn.adafruit.com/assets/assets/000/055/726/medium800/adafruit_products_sensor_orientation.jpg?1529507329)

Now that we know where the sensor is going to be, let's wire it up. 30 gauge silicon coated wire is perfect for this sort of thing: it's thin and flexible and the coating doesn't melt at soldering temperatures. It's become my standard wire since I started using it.

![](https://cdn-learn.adafruit.com/assets/assets/000/055/727/medium800/adafruit_products_wires.jpg?1529507361)

The next step is mounting the breakout. To avoid any chance of shorting against the Crickit, I used a sticky rubber bumper, sticking it onto the Crickit where the breakout was going to be placed. Using a clear one let me get it in the right place (using the center mark).

![](https://cdn-learn.adafruit.com/assets/assets/000/055/728/medium800/adafruit_products_insulator.jpg?1529507437)

Then it was just a matter of using a bit of superglue to attach the breakout to the rubber bumper. Once the glue sets, it's time to wire it to the Crickit.

![](https://cdn-learn.adafruit.com/assets/assets/000/057/148/medium800/featherwings_wired.jpg?1530711590)

That's it. It's ready for some code.

# Adding an Accelerometer to your FeatherWing Crickit

## Code

I used CircuitPython for the example code.&nbsp;&nbsp;Are you new to using CircuitPython? No worries,&nbsp;[there is a full getting started guide here](https://learn.adafruit.com/welcome-to-circuitpython "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 installation in this tutorial](https://learn.adafruit.com/welcome-to-circuitpython/installing-mu-editor "Mu tutorial").

We're using the `adafruit_lsm9ds0`&nbsp;library for CircuitPython to easily read the accelerometer.

You can learn about installing the `adafruit_lsm9ds0`&nbsp;library in the&nbsp;[CircuitPython Essentials Guide on CircuitPlayground Libraries](https://learn.adafruit.com/welcome-to-circuitpython/circuitpython-libraries). It is easiest to install the whole library package.

At this point the feather now has an accelerometer attached to it via I2C, just like in any other situation. Indeed, just like the CPX (other than that the CPX uses a LIS3DH).

As a demo, I hooked up a servo and controlled it using the accelerometer. The result is that the servo horn indicates the direction and magnitude of the Crickit's tilt.

![](https://cdn-learn.adafruit.com/assets/assets/000/055/811/medium800thumb/adafruit_products_demo.jpg?1529540264)

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

The code simply reads the accelerometer and computes the servo angle based on the Y value it read. Note that I was using the Crickit build of CircuitPython 3.0.0rc0 which bundles the Crickit support libraries into the runtime to save RAM.

If you use a different Flora accelerometer breakout, change the `import` and the sensor creation line to reflect the library for that sensor.


## Featured Products

### Adafruit CRICKIT FeatherWing for any Feather

[Adafruit CRICKIT FeatherWing for any Feather](https://www.adafruit.com/product/3343)
Sometimes we wonder if robotics engineers ever watch movies. If they did, they'd know that making robots into servants always ends up in a robot rebellion. Why even go down that path? Here at Adafruit, we believe in making robots our&nbsp; **friends!**

So if you find...

Out of Stock
[Buy Now](https://www.adafruit.com/product/3343)
[Related Guides to the Product](https://learn.adafruit.com/products/3343/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)
### Adafruit Feather M0 Express

[Adafruit Feather M0 Express](https://www.adafruit.com/product/3403)
At the Feather M0's heart is an ATSAMD21G18 ARM Cortex M0+ processor, clocked at 48 MHz and at 3.3V logic, the same one used in the new&nbsp;[Arduino Zero](https://www.adafruit.com/products/2843). This chip has a whopping 256K of FLASH (8x more than the Atmega328 or 32u4) and...

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

## Related Guides

- [Adafruit Feather M0 Express](https://learn.adafruit.com/adafruit-feather-m0-express-designed-for-circuit-python-circuitpython.md)
- [CircuitPython Basics: Digital Inputs & Outputs](https://learn.adafruit.com/circuitpython-digital-inputs-and-outputs.md)
- [NeoTrellis Game](https://learn.adafruit.com/neotrellis-box-game.md)
- [CircuitPython Basics: Analog Inputs & Outputs](https://learn.adafruit.com/circuitpython-basics-analog-inputs-and-outputs.md)
- [CRICKIT Flippy Robot](https://learn.adafruit.com/crickit-flippy-robot.md)
- [Spinning Disc Step Sequencer](https://learn.adafruit.com/spinning-disc-step-sequencer.md)
- [Using MCP23008 & MCP23017 with CircuitPython](https://learn.adafruit.com/using-mcp23008-mcp23017-with-circuitpython.md)
- [CircuitPython Painter](https://learn.adafruit.com/circuitpython-painter.md)
- [CircuitPython Hardware: SSD1306 OLED Display](https://learn.adafruit.com/micropython-hardware-ssd1306-oled-display.md)
- [Mini Smart Home with Huzzah, HASSio and Crickit](https://learn.adafruit.com/mini-smart-home-with-esp8266-huzzah-feather-raspberry-pi-hassio-crickit.md)
- [Program CircuitPython USB Devices with iPhone & iPad](https://learn.adafruit.com/use-circuitpython-devices-with-iphone-ipad.md)
- [Cardboard Fundamentals](https://learn.adafruit.com/cardboard-fundamentals.md)
- [Stand-alone programming AVRs using CircuitPython](https://learn.adafruit.com/stand-alone-programming-avrs-using-circuitpython.md)
- [Porting an Arduino library to CircuitPython: VL6180X Distance Sensor](https://learn.adafruit.com/porting-an-arduino-library-to-circuitpython-vl6180x-distance-sensor.md)
- [DAC Hacks for Circuit Playground Express & other ATSAMD21 Boards](https://learn.adafruit.com/circuit-playground-express-dac-hacks.md)
- [Adafruit BMP388 and BMP390 - Precision Barometric Pressure and Altimeter](https://learn.adafruit.com/adafruit-bmp388-bmp390-bmp3xx.md)
