Introduction: TfCD - Automatic Bicycle Light - Find Your Bike Back in the Dark!
This Instructable will explain how to make your own wirelessly connected bicycle light! As soon as you come close enough to your bicycle the light will turn on, this way you can always find your bike back in the dark and never forget to turn on your bicycle light again. The housing of the light is 3D printed and via two Xbee's your bicycle light will communicate with a 'key chain' that you carry with you.
Step 1: Get the Components
The necessary components are:
1. XBee (2x)
2. XBee explorer USB
3. XBee Shield
4. Arduino UNO
5. 3.7V lithium-ion battery
6. NeoPixel ring x12
7. Arduino FIO
8. Resistor between 300-400 Ohm
3. Soldering material
Step 2: Programming
For the programming there are three steps that need to be fulfilled
To be able to work with the NeoPixel you need to download a the Arduino software and NeoPixel library first. The Arduino software can be downloaded from: https://www.Arduino.cc/en/Main/Software and the NeoPixel library can be found at: https://www.Arduino.cc/en/Main/Software
In order to install the library, first download the file, then open Arduino on your computer, go to Sketch>Include Library>manage Libraries and in the search box type “NeoPixel”. When you see the program you just downloaded “Adafruit NeoPixel by Adafruit” select it and click on “install”. Then close the window, now you are ready to use your NeoPixel.
2B: Uploading code to the Arduino's
To make life ease on you we have already written a code for the Arduino's for you, you can download this below and upload it to your Arduino FIO and UNO.
To upload code to your Arduino UNO, simply use the included usb cable. Please remove the XBee from the shield while uploading, else you will get an avr dude error. To upload the code to your Arduino FIO however takes a different approach. It can be done in two ways:
Option 1: Buy an FTDI adapter and connect this adaptor to the appropriate pins.
Option 2: This option is the one we prefer as you do not have to buy an extra adapter and you do not have to disconnect your XBee while uploading your code. You can wirelessly upload your code to your Arduino by using the XBee explorer USB. The XBee explorer will need a small hack however, and your XBee's need the correct settings.
2C: Configuring the XBee's
The following web page will elaborate on how to hack your XBee explorer and fully configure your XBee's: https://www.Arduino.cc/en/Main/ArduinoBoardFIOPro...
Please read this page carefully. If you need additional help with setting up your Xbee's, this video will give a more elaborate explanation:
Customizing the light
If you want, you can adapt the code, for example you can change the color of the light (white) to red in order to make your light a rear light. Change this line: 'pixels.setPixelColor(i, pixels.Color(255, 255, 255))' to this 'pixels.setPixelColor(i, pixels.Color(255, 0, 0))'.
In the code itself you can find additional comments on how to change it to your liking.
Step 3: Build the Circuit
3A Build circuit using breadboard
The very first step is to make the NeoPixel ready to use. In order to do so you will need to solder three wires onto it: one to GND, 5V DC power, Data In. (see image above)
Note: The NeoPixel will run fine on 3.7 volts, you will encounter '5V' through some parts of this instructable. This is just because the NeoPixel has 5V written next to the Vin pin.
The second step is to make the circuits working. Therefore it is important to first test it with a breadboard first. Build the circuits as shown in the image. Circuit 1: Connect the GND of the NeoPixel to the GND of the Arduino FIO. Then connect the Input of the NeoPixel to pin D6 of Arduino FIO (put the resistor in line to protect the NeoPixel from spikes on the data line).
First make sure the onboard switch on the Arduino FIO is set to off. Then connect the 5V DC power of the NeoPixel to the BAT+ van de Arduino. Lastly connect FIRST the GND of the battery to the BAT – of the Arduino and the + of the battery to the BAT + of the Arduino (see circuit sketch)
Circuit 2: Connect the Arduino UNO and the XBee using the XBee shield (like shown in the picture)
the shield can only be inserted in one way, focus on the block with six holes aligning correctly with the six pins on the Arduino. To correctly insert the XBee, please look at the white outline on the XBee shield and the shape of the XBee, this should correspond.
Now they you have build the circuits test if they are working. Switch the the Arduino FIO to ON and connect the Arduino UNO to a power source.
Step 4: Soldering
Now that you have build and tested the circuit you can start soldering the circuit. Solder the connections as can be seen in the picture, make sure not to use the breadboard here.
Step 5: 3D Printing
One of the last steps is to 3D print your own lamp. You can make your own design for this or use the one that we have already prepared. This can be downloaded below. Make sure that if you have bought different components that described that the 3D model fits al your components. The connector on the top is a Garmin male quarter turn connector, you can buy the female part at most bike shops.
Step 6: Finalizing
Put circuit 1 (thecircuit with the NeoPixel) into the lamp, as is shown in the picture above. Now connect the bicycle light to your bike and the key chain to your keys. You now have made your own wireless automatic bicycle light that automatically turns on and of!
Possible improvements are an additional switch on the outside of the lamp that turns the Arduino FIO on and off, while the current switch will be inside the lamp and hard to reach.
The Arduino UNO should be changed to an additional Arduino FIO with a battery. As an Arduino UNO with XBee shield is very bulky.
mylifeinbm made it!
We have a be nice policy.
Please be positive and constructive.