Dual Nano IOT Bluetooth lighting project concept

I've done some small UNO based projects several years ago, but nothing recent. So I would appreciate any comments on the feasibility of the following:

I want to modify LED brake lights on a motorcycle trunk box into tail, stop, turn using the two available (nominal +12v) power and ground wires in the connector. The bike has separate turn and brake lights, the box has one strip of red LEDs on each side.

I propose to connect the + to the (always on) tail light supply instead of the brake light (intermittent) supply. I would use this to provide power to a Nano IOT mounted on the bike itself and a second mounted in the trunk, as well as power to the two LED strips, one on each side of the box.

The first Nano would have 3 inputs, one from the brake light circuit, one from the left turn and one from the right turn. The nominal 12v signals from the bike's circuit would be limited to 3.3v by three terminal regulators (LD1117V33) (and maybe a pull-down resistor?) at the inputs.

The second Nano would have two outputs, one to each side, controlling enhancement mode MOSFETS to power the LED strips.

The two would have to automatically pair on power up. Ideally there would be fault tolerance to ensure a pairing if the trunk was attached after the bike ignition was turned on, although this would be a rare situation.

The sketch on the first Nano would (after setting up the BT connection, etc.) consist of an infinite loop along the lines of (I realize my syntax is all wrong, I am way out of practice, this is just to illustrate the logic flow):


// LT is left turn input, RT is right turn input, BR is brake input. 
// LTSTATUS, etc. is the calculated status of the left turn signal, etc. 
// STATUS is the sum total and final output to the second Nano IOT. 
// Status values are such that the final STATUS value must be unique for each condition. 



Loop {

// brake light is easy, it's either on or off

if (BR = true) {BRSTATUS == 1} 
     else {BRSTATUS = = 0}

// because the bike has separate turn and brake lights, I need to allow time to determine if the signal has been turned off or is just between flashes
If LT = (true && TIMER0 = false) 
{
// code to start first 1.5 second timer goes here. To Be Determined. 
}
If LT = (true){ 
      if LT = (true) {
      then  LTSTATUS == 2} 
      else {LTSTATUS == 4}
else LTSTATUS == 0}
        }

// similar for the right turn signal
If (RT = true && TIMER1 == false) 
{
// code to start second 1.5 second timer goes here
}
       If TIMER1 = (true) 
       then { 
              if RT = (true) 
              then {RTSTATUS = 6}
              else {RTSTATUS =8}
      }
     else {RTSTATUS = 0}

STATUS = (BRSTATUS + LTSTATUS + RTSTATUS)

// special case to handle 4-way flashers

if (LTSTATUS = 2  && RTSTATUS = 6) 
then {STATUS ==1}
if (LTSTATUS =4 && RTSTATUS =8)
then {STATUS == 0} 


// send STATUS to second Nano via bluetooth somehow -- still researching BLE vs Classic
}

Code for second Nano inside trunk box:

//again, set up BT connection, declare variables, etc. 
// 

Loop {

// normal running, no brakes or turn, just tail. Use PWM to dim both sides
if (STATUS == 0) {analogwrite(LEFTPIN, 125 && RIGHTPIN, 125}

// brakes, no turn. Both sides on full output
if (STATUS == 1) {analogwrite(LEFTPIN, 255 && RIGHTPIN, 255}

// left turn illuminated, no brakes. left side on full, right at tail level
if (STATUS == 2) {analogwrite(LEFTPIN, 255 && RIGHTPIN, 125}

// left turn illuminated, brakes on. Both sides on full
if (STATUS == 3) {analogwrite(LEFTPIN, 255 && RIGHTPIN, 255}

// left turn on dim part of flash sequence, no brakes. Both sides at tail level.
if (STATUS == 4) {analogwrite(LEFTPIN, 125 && RIGHTPIN, 125}

// left turn on dim part of flash sequence, brakes on. Left side dim, right side on full. 
if (STATUS == 5) {analogwrite(LEFTPIN, 125 && RIGHTPIN, 255}

// right turn illuminated, no brakes
if (STATUS == 6) {analogwrite(LEFTPIN, 125 && RIGHTPIN, 255}

// right turn illuminated, brakes on
if (STATUS == 7) {analogwrite(LEFTPIN, 255 && RIGHTPIN, 255}

// right turn on dim part of flash sequence, brakes off
if (STATUS == 8) {analogwrite(LEFTPIN, 125 && RIGHTPIN, 125}

// right turn on dim part of flash sequence, brakes on
if (STATUS == 9) {analogwrite(LEFTPIN, 125 && RIGHTPIN, 255}

}

Comments? Suggestions?

The length of time that may be required for the BT to pair up verses the importance of the task to be accomplish lends me to want to keep both devices on all the time.

I'd use something like these,


They have to be soldered together to make a programable LED strip but they allow for more customized container. A container that can take the harsh operating environment. Also, making your own LED strip allows you to customize the shape.

There is a version of those programmable LED strips that run off of 12 volts.

There is silicon coated programmable LED strips that can withstand some weathering, but they come in set lengths.


My wife rides a bicycle to work. On the back of her bike is a TFmini LIDAR that detects objects behind her bike. Depending upon the distance the object is behind her bicycle a LED strip illuminates. As the object gets closer the light show gets crazier the light show gets.

forgot the link

Thanks for the suggestion. However, the 12v LED strips are OEM and integrated into the case, well protected from the elements behind red lenses. I think I'd rather stick with them, although individually addressable LEDs would open up the possibility of some interesting turn signal effects :wink:

How long does it typically take these Nano IOT devices to pair when powered up? Even when in a hurry, it still takes a few moments after turning the key to start the engine, raise the kickstand, drop it in gear, and check for traffic. Say 10 seconds? But typically I would start the bike and let it warm up a bit while I done helmet and gloves. More like a minute.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.