DESIGN AND METHODOLOGY
brainstorming
design 1
Low visibility, adds weight to the bike, can fall off the bike
design 2
Increased visibility from previous design, however, would get in the way of biker, can fall off
design 3
Uncomfortable, hard to display brake lights
the FINAL design
We decided on this design because it accomplished all of our design goals. It is lightweight and fitted so it will not mess with the cyclist's speed or aerodynamics. The design features a tight vest that has an LED matrix on the back. The controls (toggle switches and flex sensors) are connected wirelessly to the matrix using an RF24 receiver and transmitter. There are separate switches for the right turn signal and the left turn signal located next to each handle and when one is flipped, the corresponding turn signal is displayed. The flex sensors stick under the handbrakes and when at least one of the handbrakes are pressed, the sensors activate the brake light. When the flex sensors are bent by pushing the break, they present a value and if the value is within the threshold marked in the code, it will activate the brake light.
PROTOTYPE
Flow Charts
Brake Light flow chart
Turn Signal flow chart
RECEIVER+MATRIX CODE
//import installed libraries
#include <printf.h>
#include <nRF24L01.h>
#include <RF24_config.h>
#include <RF24.h>
#include <SPI.h>
const uint64_t pipe= 0xE8E8F0F0E1LL; //the frequency/channel, same for both receiver and transmitter
RF24 radio(9, 10); //creating the radio for the reciever and transmitter to communicate
int elephant[4]; //declaring the variable as 'elephant'
int trueVals[4];
//import installed libraries
#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>
#ifndef PSTR
#define PSTR
#endif
#define PIN 2 //matrix is in pin 2
bool leftOn = false, rightOn = false;
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(32, 8, PIN,
NEO_MATRIX_TOP + NEO_MATRIX_LEFT +
NEO_MATRIX_COLUMNS + NEO_MATRIX_ZIGZAG,
NEO_GRB + NEO_KHZ800); //setting up how the words on the matrix are oriented
const uint16_t colors[] = {
matrix.Color(255, 0, 0), matrix.Color(255, 0, 0), matrix.Color(255, 0, 0)}; //setting the color of the matrix LEDs to red
void setup() {
radio.begin();
radio.setChannel(108);
radio.openReadingPipe(1, pipe);
radio.startListening();
Serial.begin(9600); //
pinMode (2, OUTPUT);
matrix.begin();
matrix.setTextWrap(false);
matrix.setBrightness(175);
matrix.setTextColor(colors[0]);
}
int x = matrix.width();
int pass = 0;
void loop() {
radio.read(elephant, sizeof(elephant));
if((elephant[0] >= 0 && elephant[1] >= 0 && elephant[2] >= 0 && elephant[3] >= 0) && (elephant[0] != 0 || elephant[1] != 0 || elephant[2] != 0 || elephant[3] != 0)){
Serial.println(elephant[0]);
Serial.println(elephant[1]);
Serial.println(elephant[2]);
Serial.println(elephant[3]);
if (elephant[1] > 741 || elephant[2] > 741) {
matrix.fillScreen(0);
matrix.setCursor(2, 0);
matrix.print(("BRAKE"));
matrix.show(); //if the flex sensors values are above 741, turn on the brake light
}
else if (elephant[0]==1){
if(leftOn){
matrix.fillScreen(0);
matrix.setCursor(0, 0);
matrix.print((" "));
matrix.show();
leftOn=false;
}
//left turn signal
else{
matrix.fillScreen(0);
matrix.setCursor(0, 0);
matrix.print(("<<<<<<<<<<<<<<<<<<<<<"));
matrix.show();
leftOn=true;
}
}
else if (elephant[3]==1){
if(rightOn){
matrix.fillScreen(0);
matrix.setCursor(0, 0);
matrix.print((" "));
matrix.show();
rightOn=false;
}
//right turn signal
else{
matrix.fillScreen(0);
matrix.setCursor(0, 0);
matrix.print((">>>>>>>>>>>>>>>>>"));
matrix.show();
rightOn=true;
}
}
else{
matrix.fillScreen(0);
matrix.setCursor(2, 0);
matrix.print((" "));
matrix.show();
}
delay(100);
}
}
TRANSMITTER + SWITCH + SENSOR CODE
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
const uint64_t pipe= 0xE8E8F0F0E1LL; //the frequency/channel, same for both receiver and transmitter
RF24 radio (4, 10);
int rocket[4]; //declaring variable as rocket
#define LEFT 4 /left switch is in pin 4
#define BRAKE1 A0 //brake 1 is in pin A0
#define BRAKE2 A1//brake 2 is in pin A1
#define RIGHT 7 //right switch is in pin 7
void setup() {
Serial.begin(9600);
radio.begin();
radio.setChannel (108);
radio.openWritingPipe(pipe);
pinMode (LEFT, INPUT);
pinMode (BRAKE1, INPUT);
pinMode (BRAKE2, INPUT);
pinMode (RIGHT, INPUT);
}
void loop() {
//declaring each "channel's" function
rocket[0] = (digitalRead (LEFT));
rocket[1] = (analogRead (BRAKE1));
rocket[2] = (analogRead (BRAKE2));
rocket[3] = (digitalRead (RIGHT));
radio.write(rocket, sizeof(rocket));
for(int i = 0; i<4; i++){
Serial.println(rocket[i]);
}
Serial.println();
delay(500);
}
Circuit Diagrams
The matrix is what the brake lights and turn signals are displayed on.
The flex sensors are for the brake lights and the switches are for the turn signals.