New version of the software + a fire module selection option. Regular and Stun laser gun. Everything working at 5V.
/*
Sketch to control a V Visitor laser gun prop.
Created by Diego J. Arevalo, November 26, 2012.
Released into the public domain.
*/
#include <Wtv020sd16p.h>
#include <Pam8803.h>
#include "LaserGunFactory.h"
const int WTV_RESET_PIN = 2;
const int WTV_CLOCK_PIN = 3;
const int WTV_DATA_PIN = 4;
const int WTV_BUSY_PIN = 5;
const int ANALOG_LED_PIN= 6;
const int TRIGGER_PIN = 7;
const int FIRE_MODE_PIN = 11;
const LaserGunType LASER_GUN_TYPE = VVisitorLaserGun;
const int AMP_VOLUME_DOWN_PIN = 8;
const int AMP_VOLUME_UP_PIN = 9;
const int AMP_RESET_PIN = 10;
static Pam8803 *pam8803 = NULL;
static LaserGun *laserGun = NULL;
static LaserGunFactoryParameters laserGunFactoryParameters;
void setup() {
pam8803 = new Pam8803(AMP_RESET_PIN, AMP_VOLUME_UP_PIN, AMP_VOLUME_DOWN_PIN);
pam8803 -> reset();
pam8803 -> setVolume(50);
laserGunFactoryParameters.setWtvResetPin(WTV_RESET_PIN);
laserGunFactoryParameters.setWtvClockPin(WTV_CLOCK_PIN);
laserGunFactoryParameters.setWtvDataPin(WTV_DATA_PIN);
laserGunFactoryParameters.setWtvBusyPin(WTV_BUSY_PIN);
laserGunFactoryParameters.setAnalogLedPin(ANALOG_LED_PIN);
laserGunFactoryParameters.setTriggerPin(TRIGGER_PIN);
laserGunFactoryParameters.setFireModePin(FIRE_MODE_PIN);
laserGunFactoryParameters.setLaserGunType(LASER_GUN_TYPE);
laserGun = LaserGunFactory::getLaserGun(laserGunFactoryParameters);
}
void loop() {
laserGun -> senseSwitches();
}
Attached the whole Sketch in this post. Enjoy.