3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

Light Up Cycling Jersey

Step 14Coding

Now that all the connections are made you are ready to write the code for the jersey.

Here is the link for where you can download the arduino software:

http://www.arduino.cc/en/Main/Software

Below is the code I wrote. Feel free to use it.

// these constants describe the pins. They won't change:
const int lightpin = 0;               //reads the power from the light sensor
const int switchp=5;                  //power pin for the relay to the EL wire
const int xpin = 3;                   // x-axis of the accelerometer                  // z-axis (only on 3-axis models)
const int LED1= 8;                    //LED's 1-6 numbered accordingly
const int LED2= 9;
const int LED3= 10;
const int LED4= 11;
const int LED5= 12;
const int LED6= 13;                    

void setup()
{
  // initialize the serial communications:
  Serial.begin(9600);
 
  // Provide ground and power by using the analog inputs as normal
  // digital pins.  This makes it possible to directly connect the
  // breakout board to the Arduino.  If you use the normal 5V and
  // GND pins on the Arduino, you can remove these lines.
  pinMode(switchp, OUTPUT);
  pinMode(LED1, OUTPUT);
  pinMode(LED2, OUTPUT);
  pinMode(LED3, OUTPUT);
  pinMode(LED4, OUTPUT);
  pinMode(LED5, OUTPUT);
  pinMode(LED6, OUTPUT);
  pinMode(lightpin,INPUT);
  pinMode(xpin,INPUT);
  pinMode(switchp, OUTPUT);
}

void loop()
{
  if(analogRead(lightpin)<30)    //test to see if there is light on the light sensor
  {
     
    if(analogRead(xpin)>600) //test to see if there is acceleration
    {
     //left
       digitalWrite(switchp, HIGH);  // set the EL WIRE on
       delay(200);                  // wait for .2 second
       digitalWrite(switchp, LOW);   // set the EL Wire off
       digitalWrite(LED3, HIGH);   // set the LED on
       digitalWrite(LED4, HIGH);   // set the LED on
       delay(200);                // wait for .2 second
       digitalWrite(LED3, LOW);  // set the LED off
       digitalWrite(LED2, HIGH);  // set the LED on
       digitalWrite(LED4, LOW);  // set the LED off
       digitalWrite(LED5, HIGH);  // set the LED on
       digitalWrite(switchp, HIGH); // set the EL WIRE on
       delay(200);                    // wait for .2 second
       digitalWrite(switchp, LOW);  // set the EL WIRE off
       digitalWrite(LED2, LOW);  // set the LED off
       digitalWrite(LED1, HIGH); // set the LED on
       digitalWrite(LED5, LOW);
       digitalWrite(LED6, HIGH);
       delay(200);                    // wait for .2 second
       digitalWrite(LED1, LOW);
       digitalWrite(LED6, LOW);
       digitalWrite(switchp, HIGH);
       delay(200);                    // wait for .2 second
       digitalWrite(switchp, LOW);
   
      } 
      
        else        //Turn on EL WIRE and LED indefintely
        {
         digitalWrite(LED6, HIGH);   // set the LED on
         digitalWrite(LED5,HIGH);
         digitalWrite(LED4, HIGH);   // set the LED on
         digitalWrite(LED3,HIGH);
         digitalWrite(LED2, HIGH);   // set the LED on
         digitalWrite(LED1,HIGH);
         digitalWrite(switchp, HIGH);
        } 
       
  
    }  
 else    //if lightsensor is off, then turn EL WIRE and LED off
 {
    digitalWrite(LED6, LOW);   // set the LED on
         digitalWrite(LED5,LOW);
         digitalWrite(LED4, LOW);   // set the LED on
         digitalWrite(LED3,LOW);
         digitalWrite(LED2, LOW);   // set the LED on
         digitalWrite(LED1,LOW);
         digitalWrite(switchp,LOW);
 }
     Serial.print(analogRead(lightpin));    //output for serial monitor
        Serial.print("\t");
     
        // print the sensor values:
        Serial.print(analogRead(xpin));
        // print a tab between values:
        Serial.print("\t");
        // print a tab between values:
        Serial.println();
        // delay before next reading:
        delay(50);
}
« Previous StepDownload PDFView All StepsNext Step »

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
8
Followers
3
Author:dmallen