pong playing flexible screen on a shirt

Upload: lorddarthvader

Post on 02-Jun-2018

221 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/10/2019 Pong Playing Flexible Screen on a Shirt

    1/38

    http://www.instructables.com/id/Pong-Playing-Flexible-Screen-on-a-Shirt/

    Food Living Outside Play Technology Workshop

    Pong Playing Flexible Screen on a Shirtby TheGreatSon October 9, 2013

    Table of Contents

    Pong Playing Flexible Screen on a Shirt .............................................................................................

    Intro: Pong Playing Flexible Screen on a Shirt .....................................................................................

    Step 1: Materials and Tools ...................................................................................................

    Step 2: Cut the LED Strip Into Smaller Strips ......................................................................................

    Step 3: Soldering the Screen Together ..........................................................................................

    Step 4: Soldering the Core Electronics ...........................................................................................

    Step 5: Controller .......................................................................................................... 1

    Step 6: Shirt .............................................................................................................. 1

    Step 7: Programming ....................................................................................................... 3

    Step 8: Finished Product ..................................................................................................... 3

    Related Instructables ........................................................................................................ 3

    Advertisements ............................................................................................................... 3

    Comments ................................................................................................................ 3

    http://www.instructables.com/member/TheGreatS/?utm_source=pdf&utm_campaign=titlehttp://www.instructables.com/tag/type-id/category-workshop/http://www.instructables.com/tag/type-id/category-technology/http://www.instructables.com/tag/type-id/category-play/http://www.instructables.com/tag/type-id/category-outside/http://www.instructables.com/tag/type-id/category-living/http://www.instructables.com/tag/type-id/category-food/
  • 8/10/2019 Pong Playing Flexible Screen on a Shirt

    2/38

    http://www.instructables.com/id/Pong-Playing-Flexible-Screen-on-a-Shirt/

    Author:TheGreatS 40 Watt Soldering Iron

    I enjoy electronics and like to build through whatever medium suits my fancy.

    Intro: Pong Playing Flexible Screen on a ShirtThis is my Halloween costume for the year 2013. It's been in the works for about a year and has taken quite a few man hours to create. The screen is 14 by 15 pixelspretty low resolution but it can still do some fun things. It is physically flexible in all directions, although it cannot be folded without damage. It has a controller consistinof a single button and slide pot, connected to a pro mega via USB. To keep it alive for a long time it employs two monstrous 2200 mAh batteries wired in series to get necessary voltage, and then a 5 Volt regulator to make it usable. All the electronics are place in pockets on the inside of the shirt so they can be removed and so the scan be washed.

    It plays a functional game of pong. It first graces one with the words "PONG PLAY" in lovely blue lettering using a modified version of the Tom Thumb font (can be fouat http://robey.lag.net/2010/01/23/tiny-monospace-font.html). After five seconds the option can be given to press the button to move on, or to not press the button andleave a perfectly good experience behind. When one chooses to press the button, the game begins. A red paddle on the right is the computer paddle and the greenpaddle on the right is the player paddle, which is controlled by the slide pot to move up and down. The ball bounces around as each side tries to score a point. The placan hit the ball with the edge of their paddle to speed it up (a nice feature) while the computer cannot do this, and instead ends up being stuck with moving slightly slothan the ball. When a point is scored a pixel changes to white on the scoring sides paddle. It counts in binary from the bottom. where green or red is zero and white is21 is the score to win (or lose depending on who get's 21 points) and so when the player paddle reads 10101, the "YOU WIN" text is displayed. Once again in modifieTom Thumb. The same happens but with "YOU LOSE" displayed instead. After a win or loss the game restarts to the point right after Pong Play. To restart entirely threstart button on the "Magic Box", also known as the-box-with-all-the-electronics-except-the-screen, is pressed.

    Image Notes

    1. Want to play?

    Image Notes

    1. Pong Play!

    http://www.zazzle.com/40wattsolderingiron*http://member/TheGreatS/http://member/TheGreatS/
  • 8/10/2019 Pong Playing Flexible Screen on a Shirt

    3/38

    http://www.instructables.com/id/Pong-Playing-Flexible-Screen-on-a-Shirt/

    Image Notes1. This is the face of concentration

    Image Notes1. This is what it looks like outside the shirt.

    Step 1:Materials and ToolsThings marked with a * are optional but recommend

    And so in no particular order...

    Materials:4 Yards of Adafruit Neopixle 30 pixle per meter strip1 T-shirt*1 pair of Suspenders1/2 yard of fabric will be more than enough (Non stretchy weave is preferred)6 foot USB A male to USB B male cable1 USB A female connector3 2 pin JST female connectors4 2 pin JST male wiresbattery charger2 6600 mAh batteries1 Arcade style Button1 arduino pro-mega1 FTDI header1 USB B female connector with breakout board1 on/off switch (toggle)1 reset switch (toggle or momentary)

    1 slide potentiometer*1 slide pot knob1 high amp connector pair*1 project case1 5V 3+ amp voltage regulatora small bit of plasticsome soldersome wiresome thread*some hot glue*some elasticsome time (Maybe a little bit more than "some")some perseverance (You will probably need quite a bit of this actualy)some heat shrink tubing or electrical tapesome super gluesome iron on backing

  • 8/10/2019 Pong Playing Flexible Screen on a Shirt

    4/38

    http://www.instructables.com/id/Pong-Playing-Flexible-Screen-on-a-Shirt/

    Tools*Helping HandsNormal Hands (or someone with access to them)Soldering Iron*Hot Glue GunDremel or SandpaperChiselWire StrippersWire CuttersStaple GunScrew DriverSaw

    PinsSewing MachineFabric Scisors

    Image Notes1. Didn't end up using2. Didn't end up using3. 4 JST wire connectors4. Battery Charger5. Batteries6. Arduino Pro Mega

    7. FTDI programmer8. 3 JST female connectors9. USB A female10. Button11. 6 Foot USB male A to USB male B cable12. Slide Potentiometer13. USB B female connector with Breakout board14. Two on off switches15. Slide pot knob16. High amp power connectors17. Project Box. Hooray recycling!18. Another Connector

    Image Notes1. 4 meters of Adafruit Neopixle Strip

    Step 2:Cut the LED Strip Into Smaller StripsUse you're preferred cutting utensil and cut the strip into 14 segments, each 15 pixels long.Cut only between the copper traces, labeled something like "DO" "DIN" "+5and "GND". If it is already soldered over the copper their just cut right through. Try not to cut too much into the exposed copper but if you nick it a little that is just fine.Once all 14 of the strips have been cut, trim a little bit of the rubber off each end to get it out of the way for soldering the strips.

  • 8/10/2019 Pong Playing Flexible Screen on a Shirt

    5/38

    http://www.instructables.com/id/Pong-Playing-Flexible-Screen-on-a-Shirt/

    Image Notes1. Snip Snip Snip! Be sure it's between the copper traces.

    Image Notes1. Lots of strips2. What to do with the leftovers?

    Image Notes1. Lining it all up

    Step 3:Soldering the Screen TogetherTake the wire and cut it into about 3.5 inch (9 cm) segments. In my case I have three different colors to make it easier to keep straight when soldering, but one colorwould work just fine. You will need about 40 of these little guys, but cut a couple more just in case.

    Once You have finished cutting the wire, strip and tin the ends (If you have soldering experience you can skip to the next paragraph), meaning after you remove the litbit of plastic put some solder on the ends of each wire. Don't heat the solder and try to move to to the wire, heat with you're soldering iron from the bottom of the coppeand put the solder on the top. Be patient and wait for the hot wire to melt the solder. It is tempting to tough the soldering iron to the solder to get it started (My impatienand I know exactly how you feel) but the solder won't stick as well. Do the same for the exposed copper traces on each end of the strip sections. If it already has soldedon't worry about it. For the strip you may want to build up a little mound to make it easier later. When working with the strip, do it quickly, and try to not spend to muchtime applying heat to the strip. Only do what you need to do to melt the solder onto the trace.

    Solder a wire on each trace to the end of the first strip (The first strip being the one with the wires and connector, solder it to the exposed end). If you look at the strip ywill see little arrows on i t going up to the end where you soldered the wire. Take another strip so that the arrows are pointing the opposite direction, and solder the wirecoming from the GND trace to the GND trace of the other, the +5V to the +5V and so on. Repeat this making sure the arrows switch directions after every section so thif you were to follow them it would zig zag up and down, and that it could be stretched out to on long strip in the end.

    Once all 14 strips have been soldered, lay them out and line then up so the LED's form a grid. Then keep them together using a method that can be removed laterwithout damage to the strip. I used scotch tape. It's sticky enough to keep everything together but not so sticky as to leave a residue. I do not recommend anything topermanent, like staples or duct tape.

    Once everything has been taped together solder a wire from the strip on the bottom +5V to the one immediately next to it. Repeat until the the entire bottom has thepower taps going all the way across. This is so the screen doesn't dim as the line of LEDs progress.

  • 8/10/2019 Pong Playing Flexible Screen on a Shirt

    6/38

    http://www.instructables.com/id/Pong-Playing-Flexible-Screen-on-a-Shirt/

    Image Notes1. Cut and stripped, waiting patiently to be tinned

    Image Notes1. Lots of wire2. Lots of wire

    Image Notes1. Almost 3.5 inches (little under 9 cm)

    Image Notes1. Prepairing for soldering

    Image Notes1. Note the lables

    Image Notes1. Prep with some solder beads

  • 8/10/2019 Pong Playing Flexible Screen on a Shirt

    7/38

    http://www.instructables.com/id/Pong-Playing-Flexible-Screen-on-a-Shirt/

    Image Notes1. Soldered. This should make you feel better about your soldering jobs.

    Image Notes1. Soldered to the next strip over, minding the labels.2. Coming in3. Going out

    Image Notes1. Repeat

    Image Notes1. Ugg, this took a while and was so redundant.

    Image Notes1. Like vines in a jungle

    Image Notes1. Laying them out to make sure it fits

  • 8/10/2019 Pong Playing Flexible Screen on a Shirt

    8/38

    http://www.instructables.com/id/Pong-Playing-Flexible-Screen-on-a-Shirt/

    Image Notes1. Using tape to hold it all together.

    Image Notes1. Continuing with the tape...

    Image Notes1. Make sure they line up2. Make sure it lines up

    Image Notes1. There we go, a large mass of expensive LEDs and cheep scotch tape

    Image Notes1. Voltage taps so that the lights don't dim as the strip progresses.

  • 8/10/2019 Pong Playing Flexible Screen on a Shirt

    9/38

  • 8/10/2019 Pong Playing Flexible Screen on a Shirt

    10/38

  • 8/10/2019 Pong Playing Flexible Screen on a Shirt

    11/38

    http://www.instructables.com/id/Pong-Playing-Flexible-Screen-on-a-Shirt/

    Image Notes1. The fail corner.2. Don't pay too much attention to the crazy wiring, much of it ended up notbeing used.

    Image Notes1. Heat shrink tubing to keep the pins from shorting. I sadly messed up thecommon protocol for ground and power, but who said anything about followingprotocol in this project! We aren't trying to plug this into a computer!

    Image Notes1. Soldered the pins into the BOB.

    2. Preparing to solder the other wires in, this time following protocol, that willmake my life more difficult in the future...

    Image Notes1. soldered and clipped short

    Image Notes1. Heat Shrink Tubing slid over...

    Image Notes1. And shrunk. My camera wouldn't focus for me here, and for that I apologize.

  • 8/10/2019 Pong Playing Flexible Screen on a Shirt

    12/38

    http://www.instructables.com/id/Pong-Playing-Flexible-Screen-on-a-Shirt/

    Image Notes1. Shrunk!

    Image Notes1. It's so pretty :)

    Image Notes1. Tape to keep the wires from sliding out.

    Image Notes1. There are the wires coming out the other end!

    Image Notes1. Tape to keep it from flopping all over the place.

    Image Notes1. This is the power supply I ended up using.2. Battery connectors3. reset switch. I found out a little while later this was a "normally on" momentaryswitch. Microwave parts to the rescue!

  • 8/10/2019 Pong Playing Flexible Screen on a Shirt

    13/38

    http://www.instructables.com/id/Pong-Playing-Flexible-Screen-on-a-Shirt/

    4. On/Off switch5. Not the final position, It worked out better on the top of the box.6. Here is the mega!

    Step 5:ControllerFirst is choosing the right shape to start off with. It all depends on how you want the controller structured. I wanted more of a flat controller so I got a piece of 3 1/2" by3/4" plank. arrange the parts in a way that seems fitting and comfortable to work with. Use a french curve, compass, triangle, and straight edge to draw on where all thpieces should go. Cut the basic outline out using the cutting tool of you're choice. A ban saw would be best but I used a coping saw, which worked just fine. Sand dowthe edges to make them smoothly transition, then sand down the corners to make it more comfortable.

    Drill out the hole for the switch, then sand,chisel, and/or Dremel out any part on the bottom that will make it fit. Try not to do anything with the top and only sand out whyou need to be able to fit it in by twisting, angling, or whatever else to get it to go in. Once it is in attach it with the plastic nut and attach the switch. Drill out the area fothe potentiometer knob to fit through and chisel out an area so it can sink in and fit all the way through. Drill out some holes so a screw can hold it in.

    Bend in the little pieces of the USB A connector that make it's general width increase a little (look at the pictures). Chisel out a portion for the connector, progressivelychecking to make sure the connector fits. Super glue the connector into it's slot. Take a l ittle piece of plastic and cut it into a shape that will fit over the connector (lookthe pictures), and then staple it to the wood. Cut off any pieces that may get in the way. Screw in potentiometer and attach the knob.

    Solder the positive wire to one of the ends of the potentiometer (not the variable portion) and the negative wire to the opposite end. Solder the D- pin to the variable pion the pot. Solder a wire from the pin on the pot with the positive wire to one of the pins on the button. Solder D+ to the other pin on the button. Trim the spare wire aninsulate the pieces that need it.

    Image Notes1. Easily cuttable wood, with all the marks.

    Image Notes1. This is how my hand will fit on the controler, you can see how the button is righunder my thumb.

    Image Notes1. This is how my hand will fit to hold the Pot knob.

    Image Notes1. Cut a line tangent to the curve.2. Cut a line tanget to the curve.

  • 8/10/2019 Pong Playing Flexible Screen on a Shirt

    14/38

    http://www.instructables.com/id/Pong-Playing-Flexible-Screen-on-a-Shirt/

    Image Notes1. Keep going around...

    Image Notes1. Sand it down to make the curve smooth. This wood is soft so it's pretty easy.

    Image Notes1. All the edges are smooth, including the top to side edges not just the side toside edge.2. Starter hole3. Little rougher in some places.

    Image Notes1. Drilled out.

    Image Notes1. Sandint to make it smooth

    Image Notes1. Chiseling out certain parts so the button can fit through the hole.

  • 8/10/2019 Pong Playing Flexible Screen on a Shirt

    15/38

    http://www.instructables.com/id/Pong-Playing-Flexible-Screen-on-a-Shirt/

    Image Notes1. I got impatant and switched to a dremel.

    Image Notes1. It fits!2. I'll use this part as a handle-ish thing.

    Image Notes1. Really rough, I should have taken more time to make it look nicer.2. Hole for screw3. Hole for screw

    Image Notes1. Chiseling out this part so the pot sinks in a little.

  • 8/10/2019 Pong Playing Flexible Screen on a Shirt

    16/38

  • 8/10/2019 Pong Playing Flexible Screen on a Shirt

    17/38

    http://www.instructables.com/id/Pong-Playing-Flexible-Screen-on-a-Shirt/

    1. Heat shrink tubing to keep the pins from shorting. I sadly messed up thecommon protocol for ground and power, but who said anything about followingprotocol in this project! We aren't trying to plug this into a computer!

  • 8/10/2019 Pong Playing Flexible Screen on a Shirt

    18/38

    http://www.instructables.com/id/Pong-Playing-Flexible-Screen-on-a-Shirt/

    Step 6:ShirtFind a comfortable shirt that will let the light through. I chose this basic white T-shirt. It doesn't really matter the color or style as long as the light can be seen shiningthrough from the inside. However I do not recommend graphics on the front. Lay out everything on the shirt to help you decide where you want it and use an erasablemarking tool to draw it on. I (meaning some people I know) have a pencil meant for marking fabrics which washes out easily.

    Measure the size of the batteries, controller case, and screen and cut out pieces of paper to match. Then pin the paper to a piece of non-stretchy fabric. A weave workwell for this. Then cut out rectangle leaving about a quarter inch for a seam all the way around. Then using the piece of paper as a guide iron the folds into the fabric. Nthe paper can be removed. On the part of the pocket that will be the top fold it over it's self three times. Iron and pin it to keep it in place. Sew a seem all the way alongthe middle of the fold. Now take the corner and fold it so the un-sewn edges perpendicular to each other are parallel and sew a seem along the ironed crease closest tthe corner (The pictures really help). Do this for the other corner as well.

    If perchance you will have a toggle switch coming out of a pocket, sew a button hole at the base of the pocket where the switch touches. Then sew a button hole and cout the middle portion. I can't really give detailed instructions because I had a cool tool to make button holes. Just be sure you make the holes before the pocket is sewon.

    Take some pins and poke them through the shirt at the corners of the markings for the pocket. Take the pocket and put each corner at a pin (on the inside of the shirt)leaving a quarter inch for the seam, and pin it to the shirt. After the pocket has been pinned. remove the pins not holding the pocket in and sew the pocket to the shirt.Repeat for all the pockets. For the large pocket holding the screen leave a gap for the wires at the bottom of the pocket.

    To put a hole in the shirt mark the place and take an iron on backing (with the shinier part on the fabric) and iron it on. Then, for a small hole (like what I used for thetoggle switch), make a button hole. For a larger hole, mark the outline and use a zigzag stitch along the line (or curve or what-have you) and cut out the middle part.

    If you want you can use suspenders to hold the weight of the pockets, the two clips holding onto the pockets on the front and the back clip onto the pants. I also got a sleeve of fabric sewn over the parts of the suspenders that will be touching my skin. Two shirts can get a little too hot so I opted out and used the little fabric sleeve.

    Image Notes

    1. My shirt of choice.2. My face

    Image Notes

    1. You can sort of see the drawings on it.

  • 8/10/2019 Pong Playing Flexible Screen on a Shirt

    19/38

    http://www.instructables.com/id/Pong-Playing-Flexible-Screen-on-a-Shirt/

    Image Notes1. The fabric I will be making the pockets out of.

    Image Notes1. Pining to make sure it says in place.

    Image Notes1. Cut with a seem allowance.

    Image Notes1. Finished cutting. Note the extra fabric around the edges to allow for theseems

    Image Notes1. Iron the seam all the way around.

    Image Notes1. Ironing the edges

  • 8/10/2019 Pong Playing Flexible Screen on a Shirt

    20/38

    http://www.instructables.com/id/Pong-Playing-Flexible-Screen-on-a-Shirt/

    Image Notes1. This is the top and will be sew this way to avoid fraying.

    Image Notes1. All the creases are ironed on and the paper is removed

    Image Notes1. Sewing the part all along the edge.

    Image Notes1. and here is the seem.

    Image Notes1. Fold like so.

  • 8/10/2019 Pong Playing Flexible Screen on a Shirt

    21/38

    http://www.instructables.com/id/Pong-Playing-Flexible-Screen-on-a-Shirt/

    Image Notes1. Sew like so.

    Image Notes1. Looks good!

    Image Notes1. A nice corner is formed.

    Image Notes1. A nice corner is formed.

  • 8/10/2019 Pong Playing Flexible Screen on a Shirt

    22/38

    http://www.instructables.com/id/Pong-Playing-Flexible-Screen-on-a-Shirt/

    Image Notes1. Pins to make sure the pocket ends up in the right place.

    Image Notes1. The pins from the other side

    Image Notes1. checking everything to make sure it is all placed correctly.

    Image Notes1. pocket placed and pined.

    Image Notes1. Pinning the pocket to the shirt. Right now you can see the inside of thepocket.

    Image Notes1. Top part of the pocket pinned.

  • 8/10/2019 Pong Playing Flexible Screen on a Shirt

    23/38

    http://www.instructables.com/id/Pong-Playing-Flexible-Screen-on-a-Shirt/

    Image Notes1. Top of the pocket pinned.

    Image Notes1. Putting the corner at the pin.

    Image Notes1. Pinning the corner in

    Image Notes1. Pinned!

    Image Notes1. Sewing everything on.

    Image Notes1. Sew along the line closest to the edge.

  • 8/10/2019 Pong Playing Flexible Screen on a Shirt

    24/38

    http://www.instructables.com/id/Pong-Playing-Flexible-Screen-on-a-Shirt/

    Image Notes1. Coming around a corner.

    Image Notes1. Finished pocket.

    Image Notes1. Pocket from the other side.

    Image Notes1. The shirt is turned inside out.

    Image Notes1. This is where the lines meet

    Image Notes1. ...so a pin is pushed through

  • 8/10/2019 Pong Playing Flexible Screen on a Shirt

    25/38

    http://www.instructables.com/id/Pong-Playing-Flexible-Screen-on-a-Shirt/

    Image Notes1. Pins are placed so that we know where to place the pockets.

    Image Notes1. Put on the crease that shows the place to put the seam

    Image Notes1. The pocket is pinned to the shirt

    Image Notes1. and the pocket is sewn on

    Image Notes1. The place to put the hole so the wires can come out.

    Image Notes1. Sewing on the chest pocket.

  • 8/10/2019 Pong Playing Flexible Screen on a Shirt

    26/38

    http://www.instructables.com/id/Pong-Playing-Flexible-Screen-on-a-Shirt/

    Image Notes1. Keep bunching it up to get to the end.

    Image Notes1. And here is the end!

    Image Notes1. The chest pocket sewn on. It has no third dimension like the other pockets.

    Image Notes1. Here is the pocket from the outside.

    Image Notes1. Iron on backing to prevent the button hole from stretching.

    Image Notes1. Iron it on!

  • 8/10/2019 Pong Playing Flexible Screen on a Shirt

    27/38

  • 8/10/2019 Pong Playing Flexible Screen on a Shirt

    28/38

    http://www.instructables.com/id/Pong-Playing-Flexible-Screen-on-a-Shirt/

    Image Notes1. An itty-bitty one for the switch.

    Image Notes1. Cutting out the center

    Image Notes1. Getting the little bit of un-cut fabric.

    Image Notes1. Marking the place for the hole.

    Image Notes1. Iron on backing

    Image Notes1. Iron it on!

  • 8/10/2019 Pong Playing Flexible Screen on a Shirt

    29/38

    http://www.instructables.com/id/Pong-Playing-Flexible-Screen-on-a-Shirt/

    Image Notes1. Mmmmmmmmm, steamy.

    Image Notes1. Once again on the pocket.

    Image Notes1. Here is the little hole!

    Image Notes1. Cut it out.

    Image Notes1. All the pockets from the inside.

  • 8/10/2019 Pong Playing Flexible Screen on a Shirt

    30/38

    http://www.instructables.com/id/Pong-Playing-Flexible-Screen-on-a-Shirt/

    Image Notes1. All the pockets from the outside.

    Image Notes1. This is the remeasured one we will use.2. A little bit in the wrong place.

    Image Notes1. Getting ready to sew

    Image Notes1. Using a zigzag stitch.

    Image Notes1. There it is. All reinforced.

    Image Notes1. Cutting out the middle part.

  • 8/10/2019 Pong Playing Flexible Screen on a Shirt

    31/38

    http://www.instructables.com/id/Pong-Playing-Flexible-Screen-on-a-Shirt/

    Image Notes1. Cutting... cutting.

    Image Notes1. Last little bit

    Image Notes1. Cloths pin2. Piece of fabric sewn to clips.3. Sleeves to keep it off my skin and make it more comfortable.

    Image Notes1. Clip!

    Image Notes1. Clip!

  • 8/10/2019 Pong Playing Flexible Screen on a Shirt

    32/38

    http://www.instructables.com/id/Pong-Playing-Flexible-Screen-on-a-Shirt/

    Step 7:ProgrammingAnd here is the code. There are a few parts which are well commented but the vast majority is not. If you have questions on different parts you can either give me the number (with #include as line number one) or give me a copy of the line(s) and the function in which it resides (like loop() or compMovePaddle()) and I will do my bestexplain it to you, then add a comment to the code explaining it.

    ////////////////////////////////////////////////////////////Code Start////////////////////////////////////////////////////////////

    #include

    #define PIN 6

    //says which are the input pins for the gameint buttonPin = 40;//dictates the score, kept in a bianary array because it is esier

    int playerScore[5] = {0,0,0,0,0};int compScore[5] = {0,0,0,0,0};//dictates the ball's directionint bvd=0;//0 is down, 1 is upint bhd=0;//0 is right, 1 is left//dictates the balls positionint bvp = 8;int bhp = 6;//checks to see if the ball is in fast modeboolean fast = false;//checks if it is a score.boolean cIsPoint = false;boolean pIsPoint = false;//paddle positionsint cPaddle = 0;int pPaddle = 0;long previousMillis = 0;

    long previousMillisForComp = 0;//set the delay times for fast and slow moving ball the "Int" in normInt and fastInt is for intervalint normInt = 50;int fastInt = 10;//used to check for a win. 1 is player win, -1 in computer win, and 0 is nothing has happend yetint win = 0;//to get rid of a bug. used in the addOne statement and nowhere else.int which = 0;//Thing displayed before start, -1 is an escapeint pongPlay[] = {1,2,3,4,10,11,12,13,16,18,20,27,29,33,34,41,42,61,62,63,70,71,72,76,85,86,88,91,92,94,100,101,102,103,131,132,136,139,144,145,146,147,148,161,162,166,175,183,185,192,194,195,196,197,198,199,204,205,206,207,208,-1};//if you winint youWin[] = {1,2,3,4,5,16,17,18,19,20,27,33,34,39,46,47,48,49,54,55,56,57,58,77,78,79,84,88,91,92,93,94,95,99,103,106,110,114,118,130,131,132,144,145,146,147,151,162,163,168,169,170,177,181,192,193,204,205,206,207,-1};

    //if you loseint youLose[] = {1,3,5,16,17,18,19,20,24,26,28, 31,32,32,33,34,35,39,46,47,48,49,62,65,77,78,79,84,86,88,91,94,99,103,106,110,122,123,124,130,131,132,144,148,152,153,154,162,163,168,169,170,181,192,193,204,205,206,207,208,-1};//sets up the led stripAdafruit_NeoPixel strip = Adafruit_NeoPixel(210, PIN, NEO_RGB + NEO_KHZ800);

    //setting up, turns no pin 40 for input, begins the strip, displays the//message and the shows it.void setup() {pinMode(buttonPin,INPUT);strip.begin();for (int i = 0 ; pongPlay[i]>0 ; i++){strip.setPixelColor(pongPlay[i], strip.Color(0, 0, 255));}strip.show();delay(5000);while (digitalRead(buttonPin) == LOW){//It's a trap!(until the button is pressed.)}}void loop() {clearScreen();//draws the paddles to show the scorefor(int i = 0 ; i < 5 ; i++){if (playerScore[i]==1){strip.setPixelColor(204-i, strip.Color(255, 255, 255));}else if((playerScore[i]==0)){strip.setPixelColor(204-i, strip.Color(0, 255, 0));}if (compScore[i]==1){strip.setPixelColor(5+i, strip.Color(255, 255, 255));}else if((compScore[i]==0)){

  • 8/10/2019 Pong Playing Flexible Screen on a Shirt

    33/38

    http://www.instructables.com/id/Pong-Playing-Flexible-Screen-on-a-Shirt/

    strip.setPixelColor(5+i, strip.Color(255, 0, 0));}}//draws the ball in it's starting positionstrip.setPixelColor(98, strip.Color(255, 255, 255));strip.show();//decides if the ball is going up or going downwhile(pIsPoint == false && cIsPoint == false){clearScreen();unsigned long currentMillis = millis();//assigns the player paddle positionpPaddle=checkPaddlePos();//checks the next positioncheckNext();

    //moving the ballif (fast == false){if(currentMillis - previousMillis > normInt){previousMillis = currentMillis;moveBall();}}else if(fast == true){if(currentMillis - previousMillis > fastInt){previousMillis = currentMillis;moveBall();}}//draw the ballif(bhp%2 != 0){strip.setPixelColor(bhp*15+14-bvp, strip.Color(255, 255, 255));}else if (bhp%2 == 0){strip.setPixelColor(bhp*15+bvp, strip.Color(255, 255, 255));}

    //computer paddle movementcompMovePaddle();//draw's the paddlesdrawPaddles();//actualy put everything up.strip.show();//checking to see if a point has been scoredif (pIsPoint == true){which = 0;bhd=0;addOne();break;}else if(cIsPoint == true){which = 1;bhd=1;addOne();break;

    }}if (win == 1){clearScreen();for (int i = 0 ; youWin[i]>0 ; i++){strip.setPixelColor(youWin[i], strip.Color(255, 0, 0));strip.show();}delay(5000);for (int i = 0; i < 5; i++){playerScore[i] = 0;compScore[i] = 0;}win = 0;}else if (win == -1){clearScreen();for (int i = 0 ; youLose[i]>0 ; i++){strip.setPixelColor(youLose[i], strip.Color(0, 255, 0));

    strip.show();}delay(5000);for (int i = 0; i < 5; i++){playerScore[i] = 0;compScore[i] = 0;}win = 0;}pIsPoint = false;cIsPoint = false;bvp = 8;bhp = 6;bvd=random(0,2);//0 is down, 1 is upfast=false;}

  • 8/10/2019 Pong Playing Flexible Screen on a Shirt

    34/38

    http://www.instructables.com/id/Pong-Playing-Flexible-Screen-on-a-Shirt/

    //The AI for the gamevoid compMovePaddle(){unsigned long currentMillis = millis();if(currentMillis - previousMillisForComp > 51){previousMillisForComp = currentMillis;if (bvp >= 13 & 10-cPaddle 0){cPaddle--;}else if(bvp = 0 && cPaddle < 10){cPaddle++;}else if(bvp-3 > 10-cPaddle & 10-cPaddle >= 0 && cPaddle > 0){cPaddle--;}else if(bvp < 10-cPaddle & 10-cPaddle

  • 8/10/2019 Pong Playing Flexible Screen on a Shirt

    35/38

    http://www.instructables.com/id/Pong-Playing-Flexible-Screen-on-a-Shirt/

    fast = false;}else if(bvp+bvd == 10-cPaddle || bvp+bvd == 10-cPaddle+5){if(bvp != 0 && bvp !=14){if (bvd == 0){bvd=1;}else if(bvd == 1){bvd=0;}bhd=1;}else if (bvp == 0 || bvp == 14){bhd=1;}fast = false;}

    }else if(bhp+bhd==1){//then on the player sideif (bvp >= pPaddle & bvp

  • 8/10/2019 Pong Playing Flexible Screen on a Shirt

    36/38

    http://www.instructables.com/id/Pong-Playing-Flexible-Screen-on-a-Shirt/

    }

    void clearScreen(){for(int i=0; i

  • 8/10/2019 Pong Playing Flexible Screen on a Shirt

    37/38

    http://www.instructables.com/id/Pong-Playing-Flexible-Screen-on-a-Shirt/

    Image Notes1. Want to play?

    Related Instructables

    One ManElectricalParadeHalloween

    Costumeby

    brokenpipe

    Rainbow Mega

    Pong Clockby

    Djandco

    Ping-Pong

    Blinkyby

    DaShroom Arduino Beer

    Pong Arcadeby

    PotNoodle

    Cheap Iron Man(Mark 3)Costume withworkingfaceplate, lights,

    electronicsby

    andyr23511

    LED PongbyChip Fixes

    Advertisements

    Comments

    3 comments Add Comment

    nerd7473says: Nov 5, 2013. 2:12 PM REPvery cool I will have to try something like this

    ecsaul23says: Nov 5, 2013. 10:05 AM REPVery nice! voted

    http://www.instructables.com/id/Pong-Playing-Flexible-Screen-on-a-Shirt/?utm_source=pdf&utm_campaign=comments#DISCUSShttp://www.instructables.com/member/ecsaul23/?utm_source=pdf&utm_campaign=commentshttp://www.instructables.com/member/ecsaul23/?utm_source=pdf&utm_campaign=commentshttp://www.instructables.com/id/Pong-Playing-Flexible-Screen-on-a-Shirt/?utm_source=pdf&utm_campaign=comments#DISCUSShttp://www.instructables.com/member/nerd7473/?utm_source=pdf&utm_campaign=commentshttp://www.instructables.com/member/nerd7473/?utm_source=pdf&utm_campaign=commentshttp://www.instructables.com/id/Pong-Playing-Flexible-Screen-on-a-Shirt/?utm_source=pdf&utm_campaign=comments#commentshttp://www.instructables.com/member/Chip%20Fixes/?utm_source=pdf&utm_campaign=relatedhttp://www.instructables.com/id/LED-Pong/?utm_source=pdf&utm_campaign=relatedhttp://www.instructables.com/id/LED-Pong/?utm_source=pdf&utm_campaign=relatedhttp://www.instructables.com/member/andyr23511/?utm_source=pdf&utm_campaign=relatedhttp://www.instructables.com/id/Cheap-Iron-Man-Mk-III-Suit-with-working-faceplat/?utm_source=pdf&utm_campaign=relatedhttp://www.instructables.com/id/Cheap-Iron-Man-Mk-III-Suit-with-working-faceplat/?utm_source=pdf&utm_campaign=relatedhttp://www.instructables.com/id/Cheap-Iron-Man-Mk-III-Suit-with-working-faceplat/?utm_source=pdf&utm_campaign=relatedhttp://www.instructables.com/id/Cheap-Iron-Man-Mk-III-Suit-with-working-faceplat/?utm_source=pdf&utm_campaign=relatedhttp://www.instructables.com/id/Cheap-Iron-Man-Mk-III-Suit-with-working-faceplat/?utm_source=pdf&utm_campaign=relatedhttp://www.instructables.com/id/Cheap-Iron-Man-Mk-III-Suit-with-working-faceplat/?utm_source=pdf&utm_campaign=relatedhttp://www.instructables.com/id/Cheap-Iron-Man-Mk-III-Suit-with-working-faceplat/?utm_source=pdf&utm_campaign=relatedhttp://www.instructables.com/member/PotNoodle/?utm_source=pdf&utm_campaign=relatedhttp://www.instructables.com/id/Arduino-Beer-Pong-Arcade/?utm_source=pdf&utm_campaign=relatedhttp://www.instructables.com/id/Arduino-Beer-Pong-Arcade/?utm_source=pdf&utm_campaign=relatedhttp://www.instructables.com/id/Arduino-Beer-Pong-Arcade/?utm_source=pdf&utm_campaign=relatedhttp://www.instructables.com/member/DaShroom/?utm_source=pdf&utm_campaign=relatedhttp://www.instructables.com/id/Ping-Pong-Blinky/?utm_source=pdf&utm_campaign=relatedhttp://www.instructables.com/id/Ping-Pong-Blinky/?utm_source=pdf&utm_campaign=relatedhttp://www.instructables.com/id/Ping-Pong-Blinky/?utm_source=pdf&utm_campaign=relatedhttp://www.instructables.com/member/Djandco/?utm_source=pdf&utm_campaign=relatedhttp://www.instructables.com/id/Rainbow-Mega-Pong-Clock/?utm_source=pdf&utm_campaign=relatedhttp://www.instructables.com/id/Rainbow-Mega-Pong-Clock/?utm_source=pdf&utm_campaign=relatedhttp://www.instructables.com/id/Rainbow-Mega-Pong-Clock/?utm_source=pdf&utm_campaign=relatedhttp://www.instructables.com/member/brokenpipe/?utm_source=pdf&utm_campaign=relatedhttp://www.instructables.com/id/One-Man-Electrical-Parade-Halloween-Costume/?utm_source=pdf&utm_campaign=relatedhttp://www.instructables.com/id/One-Man-Electrical-Parade-Halloween-Costume/?utm_source=pdf&utm_campaign=relatedhttp://www.instructables.com/id/One-Man-Electrical-Parade-Halloween-Costume/?utm_source=pdf&utm_campaign=relatedhttp://www.instructables.com/id/One-Man-Electrical-Parade-Halloween-Costume/?utm_source=pdf&utm_campaign=relatedhttp://www.instructables.com/id/One-Man-Electrical-Parade-Halloween-Costume/?utm_source=pdf&utm_campaign=relatedhttp://www.instructables.com/id/One-Man-Electrical-Parade-Halloween-Costume/?utm_source=pdf&utm_campaign=related
  • 8/10/2019 Pong Playing Flexible Screen on a Shirt

    38/38

    TheGreatSsays: Nov 5, 2013. 10:13 AM REPThanks!

    http://www.instructables.com/id/Pong-Playing-Flexible-Screen-on-a-Shirt/?utm_source=pdf&utm_campaign=comments#DISCUSShttp://www.instructables.com/member/TheGreatS/?utm_source=pdf&utm_campaign=commentshttp://www.instructables.com/member/TheGreatS/?utm_source=pdf&utm_campaign=comments