Arduino Avengers: Laser Tag
by jacobrichman in Craft > Costumes & Cosplay
5104 Views, 25 Favorites, 0 Comments
Arduino Avengers: Laser Tag
Have you ever wanted to become a superhero? This Arduino Laser tag project immerses you in game where you can act as a superhero firing at your opponents to victory.
Using a flex sensor, you can reenact the famous Spiderman web shooter and Iron Man repulsor beam. You are also able to keep track of your ammunition and life count on the LCD screen on your wrist. Every time you’re hit, you can feel the impact through a vibration motor. When you win, the speaker will play your theme song.
This project won best laser tag project (out of 12) at Binghamton University's Freshman Engineering Design Arduino Exposition.
Parts
Everything but the tools were bought on Amazon and the total project was $140 (Arduinos were knockoffs).
Electronics
- Arduino Uno (x2)
- Protoboard (x2)
- Flex Sensor (x2)
- I2C LCD Display (x2)
- IR Emitter (x2)
- IR Receiver (x4) - 3 prong NOT 2 prong
- Vibration Motor (x2)
- Enclosed Piezo (x2)
Costume
- Spiderman Shirt
- Spiderman Mask
- Spiderman Gloves
- Iron Man Shirt
- Iron Man Mask
- Iron Man Gloves
Other
- Arduino Housing (x2)
- Latex Gloves
- Lots of wire
Tools
- Soldering iron and solder
- Breadboard and Jumper Wires for prototyping
- Wire Strippers
Prototyping
I would suggest first testing each component (Piezo, Flex Sensor, LCD, Vibration IR Emitter and Receiver) separately before you begin. There's plenty of sample code all over the internet to test each.
Wire everything to the breadboard as you see in the diagram above.
Note:
- The I2C LCD only has 4 pins, so wire accordingly
- The vibration motor has a 3V max, so wire it to the 3V pin and ground it to pin 13 (this means the code to control it is reversed)
- The flex sensor is denoted as a potentiometer in the schematic
Code
#include <IRremote.h> #include <Wire.h> #include <LiquidCrystal_I2C.h> #include "pitches.h" LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); int RECV_PIN = 11; int RECV_PIN2 = 10; IRrecv irrecv(RECV_PIN); IRrecv irrecv2(RECV_PIN2); decode_results results; IRsend irsend; const int flexSensor = A0; int lastFlexNum = 0; int lives = 5; int ammo = 50; int buzzerPin = 13; String superhero = "Spiderman"; //String superhero = "Iron Man"; void setup(){ digitalWrite(buzzerPin, HIGH); pinMode(buzzerPin,OUTPUT); irrecv.enableIRIn(); irrecv2.enableIRIn(); lcd.begin(16,2); lcd.backlight(); lcd.clear(); updateLCD(); Serial.begin(9600); } void loop(){ int flexVal = analogRead(flexSensor); if((lastFlexNum>350)&&((flexVal>100)&&(flexVal<350))){ if(ammo>0){ irsend.sendSony(0xa90, 12); irrecv.enableIRIn(); irrecv2.enableIRIn(); ammo = ammo - 1; updateLCD(); delay(3000); } } lastFlexNum = flexVal; if (irrecv.decode(&results)) { if ((results.value == 4045713590)||(results.value == 316007967)||(results.value == 2704)){ lives = lives - 1; lcd.setCursor(0,1); lcd.print(" "); lcd.setCursor(1,1); lcd.print(">Front Shot<"); digitalWrite(buzzerPin, LOW); delay(2000); digitalWrite(buzzerPin, HIGH); updateLCD(); } irrecv.resume(); // Receive the next value } if (irrecv2.decode(&results)) { if ((results.value == 4045713590)||(results.value == 316007967)||(results.value == 2704)){ lives = lives - 1; lcd.setCursor(0,1); lcd.print(" "); lcd.setCursor(1,1); lcd.print(">Back Shot<"); digitalWrite(buzzerPin, LOW); delay(2000); digitalWrite(buzzerPin, HIGH); updateLCD(); } irrecv2.resume(); // Receive the next value } delay(100); } void updateLCD(){ lcd.clear(); if(superhero == "Spiderman"){ lcd.setCursor(4,0); lcd.print("Spiderman"); } else{ lcd.setCursor(4,0); lcd.print("Iron Man"); } if (lives == 0){ lcd.setCursor(2,1); lcd.print("You Died :("); playMusic(); lcd.setCursor(0,1); lcd.print(" "); lives = 5; } lcd.setCursor(0,1); lcd.print("Lives:"); lcd.setCursor(6,1); lcd.print(lives); lcd.setCursor(9,1); lcd.print("Ammo:"); lcd.setCursor(14,1); lcd.print(ammo); } void playMusic(){ if(superhero == "Spiderman"){ int melody[] = {NOTE_D4, NOTE_F4, NOTE_A4, 0, NOTE_GS4, NOTE_F4, NOTE_D4, 0, NOTE_D4, NOTE_F4, NOTE_A4, NOTE_A4, NOTE_GS4, NOTE_F4, NOTE_D4,0, NOTE_G4, NOTE_AS4, NOTE_D5, 0, NOTE_C5, NOTE_AS4, NOTE_G4, 0, NOTE_D4, NOTE_F4, NOTE_A4, 0, NOTE_GS4, NOTE_F4, NOTE_D4, NOTE_AS4, NOTE_G4, NOTE_G4, NOTE_F4, NOTE_G4, NOTE_F4, NOTE_D4}; int noteDurations[] = {4, 8, 4, 4, 4, 8, 4, 4, 4, 8, 4, 4, 4, 8, 4, 4, 4, 8, 4, 4, 4, 8, 4, 4, 4, 8, 4, 4, 4, 8, 4, 8, 2, 4, 6, 4, 6, 2}; for (int thisNote = 0; thisNote < 38; thisNote++) { int noteDuration = 1200 / noteDurations[thisNote]; tone(8, melody[thisNote], noteDuration); int pauseBetweenNotes = noteDuration * 1.30; delay(pauseBetweenNotes); noTone(8); } } else{ int melody[] = {NOTE_B3, NOTE_D4, NOTE_D4, NOTE_E4, NOTE_E4, NOTE_G4, NOTE_FS4, NOTE_G4, NOTE_FS4, NOTE_G4, NOTE_D4, NOTE_D4, NOTE_E4, NOTE_E4, NOTE_B5, NOTE_D5, NOTE_D5, NOTE_E5, NOTE_E5, NOTE_G5, NOTE_FS5, NOTE_G5, NOTE_FS5, NOTE_G5, NOTE_D5, NOTE_D5, NOTE_E5, NOTE_E5}; int noteDurations[] = {4, 4, 8, 8, 4, 16, 16, 16, 16, 8, 8, 8, 8, 4, 4, 4, 8, 8, 4, 16, 16, 16, 16, 8, 8, 8, 8, 4}; for (int thisNote = 0; thisNote < 29; thisNote++) { int noteDuration = 1200 / noteDurations[thisNote]; tone(8, melody[thisNote], noteDuration); int pauseBetweenNotes = noteDuration * 1.30; delay(pauseBetweenNotes); noTone(8); } } }
Soldering
Solder wires and components to a protoboard the same way you did with a breadboard. This makes your project compact and ensures that all the wires stay connected.
Build Housing and Attach to Costume
- Enclose the Arduino in a box or some sort of casing (it can be as simple as a decorated envelope which is what was used in this project)
- Attach a battery pack to the side which will also act as the Arduino power button.
- Sew the LCD to Latex glove and wire it to the Arduino
- Put the superhero glove over the latex glove and put on the rest of the costume
- Wire the IR emitter to the bottom of the superhero glove (to aim and shoot IR beam)
- Wire the IR receivers through the costume (one to front and one to back)
Playing Instructions
You're all done!!
- The goal of the game is to hit the other player’s sensor 5 times
- When a person wants to fire a shot, they must bend the flex sensor which causes the IR emitter to send a signal
- Players must aim the emitter at the receivers embedded within their opponent’s shirt
- Each time a person is hit, their life count decreases by one
- The game continues until one person has lost all of their lives (their super hero’s theme song will play indicating they lost)