Lazer Tag
Shea Marentette
Zach Vakerics
Lazer Tag
SUMMARY
We created a laser tag game using plastic guns, laser pointers, photo resistors, a plastic vest and covers for the photo resistors. When the push button is pressed then the laser shoots for a half second. When you hit one of the three photoresistors, one of the three lights on the vest goes out. When all the lights go out, its game over.
HOW IT WORKS
The project involves 3 LEDs 3 photo resistors, 1 laser, one push button and 3 clear lids. And remember this is per person. How it works is simple, when you push the push button the laser comes on for half a second. There is a plastic cover over two of the photoresistors that spreads out the light when you shoot it, making it easier to hit. Then when shot in one of the targets, a LED turns off. When all three LEDs go out, all the LEDs flash and you lose. The game will the reset itself. You can play indoors or outdoors, because the sensors read the light around it and change the read to work with the current ambient light.
PROBLEMS
We encountered a few problems like just uploading to the board, and also making a battery for it. We had sufficient trouble making the photoresistors work as well. However we were able to overcome these difficulties with the help of Mr.Dickie and just thinking about it. If we had more money we would cover the entire chest plate with sensors and make a counting system that went higher. I also suggest, if you were to think about making this project, to use quality lazers, because the dollar store ones we used died after only a couple of days.
ARDUINO CODE
int led1 = 5;
int led2 = 7;
int led3 = 9;
int T1=0;
int T2=0;
int T3=0;
int targ1 = 2;
int targ2 = 3;
int targ3 = 4;
int val = 0;
int val2 = 0;
int val3 = 0;
int score = 0;
int thresh;
void setup() { // declares all the variables
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
digitalWrite(led1, HIGH);
digitalWrite(led2, HIGH);
digitalWrite(led3, HIGH);
thresh= analogRead(targ1);
Serial.begin (9600); //turns the LEDs on and declares led1-3 as outputs
}
void loop() {
val = analogRead(targ1); // read the value from the sensor
Serial.print ("Value = "); // report the text "Value = "
Serial.println (val);
if (val < .5*thresh) // reads the ambient light and sets it as the base light
{
T1 = 1;
digitalWrite(led1, LOW); // turns the LED off
}
val2 = analogRead(targ2); // read the value from the sensor
Serial.print ("Value = "); // report the text "Value = "
Serial.println (val2);
if (val2 < .5*thresh)
{
T2 = 1;
digitalWrite(led2, LOW);
}
val3 = analogRead(targ3); // read the value from the sensor
Serial.print ("Value = "); // report the text "Value = "
Serial.println (val3);
if (val3 < .5*thresh)
{
T3 = 1;
digitalWrite(led3, LOW);
}
score = T1+T2+T3; // totals the three sensors and scores it.
if (score == 3)
{ digitalWrite(led1, HIGH);
digitalWrite(led2, HIGH);
digitalWrite(led3, HIGH);
delay(500);
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
delay(500);
digitalWrite(led1, HIGH);
digitalWrite(led2, HIGH);
digitalWrite(led3, HIGH);
delay(500);
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
delay(1500); // Flashes the LEDs when all three sensors are tripped
T1 = 0;
T2 = 0;
T3 = 0;
digitalWrite(led1, HIGH);
digitalWrite(led2, HIGH);
digitalWrite(led3, HIGH); // resets the game
}
}
CIRCUTRY
PICTURES