light yourself up

Concept

During last year’s winter I was hit by a car while walking in the dark. So for this project, I wanted to add LED lights to the back of the wool hat so it can be used as a safety device as well as maintain it’s aesthetic view.

Components

  • LilyPad LED White x 3
  • LilyPad Arduino Board Simple
  • Lilypad Light Sensor
  • Conductive Thread
  • 3 AAA Battery

Circuit diagram

 Codes

Originally I was planning to insert a Lilypad buzz sensor to the product so it will give out a buzz signal to the users when the light is on.However; I found it really difficult combining the two sensors together. Therefore, instead of having two sensors together, i chose to insert the light sensor only. I first applied the set of codes provided by the Arduino tutorial, this set of codes allows me to turn the LED lights on and off but this is not what i desired. In order to have different brightness levels, adjustment was made and it is shown below:

int ledPin = 9; // LED is connected to digital pin 9
int led2Pin = 10; // LED is connected to digital pin 10
int led3Pin = 11; // LED is connected to digital pin 11
int led4Pin = 6; // LED is connected to digital pin 6
int led5Pin = 5; // LED is connected to digital pin 5

int sensorPin = A2; // light sensor is connected to analog pin 2
int sensorValue; // variable to store the value coming from the sensor

void setup()
{
pinMode(ledPin, OUTPUT); // sets the ledPin to be an output
pinMode(sensorPin, INPUT); // sets the ledpin to be an input
Serial.begin(9600); //initialize the serial port

}

void loop() // run over and over again
{
sensorValue = analogRead(sensorPin); // read the value from the sensor
analogWrite(ledPin, abs(sensorValue/4-255)); // 0=255, 255=0
analogWrite(led2Pin, abs(sensorValue/4-255)); // 0=255, 255=0
analogWrite(led3Pin, abs(sensorValue/4-255)); // 0=255, 255=0
analogWrite(led4Pin, abs(sensorValue/4-255)); // 0=255, 255=0
analogWrite(led5Pin, abs(sensorValue/4-255)); // 0=255, 255=0
Serial.println(sensorValue); // send that value to the computer
delay(100); // delay for 1/10 of a second
}

 

 

Another set of codes were made in order to get the best result and it’s shown below:

int ledPin = 5; // LED connected to digital pin 13
int ledPin1 = 6;
int ledPin2 = 9;
int ledPin3 = 10;
int ledPin4 = 11;

int sensorPin = A2; // light sensor is connected to analog pin 0
int sensorValue = 0; // variable to store the value coming from the sensor
int sensorFrequency = 100; // number of milliseconds between sensor readings

int lightThreshold1 = 10; // threshold below which light turns on
int lightThreshold2 = 500; // threshold below which light turns OFF

void setup()
{
pinMode(ledPin, OUTPUT); // sets the ledPin to be an output

pinMode(ledPin1, OUTPUT); // sets the ledPin to be an output
pinMode(ledPin2, OUTPUT); // sets the ledPin to be an output
pinMode(ledPin3, OUTPUT); // sets the ledPin to be an output
pinMode(ledPin4, OUTPUT); // sets the ledPin to be an output

Serial.begin(9600); //initialize the serial port

}

void loop() // run over and over again
{
sensorValue = analogRead(sensorPin); // read the value from the sensor
Serial.println(sensorValue); // send that value to the computer

/* Turn on the LEDs if the light sensor drops below threshold */
if (sensorValue <= lightThreshold1){
analogWrite(ledPin, 255); // turn the LED on

analogWrite(ledPin1, 255); // turn the LED on
analogWrite(ledPin2, 255); // turn the LED on
analogWrite(ledPin3, 255); // turn the LED on
analogWrite(ledPin4, 255); // turn the LED on
}
else if (sensorValue > lightThreshold2) // turn the LEDs off
{
analogWrite(ledPin, 0); // turn the LED off
analogWrite(ledPin1, 0); // turn the LED off
analogWrite(ledPin2, 0); // turn the LED off
analogWrite(ledPin3, 0); // turn the LED off
analogWrite(ledPin4, 0); // turn the LED off
}
else {
analogWrite(ledPin, 10);
analogWrite(ledPin1, 10);
analogWrite(ledPin2, 10);
analogWrite(ledPin3, 10);
analogWrite(ledPin4, 10);
}

/* Delay for defined delay period */
delay(sensorFrequency);
}

Detail of the final project:

                                        Right Pouch for the Lilypad Simple                                                                       Left pouch for the battery

  

Back view of the hat with the LED lights attached                                                                            Brightest at night/ dark ares                                                                                                     Dimmer with room light

                                     Fully off under the light/sun

 

 

Comments are closed.