Reboot Pack Lights Arduino (NeoPixels + 7 segment lights) (Need help)

TL;DR at bottom.

So I’m pretty new to both electronics and Arduino coding. I am helping a friend with his reboot pack build, and while he does the crafting work I offered to help with the light programming. I got the hardware part figured out very quickly, the code, however, is a bit more troublesome.

He initially ordered 2 Arduinos and some NeoPixel Ring Lights (60 LED) + Jewel (7 LED) and the 7 segment LED’s from GhostLab42 (http://www.gbfans.com/forum/viewtopic.php?f=31&t=41215).

I got the 7segment lights working nearly without issue. However I would LIKE to add a switch to it that allows it to switch from like the scrolling code to the counting code, and also have it display random numbers while scrolling.

I got the NeoPixel lights hooked up and with the example code I know they work. The NeoPixel lights have an example library but does a poor job explaining itself. I just want to have it so I can have a switch from pulsing lights to scrolling/chasing lights (Neither of which I have good code for) and maybe a rainbow startup.

A (probably farfetched) desire is to have all this code running on ONE arduino. If anyone knows how to make this happen let me know. We have a second board ANYWAYS so no big deal if this isn’t possible.

TL;DR:

-Need code to have a switch to swap codings on 7 segment displays

-Need NeoPixel Code for movie-like effects

-Want to run all code from one arduino if possible (I have 2 anyways)

Literally any help is appreciated and may help any others who cannot code very well, like myself. I will credit people in the code as well!

I’ll come back to this in a bit. I think you will be better off using 2 microcontrollers but someone who is good at coding can multi task the controller. I may be able to help you out a bit with some of the coding. I can get a scrolling code to you and rainbow.

Yeah I feel like the 2 controllers is a better deal, but the coding help would be greatly appreciated, either posted here or in PM if you prefer.

Now that I am back in town I will be able to start helping out. But first, coffee! :slight_smile:

I am gonna be breaking posts down into smaller thoughts and such. That way I don’t have to write a book and we can discuss as we go.

First I am not a pro by any means. I have successfully coded scrolling and rainbow as you mentioned. I put them on an adafruit gemma board.

I used Bluetooth to switch between the different light modes. I can help with that. (I don’t know how you will signal your board to switch modes.) I can choose different colors and modes from my phone. In the near future I will teach myself IR so I can reduce costs of my components.

I did not get the rainbow and the scrolling modes on at the same time. The coding space on the gemma is pretty tight.

I have the Trinket Pro but have not successfully written code to that yet.

If size is an issue… There is a product out there, tiny circuits, that has the same chip as the arduino but is the size of a dime. I plan on getting myself a few of those to “play” with eventually. That controller is limited with data pins though.

First here are some pictures of the lighting I have successfully coded.

Rainbow: https://www.instagram.com/p/BEFnilCHEI2/

https://www.instagram.com/p/BHKsU6yB5XV/?taken-by=dionne_simone&hl=en

Sparkle: https://www.instagram.com/p/BHKtKvyhcet/?taken-by=dionne_simone&hl=en

Scanner: https://www.instagram.com/p/BHKtYvzBsQU/?taken-by=dionne_simone&hl=en

Blinking: https://www.instagram.com/p/BHTeZQyB21h/?taken-by=dionne_simone&hl=en

Steady on: https://www.instagram.com/p/BHTeiJPhNGF/?taken-by=dionne_simone&hl=en

Scroll: https://www.facebook.com/dionnesimone/videos/10210189737166919/

Azuran, you said you got 2 Arduinos. Would you be able to tell me which ones? Uno, etc.?

I am working on code for my Reboot pack as well. One good way to switch between modes in an attempt to get the NeoPixels to display different patterns is with a simple momentary (push button) switch: https://www.adafruit.com/products/1683

The code can be written such that each time the button is pressed, the LEDs are “told” to do a new pattern. This is done by assigning a variable in the code whose only job is to keep track of how many times the button has been pressed. Something like:

int buttonState;

is what I like to use.

Initially, buttonState = 0.

When the push button switch is pressed once, buttonState is then set to 1:

[switch is pressed]
buttonState = 1;
[code that tells NeoPixels to switch to a new pattern]

There’s a really good tutorial for this that helped me: http://www.ladyada.net/learn/arduino/lesson5.html It will take you a while go to go through, but at the end you should have the building blocks for what you’re looking for.

I have not finished the code for my NeoPixels, as I’ve got a Mini Skinny 144LED strip ordered that hasn’t come in yet. I will happily share my code when I get it done, though.

Thank you for posting that link, I will be jumping over there too. :slight_smile:

Any and all help is appreciated.

Azuran and myself are building the reboot proton pack for anime weekend Atlanta this year.

Due to time constraints I asked him to help with the aurdino and Lights so I can work on the pack building.

The aurdino is a UNO version.

This is our first time using a aurdino and thus the programming is a little confusing for us.

We have seen snippets of code but it still throws us for a loop.

Trying to get the lights to scan in a slow clockwise circle and maybe flash white or a different color when a push button is pressed and held.

And if we get it figured out maybe a startup animation but that is dreaming big.

In the mean time any help is beyond appreciated!

The pack is coming along nicely but slowly.

One of the hardest parts I am running into is the thrower not sure what to do about building that since is such a unique shape but Hopefully will figure something out.

image

Its in still rough shape but each day I am adding a little more to get it right.

Much appreciated for the info coming so far, And yes I’d like to learn to program the Arduino Uno properly, I’m just on a time constraint of 4 weeks now. Still working through the issues and your samples look really good, deejeerie!

Hi Azuran, there’s a bit of a learning curve with this Arduino stuff, and I understand how intimidating it can feel.

First thing you’ll want to do is install the Arduino IDE on your computer (https://www.arduino.cc/en/Main/Software). This is what you will use to program your Uno.

Connect your Uno to one of the USB ports on your computer using a USB A-B cable: https://www.adafruit.com/products/62

After you’re got the IDE installed, open it up and set it for communicating with your Uno.

Under Tools → Board, select “Arduino/Genuino Uno”

Under Tools → Port, select whichever port is highlighted with your Uno (mine is COM7)

Under Tools → Programmer, select “USBtinyISP”

Now, since you’re using NeoPixels, you’ll want to download the Adafruit NeoPixel library. A library is just another program someone has written to help with the code so you don’t have to worry about it. Libraries do a lot of the behind-the-scenes heavy lifting. Download and install the NeoPixel library into the Arduino IDE libraries folder on your computer. https://github.com/adafruit/Adafruit_NeoPixel

There’s a green button on the right hand side of this page that says “Clone or download.” Download the .zip file and save it to your Arduino IDE libraries folder.

Now, go back to your Arduino IDE window. Under Sketch → Include Library → Add .ZIP library, navigate to where you saved the NeoPixel .zip file and select it (you may need to close and reopen the Arduino IDE to get it to show up).

Go back to Sketch → Include Library and find “Adafruit NeoPixel” in the list. Click on it. You should see some code like

#include <Adafuit_Neopixel.h>
``` up at the top of your sketch.

Well done!  This sketch is now ready to have code written to control your NeoPixels.

Clear as mud?  Let me know if you have questions!

This is a rainbow code that I have used. It was created for use with a Adafruit Gemma but should work fine on your Uno.

Just remember to define the pins correctly and enter the correct number of pixels/leds.

#include <Adafruit_NeoPixel.h>



#define PIN 1



// Parameter 1 = number of pixels in strip

// Parameter 2 = Arduino pin number (most are valid)

// Parameter 3 = pixel type flags, add together as needed:

//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)

//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)

//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)

//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)

Adafruit_NeoPixel strip = Adafruit_NeoPixel(8, PIN, NEO_GRB + NEO_KHZ800);



// IMPORTANT: Avoid connecting on a live circuit...if you must, connect GND first.



void setup() {

  strip.begin();

  strip.setBrightness(100); //adjust brightness here

  strip.show(); // Initialize all pixels to 'off'

}



void loop() {

  rainbowCycle(20);

}





// Slightly different, this makes the rainbow equally distributed throughout

void rainbowCycle(uint8_t wait) {

  uint16_t i, j;



  for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel

    for(i=0; i< strip.numPixels(); i++) {

      strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));

    }

    strip.show();

    delay(wait);

  }

}







// Input a value 0 to 255 to get a color value.

// The colours are a transition r - g - b - back to r.

uint32_t Wheel(byte WheelPos) {

  if(WheelPos < 85) {

   return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);

  } else if(WheelPos < 170) {

   WheelPos -= 85;

   return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);

  } else {

   WheelPos -= 170;

   return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);

  }

}

As far as the thrower, there are files on thingyverse.

Ectomike made it. http://www.thingiverse.com/thing:1440634/#comments

If you use it, try to send some bucks his way. :slight_smile:

LegendofMart made a box too. http://www.thingiverse.com/thing:1723959

Yes I saw those but I do not have a 3d printer yet.

Maybe someday.

Thanks for all the help so far !

We have a place around here that is called MakerSpace. I know there are other cities that have them as well. I am pretty sure they could print it for you for a reasonable price. Or perhaps someone here with access to a 3d printer will stumble in here and give you a quote.

I changed the “rainbow” example sketch deejeerie posted to–I hope–be a little more beginner friendly. Adafruit is great because they provide libraries and a lot of example code, but they could stand to have more explanation and best-practices in their example sketches.

I like to have my named variables at the top of my program as much as possible, so that if I decide I want to change a value, I only have to change it in one place. That’s why stuff like the number of NeoPixels (NUMPIXELS), the NeoPixel brightness (BRIGHTNESS), and data pin (PIN) are all at the top. If I decided to add a 144NeoPixel strip to my 60 NeoPixel ring and Jewel, all I would have to do is change one number, NUMPIXELS, from 67 to 211. Same with the brightness of all the NeoPixels. If I am walking around a Con during the day, I might set BRIGHTNESS to 200. But if I’m out on Halloween, maybe I take it down to 75. Just change one number, upload the changes to the Uno, and bam, done.

#include <Adafruit_NeoPixel.h>

    #define NUMPIXELS 67   //This is the TOTAL number of NeoPixels you have on your strip.  A ring + a Jewel = 60 + 7 = 67

    #define PIN 13         //This is the Uno pin your data wire is connected to.  I use 13 because it's nice and out of the way.

    #define BRIGHTNESS 100      //This is how bright the NeoPixels should be.  255 is brightest, 0 is off.

    #define RAINBOWWAIT 20    //Arduino times are in milliseconds.  So a value of 20 means a 20 ms wait every time
                                                             //"delay()" is called.  A value of 1000 means a wait time of 1 s.  The smallest allowable
                                                             // value is 1, or 0.001 seconds.

    // Parameter 1 = number of pixels in strip
    // Parameter 2 = Arduino pin number (most are valid)
    // Parameter 3 = pixel type flags, add together as needed:
    //   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
    //   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
    //   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
    //   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
    Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

    // IMPORTANT: Avoid connecting on a live circuit...if you must, connect GND first.

    void setup() {
      strip.begin();
      strip.setBrightness(BRIGHTNESS);
      strip.show(); // Initialize all pixels to 'off'
    }

    void loop() {
      rainbowCycle(RAINBOWWAIT);
    }


    // Slightly different, this makes the rainbow equally distributed throughout
    void rainbowCycle(uint8_t wait) {
      uint16_t i, j;

      for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
        for(i=0; i< strip.numPixels(); i++) {
          strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
        }
        strip.show();              //This takes the bits from the code directly above and "pushes" those colors out to the NeoPixels
        delay(wait);
      }
    }

    // Input a value 0 to 255 to get a color value.
    // The colours are a transition r - g - b - back to r.
    uint32_t Wheel(byte WheelPos) {
      if(WheelPos < 85) {
       return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
      } else if(WheelPos < 170) {
       WheelPos -= 85;
       return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
      } else {
       WheelPos -= 170;
       return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
      }
    }

If you copy this code, paste it into your Arduino IDE program, and upload it to your Uno, you should see your NeoPixels blasting out some neat color. Play around with the parameters BRIGHTNESS, RAINBOWWAIT, and NUMPIXELS. What happens when you put different numbers in?

When you say you want code for the movie effects, do you just mean the red clockwise pulsing on the back of the proton packs? And by “rainbow startup,” do you mean you want the pack to quickly go through the rainbow, then “land” on red and do pulses?

Exactly . I wanted it on start up to quickly go through a rainbow then stay on red and in a slow clockwise motion .

I was also hoping that when a momentary push button was held it would flash white and blue until released then go back to the slow clockwise red like in the movie .

Also thanks so much for all the help !

Understood. I’ll start working on it.

Your my hero thanks so much