Project tutorial
Leduindo - Smart Led Bike Lightning

Leduindo - Smart Led Bike Lightning © MIT

Get yourself noticed on the night rides using a light sensor and some shinny leds.

  • 4,773 views
  • 1 comment
  • 19 respects

Components and supplies

Apps and online services

About this project

As the dark season is around, let's make smart bright lights for your bike using a photocell and some powerful leds. This could be useful for 'cops on bike' also...

Hardware components

Find all the components such as photocell, powerful leds, resistor... and a small controller such as Arduino Nano. Then put it all together...

I found difficult to get right cathodes / anodes from first time and messed a bit the circuit ...

After you get it right this should like this...

Focus on the arduino board now. Digital pins from 7 to 12 on each 'long leg' and ground on the others.

The resistor is need it for connection of the analog pin and photocell, learn more from Adafruit - We connected to A0, VCC and GND

Arduino light games

In your Arduino IDE first of define the variables

int photocellPin = 0;     // A0 photo cell connection
int photocellReading;     // the analog reading from the sensor divider 
int CellIntensVal;        // values of the intensity 
int LEDred1 = 12;         // pins definition 
int LEDred2 = 11; 
int LEDblue1 = 10; 
int LEDblue2 = 9; 
int LEDgreen1 = 8; 
int LEDgreen2 = 7;

We want to have 3 case scenarios in regards to lights games

  • Normal - No bright leds
  • Dark mode - Ordinary lights
  • Car behind - Let's get flashy
void cmdOffLights() { 
digitalWrite(12, LOW); 
digitalWrite(11, LOW); 
digitalWrite(10, LOW); 
digitalWrite(9, LOW); 
digitalWrite(8, LOW); 
digitalWrite(7, LOW); 
} 
void cmdDarkLights() { 
digitalWrite(12, LOW); 
digitalWrite(11, LOW); 
digitalWrite(10, LOW); 
digitalWrite(9, LOW); 
digitalWrite(8, LOW); 
digitalWrite(7, LOW);   
delay(20);   .....
} 
void cmdWoopWoop() { 
digitalWrite(12, HIGH); 
digitalWrite(11, LOW); 
digitalWrite(10, LOW); 
digitalWrite(9, LOW); 
digitalWrite(8, LOW); 
digitalWrite(7, HIGH); 
......
}

On the setup area initialize Led modes

pinMode(12, OUTPUT); 
pinMode(11, OUTPUT); 
pinMode(10, OUTPUT); 
pinMode(9, OUTPUT); 
pinMode(8, OUTPUT); 
pinMode(7, OUTPUT); 

On the loop void - photocell readings

photocellReading = analogRead(photocellPin);
CellIntensVal  = photocellReading;
Serial.println(photocellReading);     // the raw analog reading  
// LED gets brighter the darker it is at the sensor 
// that means we have to -invert- the reading from 0-1023 back to 1023-0 
photocellReading = 1023 - photocellReading; 
//now we have to map 0-1023 to 0-255 since thats the range analogWrite uses 
LEDbrightness = map(photocellReading, 0, 1023, 0, 255); 

... and some 'magic' based on the light intensity

if (CellIntensVal > 760) { cmdWoopWoop();  } 
if (CellIntensVal < 761 && CellIntensVal > 100 ) {  cmdOffLights();} 
else if (CellIntensVal < 101) {   
cmdDarkLights(); 
} 
delay(200);  

The result:

In the box - ready to be mounted!

Get noticed and enjoy your night ride!

Code

DasBike - Woop woopC/C++
Arduino ino file
int photocellPin = 0;     // the cell and 10K pulldown are connected to a0
int photocellReading;     // the analog reading from the sensor divider
int LEDbrightness;        // 
int CellIntensVal; 
int LEDred1 = 12;
int LEDred2 = 11;
int LEDblue1 = 10;
int LEDblue2 = 9;
int LEDgreen1 = 8;
int LEDgreen2 = 7;

void setup() {
// initialize the digital pin as an output.
Serial.begin(9600);   
// Pin 12 has an LED connected on most Arduino boards:
pinMode(12, OUTPUT);
pinMode(11, OUTPUT);
pinMode(10, OUTPUT);
pinMode(9, OUTPUT);
pinMode(8, OUTPUT);
pinMode(7, OUTPUT);
}

void loop() {

photocellReading = analogRead(photocellPin);  
CellIntensVal  = photocellReading;
Serial.print("Analog reading = ");
Serial.println(photocellReading);     // the raw analog reading 
// LED gets brighter the darker it is at the sensor
// that means we have to -invert- the reading from 0-1023 back to 1023-0
photocellReading = 1023 - photocellReading;

//now we have to map 0-1023 to 0-255 since thats the range analogWrite uses
LEDbrightness = map(photocellReading, 0, 1023, 0, 255);

if (CellIntensVal > 760) { cmdWoopWoop();  }
if (CellIntensVal < 761 && CellIntensVal > 100 ) {  cmdOffLights();}
  else if (CellIntensVal < 101) {  
    cmdDarkLights();
    }
 delay(200); 
}          

void cmdDarkLights() {
    digitalWrite(12, HIGH);
    digitalWrite(11, HIGH);
    digitalWrite(10, LOW);
    digitalWrite(9, LOW);
    digitalWrite(8, HIGH);
    digitalWrite(7, HIGH);
  delay(1000);    
    digitalWrite(12, LOW);
    digitalWrite(11, LOW);
    digitalWrite(10, HIGH);
    digitalWrite(9, HIGH);
    digitalWrite(8, LOW);
    digitalWrite(7, LOW);
 delay(20);  
    digitalWrite(12, LOW);
    digitalWrite(11, LOW);
    digitalWrite(10, LOW);
    digitalWrite(9, LOW);
    digitalWrite(8, LOW);
    digitalWrite(7, LOW);  
 delay(20);  
}


