nithishmurugavenkateshmaker
Published

Laser Tag using Photoresistor

Ever wanted to have your own laser tag game, now here's your chance!

BeginnerFull instructions provided1,310
Laser Tag using Photoresistor

Things used in this project

Story

Read more

Code

Photoresistor

C/C++
Photoresistor has three pins , VCC, GND and OUTPUT
In this project, There are two parts, The Light Emitting Diode or LED circuit and Photoresistor circuit with a LED
THE CONNECTIONS :
For LED circuit (Arduino not needed);
LED(positive) - switch
LED(negative) - Battery(negative)
Switch - Battery(positive)

For Photoresistor;
LED(positive) - pin 13
LED(negative) - GND
Photoresistor(VCC) - 5v pin
Photoresistor(GND) - GND
Photoresistor(Output) - A0

Instead of the LED circuit, I am using a toy LED gun
int led = 13;
void setup() {
  Serial.begin(9600);
  Serial.println("This a virtual gun shooting module");
  Serial.println("Initializing VGSM");
  delay(7000);
  Serial.println("player one ready");
  pinMode(led, OUTPUT);
}


void loop() {
  
  int value = analogRead(A0);
  
  if (value <= 31){
    Serial.println("Player one is down");
    digitalWrite(led, HIGH);
  }
    else {
      Serial.println("Player one is active");
      Serial.println(value);
      delay(150);
      digitalWrite(led, LOW);
    }
  
}

Code schematics

C/C++
//Author: Nithish Murugavenkatesh

int led = 13;
void setup() {
  Serial.begin(9600);
  Serial.println("This a virtual gun shooting module");
  Serial.println("Initializing VGSM");
  delay(9000);
  Serial.println("player one ready");
  pinMode(led, OUTPUT);
}


void loop() {
  
  int value = analogRead(A0);
  
  if (value <= 31){
    Serial.println("Player one is down");
    digitalWrite(led, HIGH);
  }
    else {
      Serial.println("Player one is active");
      Serial.println(value);
      delay(150);
      digitalWrite(led, LOW);
    }
  
}

Credits

nithishmurugavenkateshmaker
4 projects • 2 followers

Comments