Lilypad bike jacket signal indicator

Before I started to work on Smart Turn signal indicator, I built another signal indicator jacket using a Lilypad Arduino and a Lilypad accelerometer. That was almost three years ago, but since then I have received quite a few inquiries about how it works. So I am going to give a quick overview about it in this post.

In case you didn’t come here after watching my youtube video, then here it is:

This jacket uses an accelerometer to detect the position of the hand, and activates the correct signal light. The accelerometer is attached to a glove, which is worn on the left hand. I used a Lilypad accelerometer because it can be sewn to the glove using conductive thread. Conductive thread is more flexible and lighter than wire. The Lilypad accelerometer outputs a voltage proportional to the acceleration on each of its three axes.  I used metal buttons to transfer the accelerometer signal from the glove to the jacket.

The schematic below shows all the components used to make this jacket. All connections are made using conductive thread. Notice how the LEDs do not have series resistors. This is because, unlike wire, conductive thread has a significant amount of resistance already. So there is no need to have additional resistors to limit current going though each LED.

Lilypad Bike Jacket schematic

Lilypad Bike Jacket schematic (click to enlarge)

And finally here’s a sample code for the Lilypad:

/*
 * This program implements a signal indicator jacket using a Lilypad Arduino and a 
 * Lilypad accelerometer. 
 * 
 * Author: Kasun Somaratne
 * Created: Dec 1, 2013
 * Modified: Dec 2, 2016
 */

void setup()
{
 // declare all digital pins as outputs
 for(int pin = 2; pin < 14; pin++)
 {
 pinMode(pin,OUTPUT);
 digitalWrite(pin,LOW);
 }
 // we will also need to use three of the analog pins as digital output pins
 for(int pin = A0; pin < A3; pin++)
 {
 pinMode(pin,OUTPUT);
 digitalWrite(pin,LOW);
 }
}

void loop()
{
 clearLights();
 // Analog pins A3 and A4 will be used to read the X and Y outputs of the Lilypad
 // accelerometer. Use the analog values to determine the correct signal to display. 
 if((analogRead(A4) > 500) && (analogRead(A3) < 450))
 {
 leftSignal();
 delay(100);
 }
 else if((analogRead(A4) < 450) && (analogRead(A3) > 500))
 {
 rightSignal();
 delay(100);
 }
 else if(analogRead(A3) > 600)
 {
 breakLights();
 }
 else
 {
 idleLights();
 }
}

void leftSignal()
{
 for(int pin = 6; pin > 1; pin--)
 {
 digitalWrite(pin,HIGH);
 delay(100);
 }
 
 for(int pin = 2; pin < 7; pin++)
 {
 digitalWrite(pin,LOW);
 } 
}

void rightSignal()
{
 for(int pin = 12; pin < 14; pin++)
 {
 digitalWrite(pin,HIGH);
 delay(100);
 }
 for(int pin = A0; pin < A3; pin++)
 {
 digitalWrite(pin,HIGH);
 delay(100);
 }
 for(int pin = 12; pin < 14; pin++)
 {
 digitalWrite(pin,LOW);
 }
 for(int pin = A0; pin < A3; pin++)
 {
 digitalWrite(pin,LOW);
 } 
}

void idleLights()
{
 for(int pin = 7; pin < 12; pin++)
 {
 digitalWrite(pin-1,LOW);
 digitalWrite(pin,HIGH);
 delay(100);
 }
 for(int pin = 11; pin > 7; pin--)
 {
 digitalWrite(pin,LOW);
 digitalWrite(pin-1,HIGH);
 delay(100);
 } 
}

void breakLights()
{
 for(int pin = 7; pin < 12; pin++)
 {
 digitalWrite(pin,HIGH);
 } 
}

void clearLights()
{
 for(int pin = 2; pin < 14; pin++)
 {
 digitalWrite(pin,LOW);
 }
 for(int pin = A0; pin < A3; pin++)
 {
 digitalWrite(pin,LOW);
 }
}

Smart Signal light for a bicycle

This is a project I have been interested in for many years: A signal indicator for cyclists. Cycling is one of my favorite activities. As a commuter cyclist I’m on the road a lot, and safety is always on the back of my mind. When you ride your bike on the road alongside cars, trucks and buses, the chances of you walking out of an accident is very slim. One of the most important things you can do to avoid an accident is to be seen! So about 3 years ago I decided to build a wearable signal indicator for cyclists called Smart Turn. I was able to make a prototype of Smart Turn using a Lilypad Arduino and a BlueSMiRF Silver Bluetooth module.

Smart Turn prototype 1

Smart Turn prototype 1

Using the Bluetooth module I was able to control the lights on the jacket using my phone. This prototype had three major issues:

  1. The jacket was hideous and cumbersome to wear.
  2. The lights were not bright enough to be seen effectively.
  3. The cell phone battery drained after only a few hours of use.

Because of these problems the first prototype was not very practical, and I never actually ended up using it on the road. Since I was busy with school at the time the project was shelved. After school ended I slowly got back into this project and now I have built a second prototype that fixes all the problems I had with the first version.

Smart Signal belt. Prototype 2

Smart Signal belt. Prototype 2

The new Smart Signal is a belt. The major advantage of this is that you can wear it around your waist or around your backpack if you happen to ride with a backpack on like I do. The second improvement is using Neopixel RGB LEDs instead of regular LEDs. The Neopixels are significantly brighter than regular LEDs, and they can be connected serially and controlled with only three connections. The third major improvement is using a Bluetooth Low Energy (BLE) module to control the lights. Using BLE helped increase the battery lifetime significantly over the previous version. The fourth major improvement is having a separate controller attached to the handle bar of the bicycle rather than using a phone. This controller was physically actuated with the brake lever, and is much more reliable than using the accelerometer of the phone to detect braking.

Inside Smart Signal belt

I used enamel wire to make the connections between the three LED sticks. I found this to be more reliable than using conductive thread. After making all the connections, I sandwiched the LED sticks and enamel wire between two pieces of fabric and sew the fabric together. Holes were cut out to expose the LEDs. The rest of the components including the Li-polymer battery are placed on the small red case which links the belt to the belt buckle.

BLE module, ATTINY85 microcontroller and the Li-poly battery are placed inside the red case

BLE module, ATTINY85 microcontroller and the Li-poly battery are placed inside the red case

The following schematic shows the components of the Smart Signal belt. It consists of three main components: A BLE113 breakout board for wireless control, an ATTINY85 for controlling the Neopixel LEDs and Neopixel LEDs.

Schematic of Smart Signal Belt

Schematic of Smart Signal Belt

The Neopixel LEDs can be programmed with just one data pin. The only timer available with the BLE113 module is 32.768 kHz, not sufficient to meet the timing requirements of the Neopixels. So I decided to use a ATTINY85 to control the LEDs. The BLE113 breakout board, which I talked about in my previous post, includes a Li-polymer battery charger.

The following is a flow chart showing how the Smart Signal operates.

Flow chart for the Smart Signal belt operation

Flow chart for the Smart Signal belt operation

Upon startup the BLE module starts advertising that it is a Smart Signal device and that it is available for connecting to a master. This allows the controller that sits on the handle bar to find and connect to the Smart Signal belt. Once a connection is established, the Smart Signal belt stays in idle mode until a signal state update is received from the controller.

There are four lighting modes: left turn signal, right turn signal, brake and off. Brake signal overrides any of the turn signals. The BLE module sets the status of two output pins (sw1 & sw2) according to the signal state received from the controller. The ATTINY reads the sw1 & sw2 pin statuses and activates the correct lighting mode.

Smart Signal Controller

The controller is attached to the handle bar of the bicycle. The turn signals are activated by a slide switch. I used a momentary switch to detect the brake position as shown in the image below.

Smart signal controller with the brake lever status detection mechanism

Smart signal controller with the brake lever position detection mechanism

The controller also has a BLE113 module, which connects to the BLE module of the belt. If the BLE module of the controller detects a change in any of the switch positions, it will send the appropriate command to the Smart Signal belt.

The second prototype is functional, and I do use it on the road. The only gripe I have with it is that the controller is very specific to the orientation of the brake handles of my bicycle. So it is not easily transferable between bicycles. The next step for this project is to update the controller to make it universal. But for the time being I am glad to have a Smart Signal device that I can use in my daily commute. Here is a short video that shows what the Smart Signal belt looks like in action:

Let me know if you have any questions, thoughts or suggestions. Thanks for reading!