void cmdOffLights() {
     digitalWrite(12, LOW);
    digitalWrite(11, LOW);
    digitalWrite(10, LOW);
    digitalWrite(9, LOW);
    digitalWrite(8, LOW);
    digitalWrite(7, LOW);
}

void cmdWoopWoop() {
   digitalWrite(12, HIGH);
    digitalWrite(11, LOW);
    digitalWrite(10, LOW);
    digitalWrite(9, LOW);
    digitalWrite(8, LOW);
    digitalWrite(7, HIGH);
  delay(170); //You can make the lights change speed by changing this value.
    digitalWrite(12, LOW);
    digitalWrite(11, HIGH);
    digitalWrite(10, LOW);
    digitalWrite(9, LOW);
    digitalWrite(8, HIGH);
    digitalWrite(7, LOW);
  delay(150); //You can make the lights change speed by changing this value. 
    digitalWrite(12, LOW);
    digitalWrite(11, LOW);
    digitalWrite(10, HIGH);
    digitalWrite(9, HIGH);
    digitalWrite(8, LOW);
    digitalWrite(7, LOW);
   delay(70); //You can make the lights change speed by changing this value.
    digitalWrite(12, LOW);
    digitalWrite(11, LOW);
    digitalWrite(10, LOW);
    digitalWrite(9, LOW);
    digitalWrite(8, LOW);
    digitalWrite(7, LOW);
  delay(30); //You can make the lights change speed by changing this value.
    digitalWrite(12, LOW);
    digitalWrite(11, LOW);
    digitalWrite(10, HIGH);
    digitalWrite(9, HIGH);
    digitalWrite(8, LOW);
    digitalWrite(7, LOW);
  delay(30); //You can make the lights change speed by changing this value.
    digitalWrite(12, LOW);
    digitalWrite(11, LOW);
    digitalWrite(10, LOW);
    digitalWrite(9, LOW);
    digitalWrite(8, LOW);
    digitalWrite(7, LOW);
  delay(30); //You can make the lights change speed by changing this value.
    digitalWrite(12, LOW);
    digitalWrite(11, LOW);
    digitalWrite(10, HIGH);
    digitalWrite(9, HIGH);
    digitalWrite(8, LOW);
    digitalWrite(7, LOW);
  delay(70); //You can make the lights change speed by changing this value.
    digitalWrite(12, LOW);
    digitalWrite(11, HIGH);
    digitalWrite(10, LOW);
    digitalWrite(9, LOW);
    digitalWrite(8, HIGH);
    digitalWrite(7, LOW);
  delay(70); //You can make the lights change speed by changing this value.
    digitalWrite(12, HIGH);
    digitalWrite(11, LOW);
    digitalWrite(10, LOW);
    digitalWrite(9, LOW);
    digitalWrite(8, LOW);
    digitalWrite(7, HIGH);
 delay(20);  
    digitalWrite(12, LOW);
    digitalWrite(11, LOW);
    digitalWrite(10, HIGH);
    digitalWrite(9, HIGH);
    digitalWrite(8, LOW);
    digitalWrite(7, LOW);
 delay(20);  
    digitalWrite(12, LOW);
    digitalWrite(11, LOW);
    digitalWrite(10, LOW);
    digitalWrite(9, LOW);
    digitalWrite(8, LOW);
    digitalWrite(7, LOW); 
 delay(20);    
   digitalWrite(12, LOW);
    digitalWrite(11, LOW);
    digitalWrite(10, HIGH);
    digitalWrite(9, HIGH);
    digitalWrite(8, LOW);
    digitalWrite(7, LOW);
 delay(20);  
    digitalWrite(12, LOW);
    digitalWrite(11, LOW);
    digitalWrite(10, LOW);
    digitalWrite(9, LOW);
    digitalWrite(8, LOW);
    digitalWrite(7, LOW); 
 delay(20);  
    digitalWrite(12, LOW);
    digitalWrite(11, LOW);
    digitalWrite(10, HIGH);
    digitalWrite(9, HIGH);
    digitalWrite(8, LOW);
    digitalWrite(7, LOW);
 delay(20);  
    digitalWrite(12, LOW);
    digitalWrite(11, LOW);
    digitalWrite(10, LOW);
    digitalWrite(9, LOW);
    digitalWrite(8, LOW);
    digitalWrite(7, LOW); 
   delay(50);
  }

Schematics

Schematics - fzz file
bike_ledd.fzz
Schematics - pic
Bike ledd

Comments

Similar projects you might like

Bluetooth control led with lcd led status display real time.

Project tutorial by Youssef Sabaa

  • 17,332 views
  • 4 comments
  • 34 respects

SMART Home LED Lighting System and More

Project in progress by Joey Pongallo

  • 5,946 views
  • 4 comments
  • 13 respects

LED Emergency Lights using WS2812 RGB LED Module

Project tutorial by bigboystoys13

  • 10,004 views
  • 5 comments
  • 20 respects

Arduino Bike Blink Lights

Project showcase by Sam

  • 4,069 views
  • 3 comments
  • 13 respects

Smart Home - Smart Rules using ARTIK Cloud & Photon

Project tutorial by Raghavendra Ponuganti

  • 3,864 views
  • 2 comments
  • 12 respects

tinyGlow Smart LEDs

by Alex Glow

  • 3,799 views
  • 3 comments
  • 24 respects
Add projectSign up / Login