Homework - Joshua Skirbunt

Hi all!
Ok, here is the squirt gun I have to work with taken apart:


So, my initial idea here, is to make the orange water reservoir a frosted clear piece, and have it light up from the inside and get increasingly brighter and have a louder "charging hum" with each pump, then a flash "discharge" light at the barrel opening and firing sound effect when the trigger is pressed, and the reservoir would go dark again.
If not too daunting, I would also like to have the four U shaped pieces on the back have a button or two that could change the "mode" of the gun, going from a charging rifle, to some kind of automatic pulse rifle, that would be shown by some kind of screen/element in the small oval above them, the circular thing near the bottom as some type of information read out, with the ring around it lighting up, and an "ammo counter" displayed where the sticker currently is.

Here is the list of things I think I need when it's broken down:

Gun dimensions
15 3/4 long
2" circle thingy - lcd number read out screen, led ring to go around it
2 1/4" small oval thingy- lcd character read out screen
4 1/2" big oval thingy - possibly cut shapes and light from inside with amber led's
4 small u shapes 3/4" wide each - push buttons

Mold (with whatever I have enough of) and cast orange piece and circular ring in crystal clear

Button for trigger press

Button for mode change

LEDs
2 strips
One circular

2 2" lcd screens

Arduino

Roll of wire

Soldering kit

Royalty free? sound effects
Charging hum
Blaster discharge
Automatic blaster discharge sound

Paint
airbrush and compressor

Cyno
kicker

The only materials I don't already have are the electronic parts. Not sure if this covers everything I'll need as I've never done this from scratch, only kit-bashed small electronics before (for example, my friend wanted his toilet to sound like a warp pipe from Mario Bros when he flushed it. I used the guts from sound bite keychains. It worked :P)

Josh

Comments

  • OK! here is the code for the gun:

    // SWSCA Arduino Programming Basics with David Covarrubias

    #include <Adafruit_NeoPixel.h> 
    #include <avr/power.h>
    #include <Adafruit_ssd1306syp.h>
    #define PIN 6
    Adafruit_ssd1306syp display(SDA_PIN,SCL_PIN);
    Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, PIN, NEO_GRB + NEO_KHZ800);
    //long earlyRelease;
    const int buttonPin = 2;     // the number of the pushbutton pin
    const int soundPin4 =  4;      // the number of the sound pins
    const int soundPin7 = 7;
    const int soundPin8 = 8;
    int buttonState = 0;
    int brightnessValue = 0;
    int dischargeTimer = 0;
    int led;
    int oneShotFlag = 0; //flag used to keep track of animation
    int releaseFlag = 0; //second flag to keep track of button release for early release sound effect
    void setup() {
      strip.begin();
      strip.show();
      pinMode(buttonPin, INPUT);
      pinMode(soundPin4, OUTPUT);
      pinMode(soundPin7, OUTPUT);
      pinMode(soundPin8, OUTPUT);
      digitalWrite(soundPin4, HIGH);
      digitalWrite(soundPin7, HIGH);
      digitalWrite(soundPin8, HIGH);
      //Serial.begin(9600);
      
    }
      void loop() {

        //this part is a charging shot,
      //intended to return to a resting loop between button presses
      //and after a given duration of buttonState == HIGH

      //this is the resting "flicker" state
      // individual pixels randomly blink ON (0,50,50) then turn off (0,0,0) onece per loop
      //when button is not pressed (Thanks Dave!)
      int bright = random(0, brightnessValue);
      int led = random(0, 60);
      buttonState = digitalRead(buttonPin);
     
     
      //this is what it does when you don't press anything
      
      if (buttonState == LOW && releaseFlag != 1) {          //while the button is not pressed do this:
        
        digitalWrite(soundPin4, HIGH);      //turn off the charge up sound
        digitalWrite(soundPin7, HIGH);      //turn off the discharge sound
        digitalWrite(soundPin8, HIGH);      //turn off early release sound
        oneShotFlag = 0;                    //keep your flag down if no button is pushed
        dischargeTimer = 0;                 //keep/reset the timer that keeps track of how long to loop before discharge set to 0 because we don't need it yet
        brightnessValue = 0;                //keep/reset the brightness of the leds at a low level
        strip.setPixelColor(led, 0, 50, 50);//turn on a random led
        strip.show();
        strip.setPixelColor(led, 0, 0, 0);//turn off the leds (this in quick succession makes a random flickering pattern)
        strip.show();
       // Serial.println(releaseFlag);
      }
      
      //this is what it does when you press and hold the button
      
      if (buttonState == HIGH && oneShotFlag != 1) { 
        //check for button pressed but only do this if our flag is low...and it is since we set it to low when button was not pushed
        
        digitalWrite(soundPin4, LOW);                //play charge up sound
        //delay(500);
        
        //digitalWrite(soundPin4,HIGH);
        digitalWrite(soundPin7, HIGH);
        digitalWrite(soundPin8, HIGH);
        
        dischargeTimer++;                            //while button is held down discharge time gets larger
        strip.setPixelColor(led, 0, bright, bright); //turn on LED
        strip.show();
        brightnessValue++;       //make the top end of the random number larger making leds brighter
        delay(1);
        releaseFlag = 1;
        //Serial.println(releaseFlag);
      }
      if (dischargeTimer >= 360 ) { //after 360 loops with the button pressed then do thisx
        dischargeTimer = 0;         //reset variable
        discharge();                //this calls a function below that turns off the leds
      }
      
      //this is what it does if you press the button and release it before the full charge cycle //Thanks Dave!!
      
        if (buttonState == LOW && releaseFlag == 1) { //if the button is let go during the charge up phase do this
        digitalWrite(soundPin4, HIGH);
        digitalWrite(soundPin7, HIGH);
        delay(500);
        digitalWrite(soundPin8, LOW); // play release soundfx
        delay(500); 
        digitalWrite(soundPin8,HIGH);
        releaseFlag = 0; //reset release flag
        oneShotFlag = 0;                    //keep your flag down if no button is pushed
        dischargeTimer = 0;                 //keep/reset the timer that keeps track of how long to loop before discharge set to 0 because we don't need it yet
        brightnessValue = 0;                //keep/reset the brightness of the leds at a low level
        strip.setPixelColor(led, 0, 50, 50);//turn on a random led
        strip.show();
        strip.setPixelColor(led, 0, 0, 0);//turn off the leds (this in quick succession makes a random flickering pattern)
        strip.show();  
        //Serial.println(releaseFlag);
    }
      
      // this is what it does if you keep holding the button down after the full charge/discharge cycle
      
      if (buttonState == HIGH && oneShotFlag == 1) {//this makes the LEDs flicker and sound stop if the button is still held down after discharge
        digitalWrite(soundPin4, HIGH);
        digitalWrite(soundPin7, HIGH);
        digitalWrite(soundPin8, HIGH);
        dischargeTimer = 0;
        brightnessValue = 0;
        strip.setPixelColor(led, 0, 50, 50);
        strip.show();
        strip.setPixelColor(led, 0, 0, 0);
        strip.show();
       // Serial.println(releaseFlag);
      }
      }


    //this is the discharge

    void discharge() {  //after 360 loops with the button held down, do this
      for ( led = 60; led >= 0; led--) { //turn all leds OFF all in one shot
        strip.setPixelColor(led, 0, 0, 0);
        brightnessValue = 0;
      }
      strip.show();
      digitalWrite(soundPin4, HIGH); //turn off charge up sound to allow discharge sound
      digitalWrite(soundPin7, LOW); //play discharge sound
      digitalWrite(soundPin8, HIGH);
      delay(500);//wait half second then start loop() over again
      oneShotFlag = 1; // make flag = 1 when it reaches here so it wont loop back around until you let go of the button and reset the flag back to zero
      releaseFlag = 0;
      //Serial.println(releaseFlag);
    }
  • And here is the link to the video showing it working:

    https://youtu.be/ZAg2zY50FNo

    :)
  • Here is the code for the screen:

    //SWSCA Arduino Programming Basics with David Covarrubias
    //Different than what you showed us on diplays,//but I'm guessing it's due to this being a 128x64 OLED screen,//and not LCD? Either way, I used the tried and true method//of loading in an example playing with it until I understood//how the library worked :)
    //also had to look up and example on switches, and then tweak//it to fit what I needed it to do. I learned all about debouncing lol
    #include <Adafruit_ssd1306syp.h>#define SDA_PIN 12#define SCL_PIN 11Adafruit_ssd1306syp display(SDA_PIN, SCL_PIN);const int buttonPin2 = 2;  //trigger buttonconst int buttonPin9 = 9;  //state change buttonconst int soundPin4 = 4;const int soundPin7 = 7;int battPower = 0;int ammo = 6;int buttonState;   //trigger buttonint buttonState2;  //state change buttonint state = 0;     //state change flagint previous = LOW;    long time = 0;         long debounce = 200;//time delay duration checked against millis                     //so program doesn't think the button is                     //pushed more than oncevoid setup(){  delay(1000);  display.initialize();  pinMode(buttonPin2, INPUT);  pinMode(buttonPin9, INPUT);}void loop(){//this is where the display gets it's information on what to print to the screen  display.clear();  display.setTextSize(1);  display.setCursor(0, 0);  display.println(" << SWSCA SPECIAL >>");  display.print("Batt Health: %"); display.print(battPower);  display.setTextSize(2);  display.setCursor(0, 16);  display.println("AMMO: DMG:");  display.setCursor(12, 33);  display.setTextSize(4);  display.println(ammo);  if (state==0){             //this is the part where it checks the value of "state" to determine whether to display "ARC" or "FLM"  display.setCursor(56, 33);  display.setTextSize(4);  display.println("ARC");  }  if (state==1){  display.setCursor(56, 33);  display.setTextSize(4);  display.println("FLM");  }  display.update();  buttonState = digitalRead(buttonPin2);  battPower = battPower + 8;  if (battPower >= 100) {    battPower = 100;  }  if (buttonState == HIGH) {    battPower = battPower - 50;    ammo--;    delay(1000);    if (battPower <= 0) {      battPower = 0;    }    if (ammo == -1) {      ammo = 6;    }  }   //this is where buttonPin9 (state change button) is set up //as a switch  buttonState2 = digitalRead(buttonPin9);   //read buttonPin9 for a HIGH or LOW signal                                            //below, we say, if the button is pushed, and the previous state was low                                             //(a check to allow holding the button without it looping,)                                             //and its been more than 200 milliseconds since we last pushed the button                                             //(giving it time to clear the noise (multiple HIGH signals)) then..  if (buttonState2 == HIGH && previous == LOW && millis() - time > debounce) {                                                      //we do one of two things, if state==0, change it to 1, otherwise, make it zero     if (state == 0) //and the value of the state variable tells                      //the screen wether to display "ARC" or "FLM"      state =1;    else      state = 0;    time = millis();    //write down the new time on the clock  }  previous = buttonState2; //store the current value of buttonstate2                            //to a variable so we can check against it on the next loop                            //to decide whether or not to proceed to the "if" statement                            //if enough time has passed}
  • Here is the video showing the screen working:

    https://youtu.be/rQI4PAPGaYU

     :) 
  • Hi Yukako!

    Here are some pictures I have of the process:

    This was the first pass of paint, flat black primer.


    This was the second pass, a dry rub of silver "Liquid Leaf" paint to give it a gun metal look similar to, but a little lighter than a graphite rub.


    First layer of silicone for the brush on mold for the clear reservoir


    Reservoir re-cast in Crystal Clear


    Fitting all the electronics into the gun after soldering everything together.

    Those are all the pics I have, if you need more I can take more :smile: 
Sign In or Register to comment.