Harnessing energy from a bicycle

I enjoy cycling not only because it is one of the most efficient and cheapest forms of transportation, but also it is very satisfying. Yeah hills can be a pain but what goes up must come down, eventually.

When I ride my bike I like to have my phone with me so that I can have a map, a list of directions and also see how fast I am going. Couple of years ago I created an electronic dashboard for cyclists called Smart Turn. It was designed to help cyclists navigate safely through urban roads.

Smart Turn consisted of a mobile phone app and a safety vest with lights. The lights can be activated wirelessly to indicate turn signals and braking. I successfully created a working prototype of Smart Turn. However, it had several issues:

  1. The cell phone battery dies fast
  2. The turn signal lights cannot be seen during the day
  3. The vest is cumbersome to wear, specially in hot weather

The biggest problem it had is with the cell phone. The Smart Turn app uses GPS, Bluetooth and keeps the screen on all the time. This makes the cell phone battery drain in a couple of hours. So to fix this issue I created a cell phone charging system for my bicycle.

The cell phone charging system uses both solar and pedal power to charge the phone. While building this I decided to also include a battery pack, a front lamp, and a rear lamp which could also be powered by the same charging system.

The following is a schematic of the charging system:

ChargeSch

Schematic of bicycle charging system

The Dynamo

For the dynamo I used a stepper motor. This Nema17 stepper motor was rated at 12 V and 1.2 A per phase. Generally the higher the amp rating of the motor, the more power it can generate. The first thing I needed to do is to verify that this motor can generate enough power to charge the cell phone and accessories. To do that I had to attach the motor to the bicycle wheel. Thanks to my 3D printer I was able to make a holder to attach the motor to the bicycle. Then I also 3D printed a contact wheel for the motor.

Dynamo motor attached to the bicycle

Dynamo motor attached to the bicycle

Contact wheel of the dynamo

Contact wheel of the dynamo

This stepper motor has two pairs of windings. Each pair of windings generates an alternating current when the motor is rotated. To convert the AC to DC, I used a multi-phase rectifier bridge as shown in the schematic.

During initial testing I found that the motor can generate up to 70 V when hand cranking the pedal. So it was obvious that I needed a regulator before connecting it to a cell phone. As shown in the schematic I made a simple regulator using a 5.6 V Zener diode and a TP129 transistor. The transistor needed to have a heat sink since it will be generating a fair amount of heat. I put the regulator and the mode select switch in a control box under the back of the seat. The six position mode switch selects which power source is connected to which device.

Six position mode switch for selecting which power source is connected to which device

Six position mode switch for selecting which power source is connected to which device

Solar Panel

The Solar Panel I found at a local electronics store is rated to produce 200 mA at 5 V in direct sunlight. The only thing I had to do for this is to design a holder to attach it to the bicycle.

Solar panel attached to the front handle bar

Solar panel attached to the front handle bar

The Battery Pack

The battery pack consists of six Ni-Cd batteries arranged in two rows with three batteries per row connected in series. These batteries are salvaged from old solar garden lights. Ni-Cd batteries are safer and easier to charge compared to Li-Ion batteries. Also a special charging circuit is not required for Ni-Cd batteries as long as the charge current is limited.  The two rows of batteries power the front and rear lamps when neither the solar power or pedal power is available. The battery pack can be recharged by either the solar panel or the dynamo. I made a case for the battery pack using the 3D printer and sealed the case using a glue gun.

Rechargeable Ni-Cd battery pack made using solar garden light batteries

Rechargeable Ni-Cd battery pack made using solar garden light batteries

Front & Rear Lights

Both the front and the rear lights consist of two LEDs that blink alternatively. The blinking circuit is simply an astable multivibrator made with a couple of transistors. For the rear light I designed and printed a case from  scratch. But the front light is hacked from a purse light. The lights can be power from either the battery pack, solar panel or the dynamo. Although powering the lights with the solar panel is somewhat useless since there is no need for lights when it is sunny.

Front and rear lights

Front and rear lights

This charging system will significantly extend the battery life of the cell phone and uses energy that is freely available. The next step is to make turn signal indicators that are visible during the day. Unlike the front and rear lights the turn signals will be attached to the rider instead, making them more effective. More on wearable turn signal indicators will be covered in the next post.