Step 8: program your jacket

Decide on the behavior you want.

I wanted the left switch to turn on the left turn signal for 15 seconds or so, and the right switch to do the same thing for the right signal. Pressing a switch when the corresponding turn signal is on should turn the signal off. Pressing both switches at the same time should put the jacket into nighttime flashing mode. The wrist mounted LEDs should provide feedback about the current state of the jacket. Here's the code I wrote to get that behavior.

Program your jacket

To program your garment, copy and paste my code into an Arduino window and load it onto the LilyPad. You may have to make some small adjustments first depending on where you attached lights and switches. Play with delays to customize your blinking patterns. Follow my LilyPad introduction instructions if you need more information on how to program the LilyPad or how to make sense of my code.

Plug your battery back in and see if it works and...go biking!

Insulate the rest of your traces

Cover the rest of your traces with puffy fabric paint. Again, don't coat anything until you're sure it works.

About washing

Your creation is washable. Remove the battery and wash the garment by hand with a gentle detergent.

Note: silver coated threads will corrode over time and their resistance will gradually increase with washing and wear. To limit the effects of corrosion, insulate and protect your traces with puffy fabric paint or some other insulator. You can also revive exposed corroded traces with silver polish. Try this on a non-visible area first to see what it does to your fabric!


<p>is this waterproof (i'm buying it and i don't know)</p>
<p>Does anyone have had any luck on the full code, its not working for me, and thats kind of frustrating</p>
<p>Fantastic idea! I was wondering what use those Lilypads would be good for. Now I know.</p>
Quick question. I did steps one through five and actually went ahead and did five before four....I put the battery in the power source and my lilypad is blinking without my pressing the switch. What could be causing that?
<p>same to me too.. I didn't know why. Even after I run the full code, I did not press the switch, the lights on LED blink itself. So do you managed to run the full code?</p>
Hi Kelly,<br><br>This was a long time ago...In the end everything worked out. What I do remember is that there was a mistake in the code, but not sure if that was in the final code or just the test code.I'm not a programmer but if I look at the test code the loop starts and ends with a delay and the left light turns off but never on.So that could be causing the wonky behaviour. I don`t remember if there were other issues.<br>Also I don't see the final code. The links to her website produce and error message. I hope you can find it somewhere else. Good luck, I hope that helped. I made the jacket for my husband, he got good use out of it.<br>
The turn signal code fortunately was cached by google! This should be the final code to get it working...<br><br>START CODE:<br><br>int boardLED = 13;<br>int leftSignal = 9; <br>int rightSignal = 11;<br>int signalLow = 10;<br>int rightLow = 4;<br>int leftSwitch = 6;<br>int rightSwitch = 12;<br>int leftLED = 5;<br>int rightLED = 3;<br>int x, y;<br>int mode = 0;<br>int DAY = 0;<br>int NIGHT = 1;<br><br>void setup() // run once, when the sketch starts<br>{<br> pinMode(boardLED, OUTPUT);<br> <br> pinMode(leftSignal, OUTPUT);<br> pinMode(rightSignal, OUTPUT); <br> <br> pinMode(signalLow, OUTPUT); <br> pinMode(rightLow, OUTPUT); <br> <br> pinMode(leftSwitch, INPUT); <br> digitalWrite(leftSwitch, HIGH);<br> pinMode(rightSwitch, INPUT); <br> digitalWrite(rightSwitch, HIGH);<br> <br> pinMode(leftLED, OUTPUT); <br> pinMode(rightLED, OUTPUT); <br> <br> digitalWrite(boardLED, HIGH);<br> digitalWrite(signalLow, LOW);<br> digitalWrite(rightLow, LOW);<br>}<br><br>void loop() // run over and over again<br>{ <br> checkLeft();<br> checkRight();<br> if (mode == NIGHT)<br> night(); <br> else <br> day();<br>}<br><br>void checkLeft()<br>{<br> if (digitalRead(leftSwitch) == LOW)<br> {<br> digitalWrite(boardLED, LOW);<br> while (digitalRead(leftSwitch) == LOW)<br> {<br> if (digitalRead(rightSwitch) == LOW)<br> {<br> while (digitalRead(rightSwitch) == LOW | digitalRead(leftSwitch) == LOW);<br> mode = 1-mode;<br> digitalWrite(boardLED, HIGH);<br> return;<br> }<br> }<br> leftTurn();<br> }<br>}<br><br>void checkRight()<br>{<br> if (digitalRead(rightSwitch) == LOW)<br> {<br> digitalWrite(boardLED, LOW);<br> while (digitalRead(rightSwitch) == LOW)<br> {<br> if (digitalRead(leftSwitch) == LOW)<br> {<br> while (digitalRead(leftSwitch) == LOW | digitalRead(rightSwitch) == LOW);<br> mode = 1-mode;<br> digitalWrite(boardLED, HIGH);<br> return;<br> }<br> }<br> rightTurn();<br> }<br>}<br><br>void leftTurn()<br>{<br> for (x=0;x&lt;10;x++)<br> {<br> digitalWrite(leftSignal, HIGH); <br> digitalWrite(leftLED, LOW); <br> for(y=0;y&lt;10;y++)<br> {<br> delay(30);<br> if (digitalRead(leftSwitch) == LOW)<br> {<br> while (digitalRead(leftSwitch) == LOW);<br> digitalWrite(leftSignal, LOW); <br> digitalWrite(leftLED, LOW); <br> return;<br> }<br> }<br> digitalWrite(leftSignal, LOW);<br> digitalWrite(leftLED, HIGH);<br> for(y=0;y&lt;10;y++)<br> {<br> delay(30);<br> if (digitalRead(leftSwitch) == LOW)<br> {<br> while (digitalRead(leftSwitch) == LOW);<br> digitalWrite(leftSignal, LOW); <br> digitalWrite(leftLED, LOW);<br> return;<br> }<br> }<br> digitalWrite(leftLED, LOW); <br> }<br>}<br><br>void rightTurn()<br>{<br> for (x=0;x&lt;10;x++)<br> {<br> digitalWrite(rightSignal, HIGH); <br> digitalWrite(rightLED, LOW); <br> for(y=0;y&lt;10;y++)<br> {<br> delay(30);<br> if (digitalRead(rightSwitch) == LOW)<br> {<br> while (digitalRead(rightSwitch) == LOW);<br> digitalWrite(rightSignal, LOW); <br> digitalWrite(rightLED, LOW); <br> return;<br> }<br> }<br> digitalWrite(rightSignal, LOW); <br> digitalWrite(rightLED, HIGH); <br> for(y=0;y&lt;10;y++)<br> {<br> delay(30);<br> if (digitalRead(rightSwitch) == LOW)<br> {<br> while (digitalRead(rightSwitch) == LOW);<br> digitalWrite(rightSignal, LOW); <br> digitalWrite(rightLED, LOW); <br> return;<br> }<br> }<br> digitalWrite(rightLED, LOW); <br> }<br>}<br><br>void night()<br>{<br> digitalWrite(boardLED, LOW); <br> <br> digitalWrite(rightSignal, HIGH); <br> digitalWrite(leftSignal, HIGH); <br> digitalWrite(leftLED, LOW); <br> digitalWrite(rightLED, LOW); <br> delay(100);<br> digitalWrite(rightSignal, LOW); <br> digitalWrite(leftSignal, LOW);<br> digitalWrite(leftLED, HIGH); <br> digitalWrite(rightLED, HIGH); <br> delay(100);<br> digitalWrite(leftLED, LOW); <br> digitalWrite(rightLED, LOW); <br>}<br><br>void day()<br>{<br> <br> digitalWrite(boardLED, HIGH); <br> delay(1);<br> digitalWrite(boardLED, LOW); <br> digitalWrite(leftLED, HIGH);<br> delay (1);<br> digitalWrite(leftLED, LOW);<br> digitalWrite(rightLED, HIGH);<br> delay(1);<br> digitalWrite(rightLED, LOW);<br> delay (5);<br>}<br>
<p>Oh, this is the original code and it can't work. I duno why :(</p>
<p>Is this the code that is provided in Dr.Leah website? Seems the same</p>
I was testing the sewing on the jacket, and found that the left signals were not blinking.<br><br>I tested resistance, all was fine, so I went into the code and first changed left to right signals.<br><br>Once I was sure I had not messed up with the sewing, I modified the loop code so that both blink when testing, helping me make sure that connections are correct.<br><br>I wanted to share it here, in case someone else is testing it and wants both signals to flash:<br><br><br>int ledPin = 13; // the LED on the LilyPad<br>int leftSignal = 9; // my left turn signal is attached to petal 9<br>int rightSignal = 11; // my right turn signal is attached to petal 11<br>int signalLow = 10; // the - sides of my signals are attached to petal 10<br><br>void setup() <br>{ <br> pinMode(ledPin, OUTPUT); // sets the ledPin to be an output<br> pinMode(leftSignal, OUTPUT); // sets the leftSignal petal to be an output<br> pinMode(rightSignal, OUTPUT); // sets the rightSignal petal to be an output<br> pinMode(signalLow, OUTPUT); // sets the signalLow petal to be an output<br> digitalWrite(signalLow, LOW); // sets the signalLOW petal to LOW (-)<br>} <br><br>void loop() // run over and over again<br>{ <br> delay(1000); //wait for 1 second<br> digitalWrite(rightSignal, HIGH); // turn the right signal on<br> delay(1000); // wait for 1 second<br> digitalWrite(rightSignal, LOW); // turn the right signal off<br> delay(1000); // wait for 1 second<br> digitalWrite(leftSignal, HIGH); // turn the left signal on<br> delay(1000); // wait for 1 second<br> digitalWrite(leftSignal, LOW); // turn the left signal off<br> delay(1000); // wait for 1 second<br>}<br><br><br>
<p>Thanks. I did that too. Such nice person you are. Anyway did you try the full code? Can it run? I have tried the full code, but it doesn't run .Any idea?</p>
Thanks. +1
Here is a current link to the instructions:<br> <br> <a href="http://web.media.mit.edu/~leah/LilyPad/build/turn_signal_jacket.html" rel="nofollow">http://web.media.mit.edu/~leah/LilyPad/build/turn_signal_jacket.html</a><br> <br> and the code:<br> <br> <a href="http://web.media.mit.edu/~leah/LilyPad/build/turn_signal_code.txt" rel="nofollow">http://web.media.mit.edu/~leah/LilyPad/build/turn_signal_code.txt</a>
<p>Is the full code can be run? I have tried and it cant run</p>
<p>you have the code to turn the left signal off and the right on and off to flash but for the left signal do you just do the same have the right turned off and the left on and off for flashing and do you just input the code under the loop or what</p>
<p>Dude, loop the left signals code ;) I tried it works ;)</p>
hello sir i am new here and in arduino so iwant to learn arduino programing and every thing about arduino so if you khow about programing so please help me to learn arduino sorry for my poor english thanks in advance i am very thankful to you please give me replay to my email<br><br>my email:-zainulislam23@gmail.com<br>skype id:-zainulislam49<br>
<p>Hi Dr Leah, I have tried to do it for my project, but when i run the full code , there are nothing coming out? If I run the signals code, only right signals are on. Is there any errors? I have recheck my sewing for many times .Any idea ?</p>
<p>Hello, can you please make me one and I will pay.. I want to give this to my son for high school project. Thank you (email me at: coachdukedo@gmail.com) Thanks</p>
Can you make one for me let me know email is Benjamen.smith7@gmail.com
<p>Nice idea. However the link to your webpage gives a 404 Page Not Found error and why on earth do I need to pay for the instructable if you are already making money from the components?</p>
<p>Hi, I've added your project to the &quot;Top 5 Incredible Bike Projects&quot;</p><p>This is the link If you are interested:</p><p><a href="http://www.instructables.com/id/Top-5-Incredible-Bike-Projects/" rel="nofollow">http://www.instructables.com/id/Top-5-Incredible-B...</a></p>
<p>compre el lilypad que tiene la fuente de alimentacion conectada como hago para las conexiones de los pulsadores y demas elementos, es de la misma manera?</p>
<p>If there's anyone wondering about the links that aren't working, I've found them here:</p><p><a href="http://web.media.mit.edu/~leah/LilyPad/build/turn_signal_jacket.html" rel="nofollow">http://web.media.mit.edu/~leah/LilyPad/build/turn_...</a></p><p>And for the code:</p><p>http://web.media.mit.edu/~leah/LilyPad/build/turn_signal_code.txt</p><p>Now the link is hosted at MIT. </p><p>Also, wonderful project! If here in brazil would be easy to buy those boards, for sure I would do it!</p>
<p> I've been commuting, racing and touring since 1978. Honestly? This is really cute for nightclubs, but in the real world of urban riding it's waste of time. Drivers who actually pay attention see hand signals, but this? It's only going to be visible at night, and assuming drivers are actually paying attention. Better you all learn how to manage traffic, as in looking over your shoulder to see what's behind you, looking at drivers eyes to see if they see you, all the skills an urban rider already has. This garment will only promote sloppy dangerous riding and get people killed. It's not a new idea. LED turn signals on helmets have already died in the marketplace out of apathy - it's heavy high maintenance stuff that costs a lot of cash for little benefit. And at least those wouldn't be a stinking gamey mess after a ride. How do you wash this? What about rain? How do you intend to deal with high temperature weather with fabrics that won't support all this stuff? Where I live we wear all cotton t shirts to ride in half the year because of hot weather. That won't support the lights and wires. Then there's sweat corrosion. Then there's the plain old who needs the hassle of a complicated shirt when a spread of AA battery blinky lights on bike and helmet works better to be visible.</p><p>Sorry if this sounds harsh, It's not meant to be, but my years as messenger taught me a lot about city riding and extra high maintenance stuff you can't wash is useless. The brain is our best tech - watch behind you for cars and turn when there's room. The cagers won't pay any attention to this. Bike turn signals date back to at least the 1920's. They'd be standard if they did any good.</p><p>I can think of a bunch of other apps for this tech in sporting goods, but the problems of sweat and complicated maintenance would need to be addressed. And the power unit.</p>
<p>Okay, does it have street homologation or is it only for offroad ? </p>
<p>I haven't been on a bike for years but this is one of the best ideas yet.<br>Take it to Shark Tank ASAP</p>
<p>How far/often do you ride, what type of bike do u have ?</p>
<p>A wonderful idea! :)</p>
<p>I've done a similar project only with a professional cycling shirt:</p><p>https://www.youtube.com/watch?v=UWFkxcJ9KR4</p>
<p>Did anyone already suggest adding reflective tape in a fashionable way so that drivers see you first? I noticed that these jackets used are dark which is for the contrasting &quot;arrow board&quot; to be noticed but not for instances of poor visibility such as rain or fog. Great project though.</p>
any one please help me to learn arduino i want to learn arduino i send you money of classes my email<br>is <br>:-zainulislam23@gmail.com
<p>is the info about the power supply all you need to know for the power requirements for all the components or is there more power reqs needed</p>
<p>Well, get one of these http://shooln.co.uk/bike-led-signal-jacket.html. Both the jacket and remote control are waterproof, wireless remote control, got 4 buttons (rather than 2 like in this article), and less hassle to buy stuffs, program and build. I bought one from them and couldn't be happier!</p>
<p>FTDI serves to put the program in Lilypad</p>
<p>hi i am new to this stuff and just wondered what the FTDI connector is used for sorry ia m reserching for a project</p>
<p>Hello, I was wondering if we can use a two ply conductive thread however a four ply one. Thaaaanks!!</p>

About This Instructable




More by leahbuechley:turn signal biking jacket 
Add instructable to: