DEV Community

Cover image for Wireless bike signalling
Paula
Paula

Posted on

Wireless bike signalling

Introduction

I was suggested to create a project that allows people on bikes use leds to signalling their moves. This idea came to my attention as my dad is also a biker and I thought this could be useful. I recently tested wireless inductive coils for wereables in another project so I decided to make it more interesting. The whole project is documented in hackster.io under AGPL v3 licence. Let me explain.

The concept

The idea is quite simple. A single board controls blinking leds, but instead of directly connect the pin with the led, I'm attaching a wireless conductive charger to the blinking pin in the ATmega328 (for testing and prototyping you could use UNO or NANO) so it will pass the information (blinking) to the led as long as the other coil, the one connected to the led, is close to the one connected to the PCB. This way, battery and circuit (the heavier parts) are in the bike and not in the fabric, and it's more comfortable and convenient. Also, I decided to suggest a sewing pattern for using the leds in a detachable pocket so the biker can do the laundry without worrying about the components.

Alt Text

3D design

I used this wonderful 3D design for making a strap-held for the bike coils. Check it here:

Alt Text

Sketches before the design and sewing patterns:

Alt Text
Alt Text
Alt Text

Code and PCB

The code is quite simple, and adjusted to the PCB design. Let's take a look at the PCB first:

Alt Text

The board uses a ATmega328, connected to a mini USB module (only using power). Additionally, I added two power and GND pins in case an alternate power source is needed. Main pins are A0 and A1, which will be left and right leds, but in case you want to add more leds A2, A3 and A4 are ready to blink leds as well. All the leds blink with a 1 sec timing, in case the biker wanna changes this, I added a RX-TX so you can read the current timing and set a new one using an extra Arduino that sends the data to the board (through TX). Let's explore the code to better understand:

/*
  Blinking wereable, this part goes in the bike
  Creator: terceranexus6

  LICENCE: GPL v3

  In this case, the inductive coil shall be conected by default in right and left, unless you want to use any other of the 
  analog inputs for convinience (or extra).

  default blinking time is one sec, that could be changed using the RX pin.

  This could work in arduin nano and UNO using the pinout:

  ARDUINO           

  A0                COIL 1 5V 
  A1                COIL 2 5V
  GND               COIL 1 AND COIL 2 GND


  but you can also print the PCB, check it here: gitlab.com/terceranexus6/komorebi
*/

//constant values for the board (minimun)

const int led_left=A0;
const int led_right=A1;

//const values for extra lights (extra)
const int extra_led_1=A2;
const int extra_led_2=A3;
const int extra_led_3=A4;

//values for RX and TX digital
int rx = 1;
int tx = 0;


// the setup function runs once when you press reset or power the board
void setup() {
  // initialize pins as an output except from rx.
  pinMode(led_left, OUTPUT);
  pinMode(led_right, OUTPUT);

  pinMode(extra_led_1, OUTPUT);
  pinMode(extra_led_2, OUTPUT);
  pinMode(extra_led_3, OUTPUT);

  pinMode(rx, INPUT);
  pinMode(tx, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {


  //1 sec delay by default
  int my_time = 1000;

  //reading RX for changing light timing, in case of reading from another arduino
  int timing = digitalRead(rx);

  if ( timing > 0 ) {

    my_time = timing;

  }

  //sending the information back to tx for debugging, so you can check if it's either by default or rx
  digitalWrite(tx, my_time);

  //flashing left
  flash_light(led_left, my_time);

  //flashing right
  flash_light(led_right, my_time);

  //flashing extra led 1
  flash_light(extra_led_1, my_time);

  //flashing extra led 2
  flash_light(extra_led_2, my_time);

  //flashing extra led 3
  flash_light(extra_led_3, my_time);
}


void flash_light (const int lgt, int c_time){

  analogWrite(lgt, 255);   // turn the LED on (255 is the max voltage level, change for a lower light)
  delay(c_time);             // wait for a second, change for different timing
  analogWrite(lgt, 0);    // turn the LED off by making the voltage LOW
  delay(c_time);

  }

Enter fullscreen mode Exit fullscreen mode

Feel free to test, prototype and collaborate!

Latest comments (3)

Collapse
 
aleximmi profile image
aleximmi

This is really amazing Man, I want to share this on my blog bikeportions.com/best-fixie-helmet...

Collapse
 
garrysmithers profile image
garrysmithers • Edited

great presentation, is it also works in e bikes under 500.

Collapse
 
ramazangeven profile image
Ramazan Geven

nice