# Citi Bike Helmet

## Overview

https://www.youtube.com/watch?v=EuaouqKbbz0

Improve your visibility with style! Mod up this bike helmet with LED strip, a FLORA GPS, and find your way to the nearest Citi Bike station with ease. We used a Carrera foldable helmet, which has grooves between the protection, perfect for NeoPixel strip.  
  
Before you begin this project, we recommend reading the following guides:

- [Getting Started with FLORA](http://learn.adafruit.com/getting-started-with-flora)
- [FLORA GPS](http://learn.adafruit.com/flora-wearable-gps)
- [FLORA Accelerometer/compass](http://learn.adafruit.com/flora-accelerometer)  

Info: 

![](https://cdn-learn.adafruit.com/assets/assets/000/009/098/medium800/flora_DSC_1450.jpg?1396882614)

![](https://cdn-learn.adafruit.com/assets/assets/000/009/097/medium800/flora_Screen_Shot_2013-06-16_at_5.35.00_PM.png?1396882583)

This project was created in collaboration with Tyler Cooper & Justin Cooper, with major video help from Risa Rose and JM Imbrescia.

![](https://cdn-learn.adafruit.com/assets/assets/000/009/096/medium800/flora_Screen_Shot_2013-06-16_at_5.32.10_PM.png?1396882510)

![](https://cdn-learn.adafruit.com/assets/assets/000/009/100/medium800/flora_Screen_Shot_2013-06-16_at_6.13.33_PM.png?1396883030)

![](https://cdn-learn.adafruit.com/assets/assets/000/009/099/medium800thumb/flora_helmet.jpg?1448311124)

![](https://cdn-learn.adafruit.com/assets/assets/000/009/095/medium800thumb/flora_citibike-helmet.jpg?1448311120)

# Citi Bike Helmet

## Tools & Supplies

![](https://cdn-learn.adafruit.com/assets/assets/000/009/129/medium800/flora_Screen_Shot_2013-06-19_at_8.41.57_AM.png?1396883770)

For this project, gather up:

- [Carrera foldable helmet](http://carreraworld.com/us/editorials/foldable-helmet/) (we had to [order ours from the UK](http://www.leisurelakesbikes.com/p/10186/carrera-e00414-foldable-helmet-with-rear-light))
- [NeoPixel strip](http://www.adafruit.com/products/1376) (about 1.5m)
- [FLORA main board](http://www.adafruit.com/products/659)
- [FLORA LSM303 accelerometer/compass](http://www.adafruit.com/products/1247 "Link: http://www.adafruit.com/products/1247")
- [FLORA Ultimate GPS](http://www.adafruit.com/products/1059 "Link: http://www.adafruit.com/products/1059")
- Rechargeable [lithium polymer battery](http://www.adafruit.com/products/258 "Link: http://www.adafruit.com/products/258") and [charger](http://www.adafruit.com/products/1304)
- [coincell battery](http://www.adafruit.com/products/654 "Link: http://www.adafruit.com/products/654") and [holder](http://www.adafruit.com/products/653) (optional to improve GPS fix time)
- Needle and clear thread
- Scissors

Any entry level 'all-in-one' soldering iron that you might find at your local hardware store should work. As with most things in life, you get what you pay for.   
Upgrading to a higher end soldering iron setup, like the [Hakko FX-888 that we stock in our store](http://adafruit.com/products/180), will make soldering fun and easy.   
<u><br>Do not use a "ColdHeat" soldering iron</u>! They are not suitable for delicate electronics work and can damage the Flora ([see here](http://www.epemag.wimborne.co.uk/cold-soldering2.htm "Link: http://www.epemag.wimborne.co.uk/cold-soldering2.htm")).   
  
[Click here to buy our entry level adjustable 30W 110V soldering iron.](http://adafruit.com/products/180 "Link: http://adafruit.com/products/180")   
  
[Click here to upgrade to a Genuine Hakko FX-888 adjustable temperature soldering iron.](http://adafruit.com/products/303 "Link: http://adafruit.com/products/303")   
  
[Learn how to solder with tons of tutorials!](http://learn.adafruit.com/adafruit-guide-excellent-soldering)

![flora_hakko-soldering-iron.jpg](https://cdn-learn.adafruit.com/assets/assets/000/009/130/medium640/flora_hakko-soldering-iron.jpg?1396883679)

![flora_simple-soldering-iron.jpg](https://cdn-learn.adafruit.com/assets/assets/000/009/131/medium640/flora_simple-soldering-iron.jpg?1396883780)

You will want rosin core, 60/40 solder. Good solder is a good thing. Bad solder leads to bridging and cold solder joints which can be tough to find.  
  
[Click here to buy a spool of leaded solder (recommended for beginners).](http://adafruit.com/products/145)  
  
[Click here to buy a spool of lead-free solder.](http://adafruit.com/products/734)

![flora_solder.jpg](https://cdn-learn.adafruit.com/assets/assets/000/009/132/medium640/flora_solder.jpg?1396883791)

You will need a good quality basic multimeter that can measure voltage and continuity.  
  
[Click here to buy a basic multimeter.](http://adafruit.com/products/71)  
  
[Click here to buy a top of the line multimeter.](http://adafruit.com/products/308)  
  
[Click here to buy a pocket multimeter.](http://adafruit.com/products/850)  
  
[Don't forget to learn how to use your multimeter too!](http://learn.adafruit.com/multimeters "Link: http://learn.adafruit.com/multimeters")

![flora_multimeter.jpg](https://cdn-learn.adafruit.com/assets/assets/000/009/134/medium640/flora_multimeter.jpg?1396883810)

Don't forget your [wire strippers](https://www.adafruit.com/products/527), [pliers](https://www.adafruit.com/products/146), and [flush snips](https://www.adafruit.com/products/152)!

![flora_wire-strippers.jpg](https://cdn-learn.adafruit.com/assets/assets/000/009/135/medium640/flora_wire-strippers.jpg?1396883825)

![flora_snips.jpg](https://cdn-learn.adafruit.com/assets/assets/000/009/136/medium640/flora_snips.jpg?1396883835)

# Citi Bike Helmet

## Wiring Diagram

![](https://cdn-learn.adafruit.com/assets/assets/000/009/137/medium800/flora_citi-bike-helmet-diagram.jpg?1396883852)

# Citi Bike Helmet

## Build Circuit

Wrap a long piece of NeoPixel strip throughout the grooves in the [Carrera "foldable" helmet](http://carreraworld.com/us/editorials/foldable-helmet/). Start at one back edge, shifting the strip so that four LEDs are visible to the rider along the front brim.  
  
Cut the strip to length at the opposite back edge and tack the LED strip to the nylon webbing in the grooves of the helmet with a needle and clear thread. We didn't affix to every piece of webbing, just in enough spots to secure the LED strip.

![flora_citibike-helmet-00.jpg](https://cdn-learn.adafruit.com/assets/assets/000/008/917/medium640/flora_citibike-helmet-00.jpg?1396878617)

![flora_citibike-helmet-01.jpg](https://cdn-learn.adafruit.com/assets/assets/000/008/918/medium640/flora_citibike-helmet-01.jpg?1396878647)

![flora_citibike-helmet-02.jpg](https://cdn-learn.adafruit.com/assets/assets/000/008/919/medium640/flora_citibike-helmet-02.jpg?1396878672)

![flora_citibike-helmet-03.jpg](https://cdn-learn.adafruit.com/assets/assets/000/008/920/medium640/flora_citibike-helmet-03.jpg?1396878703)

![flora_citibike-helmet-04a.jpg](https://cdn-learn.adafruit.com/assets/assets/000/008/921/medium640/flora_citibike-helmet-04a.jpg?1396878729)

![flora_citibike-helmet-04b.jpg](https://cdn-learn.adafruit.com/assets/assets/000/008/922/medium640/flora_citibike-helmet-04b.jpg?1396878748)

Info: 

Using a needle and more clear thread, affix the FLORA main board to the back head brace of the helmet through two unused pins (we used the 3.3v pad next to the USB port and the GND pad next to the JST connector).  
  
Strip and tin three wires, then solder them to the input side of the LED strip.  
  
Cut to length, strip and solder these wires to VBATT, D6, and GND, referring to the wiring diagram on the previous page if necessary.

![flora_citibike-helmet-05.jpg](https://cdn-learn.adafruit.com/assets/assets/000/008/923/medium640/flora_citibike-helmet-05.jpg?1396878778)

![flora_citibike-helmet-06.jpg](https://cdn-learn.adafruit.com/assets/assets/000/008/924/medium640/flora_citibike-helmet-06.jpg?1396878795)

![flora_citibike-helmet-07.jpg](https://cdn-learn.adafruit.com/assets/assets/000/008/925/medium640/flora_citibike-helmet-07.jpg?1396878822)

![flora_citibike-helmet-08.jpg](https://cdn-learn.adafruit.com/assets/assets/000/008/926/medium640/flora_citibike-helmet-08.jpg?1396878853)

Solder small flexible wires to the LSM303 accelerometer/compass module, then apply a small piece of Sugru to cover the back of the module. Stick it in the middle of the FLORA main board, making sure not to cover the on/off switch or reset button. We are making a circuit sandwich!  
  
Solder the wires to 3.3v, SCL, SDA, and GND on FLORA, referring again to the wiring diagram.

![flora_citibike-helmet-09.jpg](https://cdn-learn.adafruit.com/assets/assets/000/008/963/medium640/flora_citibike-helmet-09.jpg?1396880010)

![flora_citibike-helmet-10.jpg](https://cdn-learn.adafruit.com/assets/assets/000/008/964/medium640/flora_citibike-helmet-10.jpg?1396880042)

![flora_citibike-helmet-11.jpg](https://cdn-learn.adafruit.com/assets/assets/000/008/968/medium640/flora_citibike-helmet-11.jpg?1396880120)

![flora_citibike-helmet-11a.jpg](https://cdn-learn.adafruit.com/assets/assets/000/008/969/medium640/flora_citibike-helmet-11a.jpg?1396880146)

Repeat the process above with the GPS module, connecting corresponding TX/RX pads to FLORA (remember that TX goes to RX and RX goes to TX).  
  
Sugru insulates the back of the GPS module from the LSM303 and FLORA main board, and also provides a semipermanent sticky situation. The silicone is not quite an adhesive, though it will remain affixed unless you choose to carefully peel it off.  
  
The lithium polymer battery slides behind the elastic of the head brace. We sewed a small fabric pouch around the battery, which in turn was stitched to the elastic.

![flora_citibike-helmet-13.jpg](https://cdn-learn.adafruit.com/assets/assets/000/008/934/medium640/flora_citibike-helmet-13.jpg?1396879047)

![flora_citibike-helmet-13a.jpg](https://cdn-learn.adafruit.com/assets/assets/000/008/935/medium640/flora_citibike-helmet-13a.jpg?1396879069)

![flora_citibike-helmet-14.jpg](https://cdn-learn.adafruit.com/assets/assets/000/008/936/medium640/flora_citibike-helmet-14.jpg?1396879098)

![flora_citibike-helmet-15.jpg](https://cdn-learn.adafruit.com/assets/assets/000/008/937/medium640/flora_citibike-helmet-15.jpg?1396879122)

# Citi Bike Helmet

## Program it

The Citi Bike Helmet code takes the FLORA to the limit. The code is used to drive LEDs, the FLORA GPS module, and the FLORA compass/accelerometer module. It looks at a long list of all Citi bike sharing stations in NYC (over 300!) and determines which coordinate is closest to you. It then uses the GPS module, and the compass module to navigate you there. The code is located in [this GitHub repo](https://github.com/adafruit/Adafruit_Learning_System_Guides/tree/main/Flora/Flora_Citi_Bike_Helmet). Click the button below to download the code.

[Download the Citi Bike Helmet Arduino Sketch](https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/Flora/Flora_Citi_Bike_Helmet/Citi_Bike_Helmet/Citi_Bike_Helmet.ino)
This code example requires the following Arduino libraries, located in the Arduino Library Manager and in GitHub as follows:

- Adafruit GPS library which can be downloaded from [https://github.com/adafruit/Adafruit-GPS-Library](https://github.com/adafruit/Adafruit-GPS-Library "Link: https://github.com/adafruit/Adafruit-GPS-Library")
- Adafruit NeoPixel library which can be downloaded from [https://github.com/adafruit/Adafruit\_NeoPixel](https://github.com/adafruit/Adafruit_NeoPixel "Link: https://github.com/adafruit/Adafruit\_NeoPixel")
- Pololu LSM303 library which can be downloaded from [https://github.com/pololu/LSM303](https://github.com/pololu/LSM303 "Link: https://github.com/pololu/LSM303")

[Learn how to install libraries here](http://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use).

https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/Flora/Flora_Citi_Bike_Helmet/Citi_Bike_Helmet/Citi_Bike_Helmet.ino

Right near the top of the sketch, you are going to see a long list of GPS coordinates that look like this:

```auto
float lat_lon[LAT_LON_SIZE][2] PROGMEM = {
  {40.767272, -73.993928},
  {40.719115, -74.006666},
  {40.711174, -74.000165},
```

These coordinates were copied and pasted using a bit of node.js ([learn more here](http://learn.adafruit.com/citi-bike-helmet/optional-generating-coordinates)). This also means that if you live in a city other than NYC that has a bike sharing program, you can use our code to get your own list of coordinates. If you live in NYC, all of the current bike share stations are loaded into the sketch.

The next piece of important code is this:

```auto
// Change the first # to match the # of LEDs in your strip -- we have 45 LEDs
Adafruit_NeoPixel strip = Adafruit_NeoPixel(45, 6, NEO_GRB + NEO_KHZ800);

int FarRight = 9;
int CenterRight = 10;
int CenterLeft = 34;
int FarLeft = 35;
int HeadsUp[] = {35, 34, 10, 9};
int RightStrip[] = {8, 7, 6, 5, 4, 3, 2, 1, 0};
int RightCenterStrip[] = {11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21};
int LeftCenterStrip[] = {33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23};
int LeftStrip[] = {36, 37, 38, 39, 40, 41, 42, 43, 44};
int counter = 0;
```

This is where we set up which LEDs on our helmet are used. This will likely need to be updated to fit your own bike helmet project. [Learn more about how the FLORA NeoPixels work here](http://learn.adafruit.com/flora-rgb-smart-pixels/ "Link: http://learn.adafruit.com/flora-rgb-smart-pixels/").  
  
In the setup function, you will find a section that deals with calibrating the FLORA compass module.

```auto
// Calibration values. Use the Calibrate example program to get the values for
// your compass.
  compass.m_min.x = -581; compass.m_min.y = -731; compass.m_min.z = -1097;
  compass.m_max.x = +615; compass.m_max.y = +470; compass.m_max.z = 505;
```

Included with the Pololu LSM303 library is a little sketch that will get you these values. Run the sketch and view the serial monitor. Then tilt your helmet/sensor in every possible direction. When done, dump the values in the serial monitor into the above bit of code (replacing our values).  
  
Thats about all you need to know to get started. Upload the code to your FLORA, and you are ready to hit the road.

To test out your animations inside, try the following code that reacts to just the compass:

```auto
#include &lt;Adafruit_NeoPixel.h&gt;
#include &lt;LSM303.h&gt;
// Test code for Adafruit Flora GPS modules
//
// This code shows how to listen to the GPS module in an interrupt
// which allows the program to have more 'freedom' - just parse
// when a new NMEA sentence is available! Then access data when
// desired.
//
// Tested and works great with the Adafruit Flora GPS module
//    ------&gt; http://adafruit.com/products/1059
// Pick one up today at the Adafruit electronics shop 
// and help support open source hardware &amp; software! -ada

Adafruit_NeoPixel strip = Adafruit_NeoPixel(45, 6, NEO_GRB + NEO_KHZ800);
int FarRight = 9;
int CenterRight = 10;
int CenterLeft = 34;
int FarLeft = 35;
int HeadsUp[] = {35, 34, 10, 9};
int RightStrip[] = {46, 8, 7, 6, 5, 4, 3, 2, 1, 0, 46};
int RightCenterStrip[] = {11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21};
int LeftCenterStrip[] = {33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23};
int LeftStrip[] = {46, 36, 37, 38, 39, 40, 41, 42, 43, 44, 46};
int counter = 256*5;

#include &lt;Wire.h&gt;
#include &lt;LSM303.h&gt;

LSM303 compass;

void setup() {
  Serial.begin(9600);
  Wire.begin();
  compass.init();
  compass.enableDefault();
  
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
  
  // Calibration values. Use the Calibrate example program to get the values for
  // your compass. M min X: -561 Y: -679 Z: -558 M max X: 232 Y: 109 Z: 224
  compass.m_min.x = -561; compass.m_min.y = -679; compass.m_min.z = -558;
  compass.m_max.x = 232; compass.m_max.y = 109; compass.m_max.z = 224;
}

void loop() {
  compass.read();
  int heading = compass.heading((LSM303::vector){0,-1,0});
  
  //Use this part of the code to determine which way you need to go.
  if ((heading &gt; 348.75)||(heading &lt; 11.25)) {
    Serial.println("  N");
    //Serial.println("Forward");
    GoForward(strip.Color(0, 51, 20), strip.Color(255, 255, 0), 200);

  }
  
  if ((heading &gt;= 11.25)&amp;&amp;(heading &lt; 33.75)) {
    Serial.println("NNE");
    //Serial.println("Go Left");
    GoForward(strip.Color(0, 51, 10), strip.Color(255, 255, 0), 200);
  }  
  
  if ((heading &gt;= 33.75)&amp;&amp;(heading &lt; 56.25)) {
    Serial.println(" NE");
    //Serial.println("Go Left");
    TurnLeft(strip.Color(11, 79, 0), strip.Color(255, 255, 0), 200);
  }
  
  if ((heading &gt;= 56.25)&amp;&amp;(heading &lt; 78.75)) {
    Serial.println("ENE");
    //Serial.println("Go Left");
    TurnLeft(strip.Color(39, 79, 0), strip.Color(255, 255, 0), 200);
  }
  
  if ((heading &gt;= 78.75)&amp;&amp;(heading &lt; 101.25)) {
    Serial.println("  E");
    //Serial.println("Go Left");
    TurnLeft(strip.Color(74, 79, 0), strip.Color(255, 255, 0), 200);
  }
  
  if ((heading &gt;= 101.25)&amp;&amp;(heading &lt; 123.75)) {
    Serial.println("ESE");
    //Serial.println("Go Left");
    TurnLeft(strip.Color(74, 79, 0), strip.Color(255, 255, 0), 200);
  }
  
  if ((heading &gt;= 123.75)&amp;&amp;(heading &lt; 146.25)) {
    Serial.println(" SE");
    //Serial.println("Go Left");
    TurnLeft(strip.Color(79, 61, 0), strip.Color(255, 255, 0), 200);
  }
  
  if ((heading &gt;= 146.25)&amp;&amp;(heading &lt; 168.75)) {
    Serial.println("SSE");
    //Serial.println("Go Left");
    TurnAround(strip.Color(79, 61, 0), strip.Color(255, 255, 0), 200);
  }
  
  if ((heading &gt;= 168.75)&amp;&amp;(heading &lt; 191.25)) {
    Serial.println("  S");
    //Serial.println("Turn Around");
    TurnAround(strip.Color(79, 32, 0), strip.Color(255, 255, 0), 200);
  }
  
  if ((heading &gt;= 191.25)&amp;&amp;(heading &lt; 213.75)) {
    Serial.println("SSW");
    //Serial.println("Go Right");
    TurnAround(strip.Color(79, 61, 0), strip.Color(255, 255, 0), 200);
  }
  
  if ((heading &gt;= 213.75)&amp;&amp;(heading &lt; 236.25)) {
    Serial.println(" SW");
    //Serial.println("Go Right");
    TurnRight(strip.Color(79, 61, 0), strip.Color(255, 255, 0), 200);
  }
  
  if ((heading &gt;= 236.25)&amp;&amp;(heading &lt; 258.75)) {
    Serial.println("WSW");
    //Serial.println("Go Right");
    TurnRight(strip.Color(74, 79, 0), strip.Color(255, 255, 0), 200);
  }
  
  if ((heading &gt;= 258.75)&amp;&amp;(heading &lt; 281.25)) {
    Serial.println("  W");
    //Serial.println("Go Right");
    TurnRight(strip.Color(74, 79, 0), strip.Color(255, 255, 0), 200);
  }
  
  if ((heading &gt;= 281.25)&amp;&amp;(heading &lt; 303.75)) {
    Serial.println("WNW");
    //Serial.println("Go Right");
  TurnRight(strip.Color(39, 79, 0), strip.Color(255, 255, 0), 200);
  }
  
  if ((heading &gt;= 303.75)&amp;&amp;(heading &lt; 326.25)) {
    Serial.println(" NW");
    //Serial.println("Go Right");
    TurnRight(strip.Color(11, 79, 0), strip.Color(255, 255, 0), 200);
  }
  
  if ((heading &gt;= 326.25)&amp;&amp;(heading &lt; 348.75)) {
    Serial.println("NWN");
    //Serial.println("Go Right");
    GoForward(strip.Color(0, 51, 10), strip.Color(255, 255, 0), 200);
  }
}

void TurnLeft (uint32_t c, uint32_t stripe, uint8_t wait) {
  strip.setPixelColor(CenterRight, 0);
  strip.setPixelColor(CenterLeft, 0);
  strip.setPixelColor(FarLeft, c);
      strip.show();
      for(uint16_t i=0; i&lt;11; i++) {
      strip.setPixelColor(LeftCenterStrip[i], strip.Color(0, 0, 0));
      strip.setPixelColor(LeftStrip[i], strip.Color(0, 0, 0));
      strip.show();
      delay(30);
      }
      //delay(wait);
  strip.setPixelColor(FarLeft, 0);
  strip.show();
     colorWipe(stripe, 30);
      //delay(wait);
}

void TurnRight (uint32_t c, uint32_t stripe, uint8_t wait) {
  strip.setPixelColor(CenterRight, 0);
  strip.setPixelColor(CenterLeft, 0);
  strip.setPixelColor(FarRight, c);
      strip.show();
      for(uint16_t i=0; i&lt;11; i++) {
      strip.setPixelColor(RightCenterStrip[i], strip.Color(0, 0, 0));
      strip.setPixelColor(RightStrip[i], strip.Color(0, 0, 0));
      strip.show();
      delay(30);
  }
      //delay(wait);
  strip.setPixelColor(FarRight, 0);
  strip.show();
      colorWipe(stripe, 30);
      //delay(wait);
}

void TurnAround (uint32_t c, uint32_t stripe, uint8_t wait) {
  strip.setPixelColor(CenterRight, c);
  strip.setPixelColor(CenterLeft, c);
      strip.show();
      for(uint16_t i=0; i&lt;11; i++) {
      strip.setPixelColor(LeftCenterStrip[i], strip.Color(0, 0, 0));
      strip.setPixelColor(RightCenterStrip[i], strip.Color(0, 0, 0));
      strip.show();
      delay(30);
  }
      //delay(wait);
  strip.setPixelColor(CenterRight, 0);
  strip.setPixelColor(CenterLeft, 0);
  strip.show();
      colorWipe(stripe, 30);
      //delay(wait);
      
}

void GoForward (uint32_t c, uint32_t stripe, uint8_t wait) {
  strip.setPixelColor(CenterRight, c);
  strip.setPixelColor(CenterLeft, c);
      strip.show();
      for(uint16_t i=0; i&lt;11; i++) {
      strip.setPixelColor(LeftCenterStrip[i], strip.Color(0, 0, 0));
      strip.setPixelColor(RightCenterStrip[i], strip.Color(0, 0, 0));
      strip.show();
      delay(30);
  }
      colorWipe(stripe, 30);
      //delay(wait);
}

// Slightly different, this makes the rainbow equally distributed throughout
void colorWipe(uint32_t c, uint8_t wait) {
for(uint16_t i=0; i&lt;11; i++) {
      strip.setPixelColor(LeftCenterStrip[i], strip.Color(255, 255/i^16, 255/i^16));
      strip.setPixelColor(RightCenterStrip[i], strip.Color(255, 255/i^16, 255/i^16));
      strip.setPixelColor(RightStrip[i], strip.Color(255, 255/i^16, 255/i^16));
      strip.setPixelColor(LeftStrip[i], strip.Color(255, 255/i^16, 255/i^16));
      strip.show();
      delay(wait);
  }
}


// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
  if(WheelPos &lt; 85) {
   return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
  } else if(WheelPos &lt; 170) {
   WheelPos -= 85;
   return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  } else {
   WheelPos -= 170;
   return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
}
```

# Citi Bike Helmet

## Wear it!

![](https://cdn-learn.adafruit.com/assets/assets/000/009/138/medium800/flora_jm-imbrescia-citi-bike-helmet-adafruit-front.png?1396883984)

The sample code uses the LEDs at the right and left edge of the helmet's brim to signal you to turn, and uses the two LEDs in the center of your forehead to tell you "go forward" (solid blue) or "turn around" (blinking red). Customize to your own navigation style!

![](https://cdn-learn.adafruit.com/assets/assets/000/009/139/medium800/flora_jm-imbrescia-citi-bike-helmet-adafruit-back.jpg?1396884013)

Info: 

# Citi Bike Helmet

## Optional: Generating Coordinates

You may need to re-generate the coordinates for the bike stations from time to time, and this page will show you how to do that.  
  
Another reason you may want to re-generate coordinates is so you can use the bike share system in your city with the helmet! It isn't limited to the NYC Citi Bike system.  
  
The below code will parse the wonderful [citybik.es api](http://api.citybik.es/):

https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/Flora/Flora_Citi_Bike_Helmet/citybikes_parser/parser.js

Let's not get too far ahead of ourselves though. First, we need to install the dependencies to run that code.  
  
To start with, you'll need node.js. It's a really easy install. Navigate to [http://nodejs.org](http://nodejs.org), and follow the installation instructions for your operating system (Windows, Linux, and OS X are supported).  
  
Next, create a folder somewhere (mine is titled 'cityparser'). Then, create a file in that folder titled parser.js and copy and paste the above snippet of code into that file, and save it.  
  
Now, open your favorite command line utility (Terminal.app, cmd.exe, etc) and navigate into the 'cityparser' folder.  
  
Now, we need to install the one dependency that is required for the parser to run. Execute the following from within the cityparser folder:

```auto
npm install request
```

Now that you have request installed, you can (finally!) run the parser to generate the locations for your particular city bike share program.  
  
Execute the following command to run the parser:

```auto
node parser.js
```

Great! It should have output a bunch of coordinates with a count at the end of it.  
  
For example, these are the last few of my output:

```auto
  {40.715348, -73.960241},
  {40.741472, -73.983209},
  {40.736502, -73.978094},
  {40.744449, -73.983035},
  {40.702550, -73.989402},
  {40.698920, -73.973329},
  {40.716887, -73.963198},
  {40.734160, -73.980242},
  {40.725500, -74.004451},
  {40.705311, -73.971000},
  {40.765909, -73.976341}
311
```

If your output is similar to the above, you'll now want to choose the correct BIKE\_SHARE\_URL for your city (NYC pre-loaded).  
  
Open the [citybik.es api](http://api.citybik.es/) page, and scroll down to the section titled "System" and "JSON". Choose your location from the dropdown, and then replace it in the parser.js file variable "BIKE\_SHARE\_URL" and re-run the program.  
  
Ok, now to set up your sketch. The last number in the results is the count of locations in that bike share. Take that number and place it in the sketch for the size of the array:

```auto
#define LAT_LON_SIZE 311
```

Then, copy and paste all of the locations (not the number), and replace the existing locations in the Bike Helmet Sketch. It should look something like this:

```auto
float lat_lon[LAT_LON_SIZE][2] PROGMEM = {
  {40.767272, -73.993928},
  {40.719115, -74.006666},
  {40.711174, -74.000165},
  {40.683826, -73.976323},
  {40.702550, -73.989402},
  {40.698920, -73.973329},
  {40.716887, -73.963198},
  {40.734160, -73.980242},
  {40.725500, -74.004451},
  {40.705311, -73.971000},
  {40.765909, -73.976341}
};
```

Now, compile your sketch, upload it, and start biking!


## Featured Products

### FLORA - Wearable electronic platform: Arduino-compatible

[FLORA - Wearable electronic platform: Arduino-compatible](https://www.adafruit.com/product/659)
FLORA is Adafruit's fully-featured wearable electronics platform. It's a round, sewable, Arduino-compatible microcontroller designed to empower amazing wearables projects.FLORA comes with Adafruit's support, [tutorials and...](http://learn.adafruit.com/category/flora)

In Stock
[Buy Now](https://www.adafruit.com/product/659)
[Related Guides to the Product](https://learn.adafruit.com/products/659/guides)
### Flora Wearable Ultimate GPS Module

[Flora Wearable Ultimate GPS Module](https://www.adafruit.com/product/1059)
This module is the best way to add a GPS to your wearable project. It's part of the Adafruit Flora series of wearable electronics, designed specifically for use with the Flora motherboard. Installed on the PCB is the latest of our Ultimate GPS modules, a small, super-thin, low-power GPS...

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/1059)
[Related Guides to the Product](https://learn.adafruit.com/products/1059/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 NeoPixel Digital RGB LED Strip - White 30 LED

[Adafruit NeoPixel Digital RGB LED Strip - White 30 LED](https://www.adafruit.com/product/1376)
You thought it couldn't get better than [our world-famous 32-LED-per-meter Digital LED strip](http://adafruit.com/products/306) but we will prove you wrong! These NeoPixel strips have 30 digitally-addressable pixel LEDs per meter and are very affordable and are only 12.5 mm...

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

[Lithium Ion Polymer Battery - 3.7v 1200mAh](https://www.adafruit.com/product/258)
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 1200mAh for a total of about 4.5 Wh. If you need a larger battery, <a...></a...>

In Stock
[Buy Now](https://www.adafruit.com/product/258)
[Related Guides to the Product](https://learn.adafruit.com/products/258/guides)
### Adafruit Micro Lipo - USB LiIon/LiPoly charger

[Adafruit Micro Lipo - USB LiIon/LiPoly charger](https://www.adafruit.com/product/1304)
Oh so adorable, this is the tiniest little lipo charger, so handy you can keep it any project box! Its also easy to use. Simply plug in the gold plated contacts into any USB port and a 3.7V/4.2V lithium polymer or lithium ion rechargeable battery into the JST plug on the other end. There are...

In Stock
[Buy Now](https://www.adafruit.com/product/1304)
[Related Guides to the Product](https://learn.adafruit.com/products/1304/guides)
### Sewable CR2032 Battery Holder

[Sewable CR2032 Battery Holder](https://www.adafruit.com/product/653)
This battery holder is by far the easiest way to add a battery to a small wearable project. By coincidence, there are two small 1mm diameter holes in the metal connection tabs, just large enough for a #5 or smaller needle to pass through. One tab connects to common ground (negative) and the...

In Stock
[Buy Now](https://www.adafruit.com/product/653)
[Related Guides to the Product](https://learn.adafruit.com/products/653/guides)
### CR2032 Lithium Coin Cell Battery

[CR2032 Lithium Coin Cell Battery](https://www.adafruit.com/product/654)
A perfect match for our [sew-able coin cell holder](http://www.adafruit.com/products/653). This non-rechargeable coin cell is CR2032 sized: 20mm diameter, 3.2mm thick. It has a nominal voltage output of 3V (although it starts a little high at 3.2V and slowly drifts down to 2.5V as...

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

## Related Guides

- [NeoPixel NanoRing](https://learn.adafruit.com/neopixel-nanoring-gemma.md)
- [Crystal Glow Knuckles](https://learn.adafruit.com/crystal-glow-knuckles.md)
- [Laser Dog Goggles](https://learn.adafruit.com/laser-dog-goggles.md)
- [FLORAbrella](https://learn.adafruit.com/florabrella.md)
- [Wearable Piezo Tones with Flora](https://learn.adafruit.com/wearable-piezo-tones-with-flora.md)
- [Chameleon Scarf](https://learn.adafruit.com/chameleon-scarf.md)
- [CircuitPython Connected Weather Cloud Lamp](https://learn.adafruit.com/circuitpython-connected-weather-cloud.md)
- [Kaleidoscope Eyes (Trinket-Powered NeoPixel LED Ring Goggles)](https://learn.adafruit.com/kaleidoscope-eyes-neopixel-led-goggles-trinket-gemma.md)
- [Bunny Ears with MakeCode](https://learn.adafruit.com/bunny-ears-with-makecode.md)
- [Make a Snow Globe with Circuit Playground Express & MakeCode](https://learn.adafruit.com/make-a-snowglobe-with-circuit-playground-makecode.md)
- [STEAM-Punk Goggles](https://learn.adafruit.com/steam-punk-goggles.md)
- [Mailbox Notification Service](https://learn.adafruit.com/mailbox-notification-service.md)
- [Charger Charm - 3D Printed holder for Micro LiPo USB Charger](https://learn.adafruit.com/usb-charger-charm-3d-printed-holder-for-micr-lipo-usb-charger.md)
- [ISS Pin](https://learn.adafruit.com/iss-pin.md)
- [Techno-Tiki RGB LED Torch](https://learn.adafruit.com/techno-tiki-rgb-led-torch.md)
