Arduino bicycle turn signals.
Press left button - turn on left led light or turn off left led light.
Press right button - turn on right led light or turn off right led light.
If left button pressed when right led light blinking, it will stop right led and start left.
If right button pressed when left led light blinking, it will turn off left led light.
The same logic for right turn button.
Video1: https://youtu.be/uAnk8ksx8WE
Video2: https://youtu.be/fiToTopHJI8
In "Components" section below you can see "Two 100nF ceramic capacitors". In Schematics I marked them as C1 and C2. These capacitors not mandatory but strongly recommended.
Optionally you can use the schematics without those two capacitors if you don't have any. In this case you also need to change value of DEBOUNCE_DELAY_MS constant from 100 to 350, this is required to handle Contact Bounce issue (you can read about it on internet).
Two downsides of removing the capacitors:
- If you press turn button down and hold it more than 350ms before release - it's possbile that it will be handled like second button press because contacts bouncing as we ignore false presses only for 350ms.
- Because we hav eto ignore presses for 350ms after it happened, there is another issue as result of the first one: you will not be able to press buttons more often that once per 350ms, presses will be ignored.
While sleeping the project is using about 5uA on 3.7v. It's about 56 years on 2800mAh battery, if I calculated correct. But actually it's not possible because li-ion battery will be self-discharged after couple years :)
While awake and blinking the arduino board uses 3mA current. About 28 days on 2800mAh battery.
So, arduino itself will eat just a little energy. LED lamps will be eating most energy, but I didn't calculate how much exactly, honestly not sure how to calculate it because while blinking it uses PWM to change brightness and on each moment it's using different current, but I can tell that one LED uses 10mA while connected to 12v source, two of them use 20mA, let's say because of PWM and blinking two LEDs use about 10mA, in this case 2800mAh will be enough for 280 hours or ~11 days + arduino eats energy of one of those 3 batteries, so I think that 3 batteries 18650 will be enough (remember about self-discharge of batteries) to blink the lights for about 8 days without stop.
-
One Arduino Pro Mini 3v 8Mhz.
-
"FTDI FT232RL USB To TTL" to upload code to Arduino Pro Mini. Remember to change toggle to 3v on the board before connecting to Arduino Pro Mini. Also soldering is not required, just put FTDI pins in holes of Pro Mini and upload the sketch (BicycleTurnSignals.ino):
You can buy it here: Link1 Link2 Link3
-
LED lights. You can find LED lights that I used by searching "1 Pair Truck Turn Indicators 12V" on aliexpress. I purchased 4 (2 for left and 2 for right side). (I used 12v LEDs because it's easier to find turn light like that. Actually you can find those working from 3.7 volt and then you don't even need 12v source like I have in schematics, you can power them from 3.7v battery too. You can buy the LEDs here: Link1 Link2 Link3
-
Two IRLB3034 mosfet transistors
-
Two 10 kOhm and two 100 Ohm resistors.
-
Two 100nF ceramic capacitors (or 0.1uF, which is same). Not mandatory but strongly recommended (read "Note about capacitors on buttons" above).
-
3 batteries 3.7v with protection (as we need to be sure batteries will not be overdischarged). Any Li-ion or Li-pol battery fits perfectly, but make sure there is overdischarge protection, for example these batteries are ok,
I put batteries inside holder on bicycle like this
and when I need to charge them I take them out and charge using external charger.
I use 12v battery made from 3 protected 18650 batteries connected in series and I power arduino from one one of those 3 batteries I don't worry about disbalance between 3 batteries as arduino eats just a little of power. Here is battery holder with 3 slots that I used: Link1, Link2
For turn lights 3 of 18650 batteries sounds like overkill (2800mAh, 12v), but I also connect 12v horn to same battery and later I could connect something more. If you will only use for turn signals you can think about connecting batteries with less capacity. But it's easier to use 18650 as this is most popular format and it's easy to find holder for the batteries and other stuff.
You will need to remove power LED and voltage regulator from Arduino Pro Mini to save energy: https://www.iot-experiments.com/arduino-pro-mini-power-consumption/ This way it will almost not eat energy while sleeping until you press left and right turn button.
To compile the source, you will need libraries installed in Arduino IDE:
- LowPower: https://github.com/rocketscream/Low-Power (download source code and put everything to .../libraries/Low-Power/ folder)
- MsTimer2: https://github.com/PaulStoffregen/MsTimer2 (download source code and put everything to .../libraries/MsTimer2/ folder)
For info:
- I connected LEDs to the bicycle using cable Ties and hot glue gun. This way they connected well enough to forget about fixing it later :)
- To connect turn buttons to handle I: put buttons on rectangular plastic pad, wrapped with heat-shrink tubing and used hot glue connected that to velcro strap. Then used the strap to connect buttons to the handle: