# Overwatch Prop Gun: Lucio's Blaster Pt. 2

## Blaster Integration: Lights and Music

![](https://cdn-learn.adafruit.com/assets/assets/000/037/950/medium800/gaming_LucioThumbnailPt2.jpg?1481327859)

https://youtu.be/O-iwm-bWY9s

This is the second part in the series on creating the&nbsp;Overwatch prop blaster for Lucio. You can check out the [first part here](../../../../overwatch-lucio-gun-pt1/overview).

In learning how to build a multi-function prop we started off by&nbsp;making individual, seperate circuits for three things: lighting, music, and sound effects. I like to start off with discreet circuits, each running with its own microcontroller and power supplly. This helps to get things up and running quickly and is straightforward to troubleshoot.

These three, separate circuits create the lighting, music, and audio effects for the prop. Let's integrate them into a single system.

![gaming_LB_p1_bld0.jpg](https://cdn-learn.adafruit.com/assets/assets/000/037/872/medium640/gaming_LB_p1_bld0.jpg?1481127893)

![gaming_LB_p1_bld1.jpg](https://cdn-learn.adafruit.com/assets/assets/000/037/873/medium640/gaming_LB_p1_bld1.jpg?1481127908)

![gaming_LB_p1_bld2.jpg](https://cdn-learn.adafruit.com/assets/assets/000/037/874/medium640/gaming_LB_p1_bld2.jpg?1481127921)

Now that those individual parts are working, it's time to combine them into a single, integrated system. This integration covers a number of elements, including&nbsp;doing multiple tasks with a single microcontroller, sharing inputs, such as a trigger pull creating both a sound effect and a lighting change, and sharing power supplies.

## Lights and Music

Leaping off from the previous lesson, you can first combine the music circuit and the lighting circuit. They each ran from their own Arduino UNO or Adafruit Metro board in part 1, but now we'll run both circuits from a single board.

![](https://cdn-learn.adafruit.com/assets/assets/000/037/913/medium800/gaming_LB_protoA2plusB2.png?1481213527)

Start with the UNO or Metro board with the Music Maker MP3 shield attached. The mode toggle switch will now serve double duty, changing both lights an music. This will still be attached to pin 5 as an input pullup switch. You'll also plug the NeoPixel ring into pin 2 as before.

![](https://cdn-learn.adafruit.com/assets/assets/000/037/914/medium800/gaming_LB_protoD_01.png?1481214832)

This time, we're going to use a smaller 3W amplifier connected to the MP3 shield for the background music playing through the three small speakers. We'll continue to use the 20W amp to pump the shooting sound effects from the Audio FX board through the big speaker in the front of the gun. Keeping these two sound circuits seperated allows us to have stereo music channels playing through the left and right small speakers, and still create loud mono effects through the front speaker.

The Arduino sketch needs to be adjusted so that it will both play back music and light the LEDs. Below is a simple sketch to do this, as well as switch modes when the toggle is flipped. Copy it and upload it to the UNO or Metro.

```
//Lucio Blaster code for UNO and Metro
// by John Park for Adafruit
//based upon:
/*************************************************** 
  Adafruit VS1053 Codec Breakout

  Designed specifically to work with the Adafruit VS1053 Codec Breakout 
  ----&gt; https://www.adafruit.com/products/1381

  Written by Limor Fried/Ladyada for Adafruit Industries.  
  BSD license, all text above must be included in any redistribution
 ****************************************************/
#include &lt;Adafruit_VS1053.h&gt;
#include &lt;SD.h&gt;
#include &lt;Adafruit_NeoPixel.h&gt;

#define NEOPIN 2 // pin for NeoPixel ring
#define NUMPIXELS 24 //adjust depeding on ring size

Adafruit_NeoPixel pixels = 
 Adafruit_NeoPixel(NUMPIXELS, NEOPIN, NEO_GRBW + NEO_KHZ800);
int NEODELAY = 0; //8 millis is 120BPM

#define NEOVUPIN 8
#define NUMVUPIXELS 8
Adafruit_NeoPixel vupixels = 
 Adafruit_NeoPixel(NUMVUPIXELS, NEOVUPIN, NEO_GRBW + NEO_KHZ800);
int NEOVUDELAY = 42; //the tempo for lighting effects

#define NEOJWLPIN 10
#define NUMJWLPIXELS 5 
Adafruit_NeoPixel jewelpixels = 
 Adafruit_NeoPixel(NUMJWLPIXELS, NEOJWLPIN, NEO_GRBW + NEO_KHZ800);
int NEOJWLDELAY = 84; //the tempo for lighting effects

// These are the pins used for the music maker shield
#define SHIELD_RESET  -1      // VS1053 reset pin (unused!)
#define SHIELD_CS     7      // VS1053 chip select pin (output)
#define SHIELD_DCS    6      // VS1053 Data/command select pin (output)

// These are common pins between breakout and shield
#define CARDCS 4     // Card chip select pin
// DREQ should be an Int pin, see http://arduino.cc/en/Reference/attachInterrupt
#define DREQ 3       // VS1053 Data request, ideally an Interrupt pin

Adafruit_VS1053_FilePlayer musicPlayer = 
  Adafruit_VS1053_FilePlayer(SHIELD_RESET, SHIELD_CS, SHIELD_DCS, DREQ, CARDCS);

//state change detection
const int  MODESWITCHPIN = 5;    // the pin that the pushbutton is attached to
int modeSwitchPushCounter = 0;   // counter for the number of button presses
bool modeSwitchState = 0;         // current state of the button
int lastModeButtonState = 0;     // previous state of the button


const char* SONGS[] = {"h.mp3", "s.mp3"};//change to reflect your file names
int songPick = 0;

const int VOL = 1; //volume higher numbers are quieter

////

void setup() {
  pixels.begin(); // This initializes the NeoPixel library.
  pixels.setBrightness(30);
  pixels.show();

  vupixels.begin(); 
  vupixels.setBrightness(20);
  vupixels.show();

  jewelpixels.begin();
  jewelpixels.setBrightness(10);
  jewelpixels.show();

  pinMode(MODESWITCHPIN, INPUT_PULLUP);
  

  Serial.begin(9600);
 

  // initialise the music player
  if (! musicPlayer.begin()) { // initialise the music player
     Serial.println(F("Couldn't find VS1053, do you have right pins defined?"));
     while (1);
  }

  if (!SD.begin(CARDCS)) {
    Serial.println(F("SD failed, or not present"));
    while (1);  // don't do anything more
  }
  Serial.println(F("SD OK!"));
  
  // Set volume for left, right channels. lower numbers == louder volume!
  musicPlayer.setVolume(VOL,VOL);

  if (! musicPlayer.useInterrupt(VS1053_FILEPLAYER_PIN_INT))
    Serial.println(F("DREQ pin is not an interrupt pin"));

//check the switch state to start up with a NeoPixel color
  modeSwitchState = digitalRead(MODESWITCHPIN); //read switch input pin
    if (modeSwitchState==HIGH){
        for(int i=(NUMPIXELS-1);i&gt;=0;i--){ //change the color "left to right" 
        //sweep
          pixels.setPixelColor(i, pixels.Color(150,120,0,10)); //yellow color
          pixels.show(); // This sends the updated pixel color to the hardware
          delay(NEODELAY); // Delay for a period of time (in milliseconds)
        }
        for(int i=(NUMJWLPIXELS-1);i&gt;=0;i--){ //change the color "left to right" 
        //sweep
          jewelpixels.setPixelColor(i, jewelpixels.Color(150,120,0,10)); //yellow color
          jewelpixels.show(); // This sends the updated pixel color to the hardware
          delay(NEOJWLDELAY); // Delay for a period of time (in milliseconds)
        }
        
    }
    else {
        for(int i=0;i&lt;NUMPIXELS;i++){ //change the color "right to left" sweep
          pixels.setPixelColor(i, pixels.Color(0,150,0,10)); //  green color
          pixels.show();  
          delay(NEODELAY); 
        }
        for(int i=0;i&lt;NUMJWLPIXELS;i++){ //change the color "right to left" sweep
          jewelpixels.setPixelColor(i, jewelpixels.Color(0,150,0,10)); //  green color
          jewelpixels.show();  
          delay(NEOJWLDELAY); 
        }
    }
    
}

void loop() {  

  // Start playing a file, then we can do stuff while waiting for it to finish
  if (! musicPlayer.startPlayingFile(SONGS[songPick])) {
    Serial.println(F("Could not open file"));
    while (1);
  }
  //Serial.println(F("Started playing"));

  while (musicPlayer.playingMusic) {
           
    modeSwitchState = digitalRead(MODESWITCHPIN); //read switch input pin                 
    if (modeSwitchState != lastModeButtonState) { // compare the modeSwitchState 
      //to its previous state
      if (modeSwitchState == HIGH) {
         // if the current state is HIGH then the button
         // went from left to right :
         modeSwitchPushCounter++;
         songPick=0;
         musicPlayer.stopPlaying(); //does this so it'll restart the player with
         // the new song choice
 
        for(int i=(NUMPIXELS-1);i&gt;=0;i--){ //change the color "left to right" 
        //sweep
          pixels.setPixelColor(i, pixels.Color(150,120,0,10)); // yellow color

        }
        pixels.show();//show the new values
        for(int i=(NUMVUPIXELS-1);i&gt;=0;i--){ //change the color "left to right" 
          vupixels.setPixelColor(i, vupixels.Color(150,120,0,10)); //yellow 
        }
        vupixels.show();
        for(int i=(NUMJWLPIXELS-1);i&gt;=0;i--){ //change the color "left to right" 
          jewelpixels.setPixelColor(i, jewelpixels.Color(150,120,0,10)); //yellow 
        }
        jewelpixels.show();
      } 
      else {
        // if the current state is LOW then the button
        // went from on to off:
        songPick=1;
        musicPlayer.stopPlaying(); //restart the player with the new song choice
        for(int i=0;i&lt;NUMPIXELS;i++){ //change the color "right to left" sweep
          pixels.setPixelColor(i, pixels.Color(0,150,0,10)); //yellow color
        }
        pixels.show();//show the new values
        for(int i=0;i&lt;NUMVUPIXELS;i++){ //change the color "right to left" sweep
          vupixels.setPixelColor(i, vupixels.Color(0,150,0,10)); //yellow color
        }
        vupixels.show();
        for(int i=0;i&lt;NUMJWLPIXELS;i++){ //change the color "right to left" sweep
          jewelpixels.setPixelColor(i, jewelpixels.Color(0,150,0,10)); //yellow color
        }
        jewelpixels.show();
      }
    // Delay a little bit to avoid bouncing
    delay(50);
  }
  // save the current state as the last state,
  //for next time through the loop
  lastModeButtonState = modeSwitchState;


    if(modeSwitchState==LOW){
      //VU meter pixel bounce -- brute force, needs to clean up or become function
      vupixels.setPixelColor(0, vupixels.Color(0,150,0,10)); 
      vupixels.setPixelColor(1, vupixels.Color(0,150,0,10)); 
      vupixels.setPixelColor(2, vupixels.Color(0,0,0,0)); 
      vupixels.setPixelColor(3, vupixels.Color(0,0,0,0)); 
      vupixels.setPixelColor(4, vupixels.Color(0,0,0,0)); 
      vupixels.setPixelColor(5, vupixels.Color(0,0,0,0)); 
      vupixels.setPixelColor(6, vupixels.Color(0,0,0,0)); 
      vupixels.setPixelColor(7, vupixels.Color(0,0,0,0)); 
      vupixels.show();  
      delay(NEOVUDELAY);

      vupixels.setPixelColor(2, vupixels.Color(0,150,0,10));  
      vupixels.setPixelColor(3, vupixels.Color(0,150,0,10));  
      vupixels.setPixelColor(4, vupixels.Color(0,150,0,10));  
 
      vupixels.show();  
      delay(NEOVUDELAY);    
 
      vupixels.setPixelColor(5, vupixels.Color(0,150,0,10));  
      vupixels.setPixelColor(6, vupixels.Color(0,150,0,10));  
      vupixels.setPixelColor(7, vupixels.Color(0,150,0,10));  
      vupixels.show();  
      delay(NEOVUDELAY);   
 
      vupixels.setPixelColor(5, vupixels.Color(0,0,0,0));  
      vupixels.setPixelColor(6, vupixels.Color(0,0,0,0));  
      vupixels.setPixelColor(7, vupixels.Color(0,0,0,0));  
      vupixels.show();  
      delay(NEOVUDELAY);   

    }
    else{
      //VU meter pixel bounce
      vupixels.setPixelColor(0, vupixels.Color(150,120,0,10)); 
      vupixels.setPixelColor(1, vupixels.Color(150,120,0,10)); 
      vupixels.setPixelColor(2, vupixels.Color(0,0,0,0)); 
      vupixels.setPixelColor(3, vupixels.Color(0,0,0,0)); 
      vupixels.setPixelColor(4, vupixels.Color(0,0,0,0)); 
      vupixels.setPixelColor(5, vupixels.Color(0,0,0,0)); 
      vupixels.setPixelColor(6, vupixels.Color(0,0,0,0)); 
      vupixels.setPixelColor(7, vupixels.Color(0,0,0,0)); 
      vupixels.show();  
      delay(NEOVUDELAY);

      vupixels.setPixelColor(2, vupixels.Color(150,120,0,10));  
      vupixels.setPixelColor(3, vupixels.Color(150,120,0,10));  
      vupixels.setPixelColor(4, vupixels.Color(150,120,0,10));  

      vupixels.show();  
      delay(NEOVUDELAY);    

      vupixels.setPixelColor(5, vupixels.Color(150,120,0,10));  
      vupixels.setPixelColor(6, vupixels.Color(150,120,0,10));  
      vupixels.setPixelColor(7, vupixels.Color(150,120,0,10));  
      vupixels.show();  
      delay(NEOVUDELAY);   

      vupixels.setPixelColor(5, vupixels.Color(0,0,0,0));  
      vupixels.setPixelColor(6, vupixels.Color(0,0,0,0));  
      vupixels.setPixelColor(7, vupixels.Color(0,0,0,0));  
      vupixels.show();  
      delay(NEOVUDELAY);   
    }
  }
}




```

One thing to&nbsp;add to the circuit at this point is an on/off switch. The PowerBoost has an enable pin (marked "EN" on the board) which cuts power to the 5V output when it is grounded. You can test this out with a single jumper wire, but we'll use a switch instead.

![](https://cdn-learn.adafruit.com/assets/assets/000/037/905/medium800/gaming_LB_p2_bread-1.jpg?1481161319)

Warning: 

You can also add a volume knob, such as [this](http://www.digikey.com/product-detail/en/bourns-inc/PDB182-E420K-103A/PDB182-E420K-103A-ND/3780709). Unlike the 20W amp, there is not an on-board volume pot connector. Instead, we'll use a traditional 10K stereo audio potentiometer, which will act as a middle-man between the output of the MP3 shield and the input of the amplifier. You can wire it as seen in the circuit diagram.

![](https://cdn-learn.adafruit.com/assets/assets/000/037/916/medium800/gaming_PDB182-E420K-103A.jpg?1481214964)

Info: 

![](https://cdn-learn.adafruit.com/assets/assets/000/037/900/medium800/gaming_LB_protoD_02.png?1481148647)

![](https://cdn-learn.adafruit.com/assets/assets/000/037/906/medium800/gaming_LB_p2_bread-2.jpg?1481161424)

You now have two of the three functions integrated. Sweet! You turn it on and off with the PowerBoost enable switch, adjust the volume, and flip modes from health to speed, causing both lights and music to change as needed.

Next up, is integration of the Audio&nbsp;FX board for shooting sounds.

# Overwatch Prop Gun: Lucio's Blaster Pt. 2

## Blaster Integration: Audio Effects

You've combined lights and music, so the next step&nbsp;is to add the sound effects sub-system.&nbsp;Here's what it looked like in part 1:

![](https://cdn-learn.adafruit.com/assets/assets/000/037/918/medium800/gaming_LB_protoC_01.png?1481215992)

When joining seperate parts into a whole system,&nbsp;you'll want to make sure they all have a common ground, so that's one connection we'll make between the Audio FX board and the rest.

In this case we'll also share the power input between these parts -- except for the 20W amp which will have it's own power supply.

And there is one more connection to be made: the Audio FX board has an activity pin -- marked "ACT" -- which you'll use to inform the Arduino UNO or Metro when it is playing a triggered sound so that the lights will flash appropriately.&nbsp;

![](https://cdn-learn.adafruit.com/assets/assets/000/037/917/medium800/gaming_afxACT.jpg?1481215868)

Info: 

One PowerBoost 1000C and battery will provide 5V at 1A, which is adequate to power the lights and music subsystems, as well as the Audio FX board. However, adding in the 20W amp for the shooting effects is too much and you'll hear clipping at higher volumes as the amp gets starved for power.&nbsp;A simple, expedient way to solve this is to supply power to the 20W amp from a separate, secondary PowerBoost and battery.

![](https://cdn-learn.adafruit.com/assets/assets/000/037/919/medium800/gaming_LB_protoD_03.png?1481216500)

Here's a lay of the land for this circuit diagram:

- Two batteries, each connected to their own PowerBoost
- PowerBoost USB pins are connected to allow both batteries to be charged by plugging USB micro into one board
- Everything is powered on/off by the switch connected to the first PowerBoost's enable pin
- Smoothing capacitor to protect NeoPixels
- First PowerBoost 5V running on all breadboard power rails (all boards powered on this rail except the 20W amp, which is powered by second PowerBoost)
- UNO/Metro controlling all NeoPixels
- UNO/Metro (via MP3 shield) ouputs stereo music through volume pot into 3.7W amplifier
- 3.7W amplifier outputs to three small speakers which will be arrayed on sides and top of prop gun
- Input toggle switch connected to UNO/Metro controlling light and music modes
- Input activity pin from Audio FX board connected to UNO/Metro controlling light flashes
- Audio FX board sounds triggered by four buttons (two to&nbsp;be tilt switches, not pictured in the diagram)
- Audio FX board outputs sound to 20W amplifier
- 20W amplifier powered by second PowerBoost
- 20W amplifier volume adjusted with Pot. Vol knob
- Large 20W speaker driven by 20W amplifier
- All boards/amps/switches power grounds&nbsp;connected to common ground

Here's the system put together on a large prototyping breadboard:

![](https://cdn-learn.adafruit.com/assets/assets/000/037/921/medium800/gaming_LB_p2_bread-4_labeled.png?1481218585)

Warning: 

The only change to the software will be the addition of the Audio FX activity pin as an input to the Arduino, so it will brighten the NeoPixels when the sound effects are triggered.

Download the code below and upload it to your Arduino UNO or Metro board. This adds a few lines of code that allows the Arduino to read the state of the Audio FX board and brighten the lights when a sounds is triggered.

```
//Lucio Blaster code for UNO and Metro
// by John Park for Adafruit
//based upon:
/*************************************************** 
  Adafruit VS1053 Codec Breakout

  Designed specifically to work with the Adafruit VS1053 Codec Breakout 
  ----&gt; https://www.adafruit.com/products/1381

  Written by Limor Fried/Ladyada for Adafruit Industries.  
  BSD license, all text above must be included in any redistribution
 ****************************************************/
#include &lt;Adafruit_VS1053.h&gt;
#include &lt;SD.h&gt;
#include &lt;Adafruit_NeoPixel.h&gt;

#define NEOPIN 2 // pin for NeoPixel ring
#define NUMPIXELS 24 //adjust depeding on ring size

Adafruit_NeoPixel pixels = 
 Adafruit_NeoPixel(NUMPIXELS, NEOPIN, NEO_GRBW + NEO_KHZ800);
int NEODELAY = 0; //8 millis is 120BPM

#define NEOVUPIN 8
#define NUMVUPIXELS 8
Adafruit_NeoPixel vupixels = 
 Adafruit_NeoPixel(NUMVUPIXELS, NEOVUPIN, NEO_GRBW + NEO_KHZ800);
int NEOVUDELAY = 42; //the tempo for lighting effects

#define NEOJWLPIN 10
#define NUMJWLPIXELS 5 
Adafruit_NeoPixel jewelpixels = 
 Adafruit_NeoPixel(NUMJWLPIXELS, NEOJWLPIN, NEO_GRBW + NEO_KHZ800);
int NEOJWLDELAY = 84; //the tempo for lighting effects

// These are the pins used for the music maker shield
#define SHIELD_RESET  -1      // VS1053 reset pin (unused!)
#define SHIELD_CS     7      // VS1053 chip select pin (output)
#define SHIELD_DCS    6      // VS1053 Data/command select pin (output)

// These are common pins between breakout and shield
#define CARDCS 4     // Card chip select pin
// DREQ should be an Int pin, see http://arduino.cc/en/Reference/attachInterrupt
#define DREQ 3       // VS1053 Data request, ideally an Interrupt pin

Adafruit_VS1053_FilePlayer musicPlayer = 
  Adafruit_VS1053_FilePlayer(SHIELD_RESET, SHIELD_CS, SHIELD_DCS, DREQ, CARDCS);

//state change detection
const int  MODESWITCHPIN = 5;    // the pin that the pushbutton is attached to
int modeSwitchPushCounter = 0;   // counter for the number of button presses
bool modeSwitchState = 0;         // current state of the button
int lastModeButtonState = 0;     // previous state of the button

const int AFXPIN = 9; //pin connected to AudioFX board ACT pin
bool afxState = HIGH; //defaults to high, is pulled low during activity

const char* SONGS[] = {"h.mp3", "s.mp3"};//change to reflect your file names
int songPick = 0;

const int VOL = 1; //volume higher numbers are quieter

////

void setup() {
  pixels.begin(); // This initializes the NeoPixel library.
  pixels.setBrightness(30);
  pixels.show();

  vupixels.begin(); 
  vupixels.setBrightness(20);
  vupixels.show();

  jewelpixels.begin();
  jewelpixels.setBrightness(10);
  jewelpixels.show();

  pinMode(MODESWITCHPIN, INPUT_PULLUP);
  pinMode(AFXPIN, INPUT_PULLUP);//set up the pin connected to AudioFX ACT pin

  Serial.begin(9600);
 

  // initialise the music player
  if (! musicPlayer.begin()) { // initialise the music player
     Serial.println(F("Couldn't find VS1053, do you have right pins defined?"));
     while (1);
  }

  if (!SD.begin(CARDCS)) {
    Serial.println(F("SD failed, or not present"));
    while (1);  // don't do anything more
  }
  Serial.println(F("SD OK!"));
  
  // Set volume for left, right channels. lower numbers == louder volume!
  musicPlayer.setVolume(VOL,VOL);

  if (! musicPlayer.useInterrupt(VS1053_FILEPLAYER_PIN_INT))
    Serial.println(F("DREQ pin is not an interrupt pin"));

//check the switch state to start up with a NeoPixel color
  modeSwitchState = digitalRead(MODESWITCHPIN); //read switch input pin
    if (modeSwitchState==HIGH){
        for(int i=(NUMPIXELS-1);i&gt;=0;i--){ //change the color "left to right" 
        //sweep
          pixels.setPixelColor(i, pixels.Color(150,120,0,10)); //yellow color
          pixels.show(); // This sends the updated pixel color to the hardware
          delay(NEODELAY); // Delay for a period of time (in milliseconds)
        }
        for(int i=(NUMJWLPIXELS-1);i&gt;=0;i--){ //change the color "left to right" 
        //sweep
          jewelpixels.setPixelColor(i, jewelpixels.Color(150,120,0,10)); //yellow color
          jewelpixels.show(); // This sends the updated pixel color to the hardware
          delay(NEOJWLDELAY); // Delay for a period of time (in milliseconds)
        }
        
    }
    else {
        for(int i=0;i&lt;NUMPIXELS;i++){ //change the color "right to left" sweep
          pixels.setPixelColor(i, pixels.Color(0,150,0,10)); //  green color
          pixels.show();  
          delay(NEODELAY); 
        }
        for(int i=0;i&lt;NUMJWLPIXELS;i++){ //change the color "right to left" sweep
          jewelpixels.setPixelColor(i, jewelpixels.Color(0,150,0,10)); //  green color
          jewelpixels.show();  
          delay(NEOJWLDELAY); 
        }
    }
    
}

void loop() {  

  // Start playing a file, then we can do stuff while waiting for it to finish
  if (! musicPlayer.startPlayingFile(SONGS[songPick])) {
    Serial.println(F("Could not open file"));
    while (1);
  }
  //Serial.println(F("Started playing"));

  while (musicPlayer.playingMusic) {

     afxState=(digitalRead(AFXPIN)); //check the Audio FX sensor

    //brighten LEDs if Audio FX board is triggered
    if(afxState==LOW){
      pixels.setBrightness(80); //brightness up
      pixels.show();
    } 
    else{
      pixels.setBrightness(30);
      pixels.show();
    }             

    modeSwitchState = digitalRead(MODESWITCHPIN); //read switch input pin                 
    if (modeSwitchState != lastModeButtonState) { // compare the modeSwitchState 
      //to its previous state
      if (modeSwitchState == HIGH) {
         // if the current state is HIGH then the button
         // went from left to right :
         modeSwitchPushCounter++;
         songPick=0;
         musicPlayer.stopPlaying(); //does this so it'll restart the player with
         // the new song choice
 
        for(int i=(NUMPIXELS-1);i&gt;=0;i--){ //change the color "left to right" 
        //sweep
          pixels.setPixelColor(i, pixels.Color(150,120,0,10)); // yellow color

        }
        pixels.show();//show the new values
        for(int i=(NUMVUPIXELS-1);i&gt;=0;i--){ //change the color "left to right" 
          vupixels.setPixelColor(i, vupixels.Color(150,120,0,10)); //yellow 
        }
        vupixels.show();
        for(int i=(NUMJWLPIXELS-1);i&gt;=0;i--){ //change the color "left to right" 
          jewelpixels.setPixelColor(i, jewelpixels.Color(150,120,0,10)); //yellow 
        }
        jewelpixels.show();
      } 
      else {
        // if the current state is LOW then the button
        // went from on to off:
        songPick=1;
        musicPlayer.stopPlaying(); //restart the player with the new song choice
        for(int i=0;i&lt;NUMPIXELS;i++){ //change the color "right to left" sweep
          pixels.setPixelColor(i, pixels.Color(0,150,0,10)); //yellow color
        }
        pixels.show();//show the new values
        for(int i=0;i&lt;NUMVUPIXELS;i++){ //change the color "right to left" sweep
          vupixels.setPixelColor(i, vupixels.Color(0,150,0,10)); //yellow color
        }
        vupixels.show();
        for(int i=0;i&lt;NUMJWLPIXELS;i++){ //change the color "right to left" sweep
          jewelpixels.setPixelColor(i, jewelpixels.Color(0,150,0,10)); //yellow color
        }
        jewelpixels.show();
      }
    // Delay a little bit to avoid bouncing
    delay(50);
  }
  // save the current state as the last state,
  //for next time through the loop
  lastModeButtonState = modeSwitchState;


    if(modeSwitchState==LOW){
      //VU meter pixel bounce -- brute force, needs to clean up or become function
      vupixels.setPixelColor(0, vupixels.Color(0,150,0,10)); 
      vupixels.setPixelColor(1, vupixels.Color(0,150,0,10)); 
      vupixels.setPixelColor(2, vupixels.Color(0,0,0,0)); 
      vupixels.setPixelColor(3, vupixels.Color(0,0,0,0)); 
      vupixels.setPixelColor(4, vupixels.Color(0,0,0,0)); 
      vupixels.setPixelColor(5, vupixels.Color(0,0,0,0)); 
      vupixels.setPixelColor(6, vupixels.Color(0,0,0,0)); 
      vupixels.setPixelColor(7, vupixels.Color(0,0,0,0)); 
      vupixels.show();  
      delay(NEOVUDELAY);

      vupixels.setPixelColor(2, vupixels.Color(0,150,0,10));  
      vupixels.setPixelColor(3, vupixels.Color(0,150,0,10));  
      vupixels.setPixelColor(4, vupixels.Color(0,150,0,10));  
 
      vupixels.show();  
      delay(NEOVUDELAY);    
 
      vupixels.setPixelColor(5, vupixels.Color(0,150,0,10));  
      vupixels.setPixelColor(6, vupixels.Color(0,150,0,10));  
      vupixels.setPixelColor(7, vupixels.Color(0,150,0,10));  
      vupixels.show();  
      delay(NEOVUDELAY);   
 
      vupixels.setPixelColor(5, vupixels.Color(0,0,0,0));  
      vupixels.setPixelColor(6, vupixels.Color(0,0,0,0));  
      vupixels.setPixelColor(7, vupixels.Color(0,0,0,0));  
      vupixels.show();  
      delay(NEOVUDELAY);   

    }
    else{
      //VU meter pixel bounce
      vupixels.setPixelColor(0, vupixels.Color(150,120,0,10)); 
      vupixels.setPixelColor(1, vupixels.Color(150,120,0,10)); 
      vupixels.setPixelColor(2, vupixels.Color(0,0,0,0)); 
      vupixels.setPixelColor(3, vupixels.Color(0,0,0,0)); 
      vupixels.setPixelColor(4, vupixels.Color(0,0,0,0)); 
      vupixels.setPixelColor(5, vupixels.Color(0,0,0,0)); 
      vupixels.setPixelColor(6, vupixels.Color(0,0,0,0)); 
      vupixels.setPixelColor(7, vupixels.Color(0,0,0,0)); 
      vupixels.show();  
      delay(NEOVUDELAY);

      vupixels.setPixelColor(2, vupixels.Color(150,120,0,10));  
      vupixels.setPixelColor(3, vupixels.Color(150,120,0,10));  
      vupixels.setPixelColor(4, vupixels.Color(150,120,0,10));  

      vupixels.show();  
      delay(NEOVUDELAY);    

      vupixels.setPixelColor(5, vupixels.Color(150,120,0,10));  
      vupixels.setPixelColor(6, vupixels.Color(150,120,0,10));  
      vupixels.setPixelColor(7, vupixels.Color(150,120,0,10));  
      vupixels.show();  
      delay(NEOVUDELAY);   

      vupixels.setPixelColor(5, vupixels.Color(0,0,0,0));  
      vupixels.setPixelColor(6, vupixels.Color(0,0,0,0));  
      vupixels.setPixelColor(7, vupixels.Color(0,0,0,0));  
      vupixels.show();  
      delay(NEOVUDELAY);   
    }
  }
}




```

Now you can try it all out! Turn on the power switch and go. You'll have lights and music running, you can adjust the volume, switch modes, and pull the triggers.

In the next part in this series we'll move from breadboards to permanent proto boards, and make the system as compact as possible in preparation for fitting it inside the 3D printed prop blaster.


## Featured Products

### Adafruit "Music Maker" MP3 Shield for Arduino (MP3/Ogg/WAV...)

[Adafruit "Music Maker" MP3 Shield for Arduino (MP3/Ogg/WAV...)](https://www.adafruit.com/product/1790)
Bend all audio files to your will with the Adafruit Music Maker shield for Arduino! This powerful shield features the VS1053, an encoding/decoding (codec) chip that can decode a wide variety of audio formats such as MP3, AAC, Ogg Vorbis, WMA, MIDI, FLAC, WAV (PCM and ADPCM). It can also be...

Out of Stock
[Buy Now](https://www.adafruit.com/product/1790)
[Related Guides to the Product](https://learn.adafruit.com/products/1790/guides)
### Adafruit METRO 328 - Arduino Compatible - with Headers

[Adafruit METRO 328 - Arduino Compatible - with Headers](https://www.adafruit.com/product/2488)
This is the&nbsp; **Adafruit METRO Arduino-Compatible - with&nbsp;headers.&nbsp;** It's a fully assembled and tested microcontroller and physical computing board with through-hole headers attached.&nbsp; If you don't want a&nbsp;Metro with the headers attached for...

In Stock
[Buy Now](https://www.adafruit.com/product/2488)
[Related Guides to the Product](https://learn.adafruit.com/products/2488/guides)
### Adafruit Audio FX Sound Board - WAV/OGG Trigger with 2MB Flash

[Adafruit Audio FX Sound Board - WAV/OGG Trigger with 2MB Flash](https://www.adafruit.com/product/2133)
Would you like to add audio/sound effects to your next project, without an Arduino+Shield? Or maybe you don't even know how to use microcontrollers, you just want to make a sound play whenever you press a button. What about something that has to be small...

In Stock
[Buy Now](https://www.adafruit.com/product/2133)
[Related Guides to the Product](https://learn.adafruit.com/products/2133/guides)
### Stereo 20W Class D Audio Amplifier - MAX9744

[Stereo 20W Class D Audio Amplifier - MAX9744](https://www.adafruit.com/product/1752)
Pump up the volume with this 20W stereo amplifier! This slim little board has a class D amplifier onboard that can drive 2 channels of 4-8 ohm impedance speakers at 20W each. Power it with 5-12VDC using the onboard DC power jack and plug stereo line level into the 3.5mm stereo headphone jack...

In Stock
[Buy Now](https://www.adafruit.com/product/1752)
[Related Guides to the Product](https://learn.adafruit.com/products/1752/guides)
### Stereo 3.7W Class D Audio Amplifier - MAX98306

[Stereo 3.7W Class D Audio Amplifier - MAX98306](https://www.adafruit.com/product/987)
This incredibly small stereo amplifier is surprisingly powerful - able to deliver 2 x 3.7W channels into 3 ohm impedance speakers. Inside the miniature chip is a class D controller, able to run from 2.7V-5.5VDC. Since the amp is a class D, its incredibly efficient (over 90% efficient when...

In Stock
[Buy Now](https://www.adafruit.com/product/987)
[Related Guides to the Product](https://learn.adafruit.com/products/987/guides)
### 20W 4 Ohm Full Range Speaker

[20W 4 Ohm Full Range Speaker](https://www.adafruit.com/product/1732)
Listen up! This high power 4" diameter speaker will amp up any audio project where you need loud sound! It is 4 ohm impedance, rated for 20W continuous power. (This thing is really loud) It also has four handy mounting tabs 3 inches apart, and a grill that fits on top. The grill is to...

In Stock
[Buy Now](https://www.adafruit.com/product/1732)
[Related Guides to the Product](https://learn.adafruit.com/products/1732/guides)
### Thin Plastic Speaker w/Wires - 8 ohm 0.25W

[Thin Plastic Speaker w/Wires - 8 ohm 0.25W](https://www.adafruit.com/product/1891)
Listen up! This 1.5" diameter speaker cone is the perfect addition to any audio project where you need an 8Ω impedance and are using 0.25W of power. The speakers are rated at 0.25W, with a maximum input of 0.5W (printed wattage on back of speaker may have either value).

We...

In Stock
[Buy Now](https://www.adafruit.com/product/1891)
[Related Guides to the Product](https://learn.adafruit.com/products/1891/guides)
### PowerBoost 1000 Charger - Rechargeable 5V Lipo USB Boost @ 1A

[PowerBoost 1000 Charger - Rechargeable 5V Lipo USB Boost @ 1A](https://www.adafruit.com/product/2465)
PowerBoost 1000C is the perfect power supply for your portable project!&nbsp; **With a built-in load-sharing battery charger circuit, you'll be able to keep your power-hungry project running even while recharging the battery!** &nbsp;This little DC/DC boost converter module can...

Out of Stock
[Buy Now](https://www.adafruit.com/product/2465)
[Related Guides to the Product](https://learn.adafruit.com/products/2465/guides)

## Related Guides

- [Adafruit Powerboost 1000C](https://learn.adafruit.com/adafruit-powerboost-1000c-load-share-usb-charge-boost.md)
- [Raspberry Gear](https://learn.adafruit.com/raspberry-gear.md)
- [Adafruit VCNL4040 Proximity Sensor](https://learn.adafruit.com/adafruit-vcnl4040-proximity-sensor.md)
- [Overwatch Prop Gun: Lucio's Blaster Pt. 1](https://learn.adafruit.com/overwatch-lucio-gun-pt1.md)
- [PiGRRL 2](https://learn.adafruit.com/pigrrl-2.md)
- [Animatronic Cosplay Wings](https://learn.adafruit.com/animatronic-cosplay-wings.md)
- [FPV Mini Display](https://learn.adafruit.com/fpv-mini-ground-station.md)
- [7” Portable Multitouch Raspberry Pi Tablet](https://learn.adafruit.com/7-portable-raspberry-pi-multitouch-tablet.md)
- [Pocket PiGRRL](https://learn.adafruit.com/pocket-pigrrl.md)
- [PyPortal Roku Remote](https://learn.adafruit.com/pyportal-roku-remote.md)
- [Zipper Switch](https://learn.adafruit.com/zipper-switch.md)
- [Overwatch Prop Gun: Lucio's Blaster Pt. 3](https://learn.adafruit.com/overwatch-prop-gun-lucios-blaster-pt-3.md)
- [7" Portable HDMI Monitor](https://learn.adafruit.com/7-hdmi-portable-monitor.md)
- [Adafruit BMP388 and BMP390 - Precision Barometric Pressure and Altimeter](https://learn.adafruit.com/adafruit-bmp388-bmp390-bmp3xx.md)
- [LED Rocket Lamp](https://learn.adafruit.com/led-rocket-lamp.md)
- [Windows IoT Core Application Management](https://learn.adafruit.com/windows-iot-application-management.md)
