projects:electronics:ptl-ino:phaser

The day I shot the PTL-ino

Let's resurrect the light gun!

Status du project
Date de début 02/2017
Status Work in progress
Initiateur Magnus

The gun is a Master System's Light Phaser.

  • Varying number of flashes: the gun gets more sensitive if it sees a burst of pulses (if it is too many though, it will readjust the background brightness and reject them all)

  • Varying pulse amplitude:

  • Varying pulse length:

tbd

Here a sample to test its functioning. It looks like the blink example, but can be shot. 8-) Unfortuntaly, one needs a very bright LED for this to work. So bright that it will hurt your eye… don't look into it!

phasertest.ino
int triggerPin= 2;
int lightPin  = 3;
int ledPin    =13;
void setup() {
  pinMode(triggerPin,INPUT_PULLUP);
  pinMode(lightPin  ,INPUT_PULLUP);
  pinMode(ledPin    ,OUTPUT      );
}
bool shoot() {
  digitalWrite(ledPin,LOW );
  delayMicroseconds(1000);
  digitalWrite(ledPin,HIGH);
  delayMicroseconds(   4);
  digitalWrite(ledPin,LOW );
  delayMicroseconds(  10);
  bool hit=digitalRead(lightPin)==LOW;
  return hit;
}
unsigned long lastt=0; // for debouncing and single shots
void loop() { // blinky!
  bool hit=false;
  for (int i=0;i<100 && !hit;++i) {
    digitalWrite(ledPin,HIGH);
    if (digitalRead(triggerPin)==LOW) {
      if (millis()-lastt>100) hit=shoot();
      lastt=millis();
    }
    delay(10);
  }
  for (int i=0;i<100 && !hit;++i) {
    digitalWrite(ledPin,LOW);
    if (digitalRead(triggerPin)==LOW) {
      if (millis()-lastt>100) hit=shoot();
      lastt=millis();
    }
    delay(10);
  }
  if (hit) { // die.. ... ......
    for (int i=0;i<20;++i) {
      digitalWrite(ledPin,HIGH);
      delay(50);
      digitalWrite(ledPin,LOW );
      delay(50);
    }
    delay(5000); // resurrect!
  }
}
  • projects/electronics/ptl-ino/phaser.txt
  • Dernière modification: 2017/02/26 22:26
  • de magnustron