Working on a somewhat unique project I could use a second pair of eyes on… Long story short, I’m 3d printing Blasters to use as laser tag guns with Proffie steroids.
I developed a Proffie config for use as the laser tag controller and reciever. But could use some guidence from the Proffie experts.
MTFBWY
// Gun config for laser tag
// Pin Definitions
#define PRIMARY_BUTTON_PIN 2 // Pin for primary button
#define OVERHEAT_BUTTON_PIN 3 // Pin for overheat button
#define LASER_PIN 9 // Pin for IR laser
#define LED_PIN 10 // Pin for high power LED
// Sound bank settings
#define NUM_BANKS 1
const uint8_t bank1_pins[] = {11}; // Sound effect pin
const uint8_t bank1_varnums[] = {1}; // Sound effect variable
// Sound Effects
const uint16_t sound_fire[] = {100, 880, 100, 880};
// Variables
uint8_t overheat_count; // Tracks number of shots fired
uint8_t overheat_max; // Maximum number of shots before overheat
bool is_overheated; // Whether the gun is currently overheated
unsigned long overheat_start; // Time when overheat starts
unsigned long overheat_duration; // How long overheat lasts
// Set up function
void setup() {
// Set initial values for overheat variables
overheat_count = 0;
overheat_max = 10;
overheat_start = 0;
overheat_duration = 3000;
is_overheated = false;
// Set button pins as inputs
pinMode(PRIMARY_BUTTON_PIN, INPUT);
pinMode(OVERHEAT_BUTTON_PIN, INPUT);
// Set laser and LED pins as outputs
pinMode(LASER_PIN, OUTPUT);
pinMode(LED_PIN, OUTPUT);
}
// Loop function
void loop() {
// Check if primary button is pressed
if (digitalRead(PRIMARY_BUTTON_PIN) == LOW) {
// Check if gun is not overheated
if (!is_overheated) {
// Fire laser and LED
digitalWrite(LASER_PIN, HIGH);
digitalWrite(LED_PIN, HIGH);
// Play fire sound effect
play_sound(1, bank1_pins, bank1_varnums);
// Increment overheat count
overheat_count++;
// Check if overheat count is at maximum
if (overheat_count >= overheat_max) {
// Set overheat start time
overheat_start = millis();
// Set is_overheated to true
is_overheated = true;
}
}
// Wait for button to be released
while(digitalRead(PRIMARY_BUTTON_PIN) == LOW);
}
else {
// Turn off laser and LED
digitalWrite(LASER_PIN, LOW);
digitalWrite(LED_PIN, LOW);
}
// Check if overheat button is pressed
if (digitalRead(OVERHEAT_BUTTON_PIN
// Receiver config for laser tag
// Number of sound banks
#define NUM_BANKS 1
// Sound bank settings
const uint8_t bank1_pins[] = {11}; // LED pin
const uint8_t bank1_varnums[] = {1}; // LED pattern variable
// LED patterns
const uint32_t pattern_hit[] = {CRGB::Green, CRGB::Green, CRGB::Green, CRGB::Green, CRGB::Green, CRGB::Green, CRGB::Green, CRGB::Green, CRGB::Green, CRGB::Green, CRGB::Green, CRGB::Green, CRGB::Green, CRGB::Green, CRGB::Green, CRGB::Green, CRGB::Green, CRGB::Green, CRGB::Green, CRGB::Green, CRGB::Green, CRGB::Green, CRGB::Green, CRGB::Green, CRGB::Green, CRGB::Green, CRGB::Green, CRGB::Green};
const uint32_t pattern_no_hit[] = {CRGB::Black, CRGB::Black, CRGB::Black, CRGB::Black, CRGB::Black, CRGB::Black, CRGB::Black, CRGB::Black, CRGB::Black, CRGB::Black, CRGB::Black, CRGB::Black, CRGB::Black, CRGB::Black, CRGB::Black, CRGB::Black, CRGB::Black, CRGB::Black, CRGB::Black, CRGB::Black, CRGB::Black, CRGB::Black, CRGB::Black, CRGB::Black, CRGB::Black, CRGB::Black, CRGB::Black, CRGB::Black};
// Variables
uint8_t hit_count;
// Set up function
void setup() {
// Set initial value of hit_count to 0
hit_count = 0;
}
// Loop function
void loop() {
// Check if IR signal is received
if (irrecv.decode(&results)) {
// Increment hit_count
hit_count++;
// Display hit pattern on LED
set_pattern(1, pattern_hit, sizeof(pattern_hit));
// Play sound effect
play_sound(1, bank1_pins, bank1_varnums);
delay(1000); // Wait for 1 second
}
else {
// Display no hit pattern on LED
set_pattern(1, pattern_no_hit, sizeof(pattern_no_hit));
}
irrecv.resume(); // Receive the next value
}