# Pocket Galaxy

## Overview

![](https://cdn-learn.adafruit.com/assets/assets/000/022/408/medium800thumb/adafruit_products_pocky_gally.jpg?1448315236)

The Pocket Galaxy&nbsp;is a small, 3d printed&nbsp;[infinity mirror](http://en.wikipedia.org/wiki/Infinity_mirror)&nbsp;using NeoPixel leds & see-through acrylic mirrors. It makes a fun desk accessory, and a LiPoly battery and charger keep it blinking on the go.

By illuminating the interior of the mirrored frame, the light is reflected 'infinitely'&nbsp;into the distance, creating a black hole-like effect.&nbsp;

![](https://cdn-learn.adafruit.com/assets/assets/000/022/357/medium800/adafruit_products_DSC_0009.jpg?1420743624)

## Parts

Links to these products can also be found on the right sidebar!

- [5V Trinket](https://www.adafruit.com/products/1501)
- [Trinket LiIon/LiPoly Backpack Add-On](https://www.adafruit.com/product/2124)
- [100mAh LiPo Battery](https://www.adafruit.com/products/1570)
- [Breadboard-friendly SPDT Slide Switch](https://www.adafruit.com/products/805)
- [1m NeoPixel Strip Black (60 LED/m)](https://www.adafruit.com/products/1461)&nbsp;You'll only use 1/5th of it
- [Premium Male/Male Jumper wires](https://www.adafruit.com/products/759), or any thin gauge wire.
- 2x [See-Thru Mirrored Acrylic](http://www.tapplastics.com/product/plastics/cut_to_size_plastic/two_way_mirrored_acrylic/558), 1/8" thickness 2 1/8" x 2 1/8" square

**NOTE:&nbsp;** We sell all of the compenents needed for this project EXCEPT the see-through mirrored acrylic. If you have access to a laser cutter you can [buy a sheet and cut](http://www.tapplastics.com/product/plastics/cut_to_size_plastic/two_way_mirrored_acrylic/558), otherwise, two 2 1/8" x 2 1/8" cuts&nbsp;can be bought [here](http://www.tapplastics.com/product/plastics/cut_to_size_plastic/two_way_mirrored_acrylic/558)&nbsp;for $10.

You'll also need a [soldering iron](https://www.adafruit.com/products/1204 "Link: https://www.adafruit.com/products/1204"), some krazy glue&nbsp;and a&nbsp;[3d Printer](https://www.adafruit.com/search?q=3d+printer). This particular Pocket Galaxy&nbsp;was printed on a [Printrbot Simple Metal](https://www.adafruit.com/product/1760).

## Prerequisite Guides

It'd be best to take a look over these guides and get familiar with these components!&nbsp;

- [Introducing Trinket](../../../../introducing-trinket)
- [NeoPixel Uberguide](../../../../adafruit-neopixel-uberguide)
- [Adafruit Pro Trinket LiPoly/LiIon Backpack](../../../../adafruit-pro-trinket-lipoly-slash-liion-backpack)

# Pocket Galaxy

## 3D Printing

The Pocket Galaxy prints in 3 pieces, with about a 2.5 hour print time.

![adafruit_products_Screen_Shot_2015-01-08_at_6.12.33_PM.png](https://cdn-learn.adafruit.com/assets/assets/000/022/400/medium640/adafruit_products_Screen_Shot_2015-01-08_at_6.12.33_PM.png?1421087120)

![adafruit_products_3dprint.jpg](https://cdn-learn.adafruit.com/assets/assets/000/022/401/medium640/adafruit_products_3dprint.jpg?1421087151)

[Download PocketGalaxy.zip](https://learn.adafruit.com/system/assets/assets/000/022/406/original/PocketGalaxy.zip?1421095162)
The two end pieces will house the electronics and mirrored acrylic,&nbsp;and the NeoPixel strips will be glued into the middle ring.

![adafruit_products_DSC_0169.jpg](https://cdn-learn.adafruit.com/assets/assets/000/022/365/medium640/adafruit_products_DSC_0169.jpg?1420752212)

# Pocket Galaxy

## Wiring & Assembly

![](https://cdn-learn.adafruit.com/assets/assets/000/022/366/medium800/adafruit_products_wiring.jpg?1420754955)

Cut the Neopixel strip down to 12 LEDs and remove the silicone casing. Using the middle piece as a reference, bend the Neopixel strip into a square so that each side sits nice and flush. It may take a few attempts, but the better it sits the better it'll look in the end.&nbsp;

&nbsp;

Quick note: any wires used in this project should be on the thinner gauge side and stranded since at the end we'll need to pack it all inside the case. I cut and stripped our breadboard jumper wires.

&nbsp;

Feed 3 wires through the slot of the middle piece and solder to the strip. The wire should be cut to just a bit over the length of one side of the print.

&nbsp;

Now would be a good time to test the strip. If it passes, super glue each side down until it is all in place! Set that piece aside while we prep the rest of the components.

&nbsp;

![adafruit_products_led1.jpg](https://cdn-learn.adafruit.com/assets/assets/000/022/224/medium640/adafruit_products_led1.jpg?1420577918)

![adafruit_products_led2.jpg](https://cdn-learn.adafruit.com/assets/assets/000/022/225/medium640/adafruit_products_led2.jpg?1420577947)

![adafruit_products_led3.jpg](https://cdn-learn.adafruit.com/assets/assets/000/022/226/medium640/adafruit_products_led3.jpg?1420577968)

![adafruit_products_led4.jpg](https://cdn-learn.adafruit.com/assets/assets/000/022/227/medium640/adafruit_products_led4.jpg?1420578002)

![](https://cdn-learn.adafruit.com/assets/assets/000/022/229/medium800/adafruit_products_led5.jpg?1420578144)

In order to fit the LiPo charger in the case,&nbsp;the&nbsp;JST connector will need to be removed, and the battery soldered directly to the contacts.&nbsp;

&nbsp;

Carefully clip the two sides on the open end of the JST, then the two longer leads on the backside. At this point the plastic should fall right off. Remove the remaining metal pieces with a&nbsp;soldering iron.

&nbsp;

![adafruit_products_DSC_0154.jpg](https://cdn-learn.adafruit.com/assets/assets/000/022/367/medium640/adafruit_products_DSC_0154.jpg?1420755261)

![adafruit_products_JST2.jpg](https://cdn-learn.adafruit.com/assets/assets/000/022/368/medium640/adafruit_products_JST2.jpg?1420755297)

![adafruit_products_JST3.jpg](https://cdn-learn.adafruit.com/assets/assets/000/022/369/medium640/adafruit_products_JST3.jpg?1420755334)

Position the PocketG\_Bottom so that the opening for the USB is on the lower left. Place the LiPo battery in the top part, and cut the JST connector off so that the wires reach to the next side, rounding the corner. &nbsp;

&nbsp;

Then solder it to the +/- pads where the JST used to be. Be careful not to let the wires short!&nbsp;

&nbsp;

Also at this point, cut the trace between the two switch points so an on/off switch can be added&nbsp;:)

![adafruit_products_DSC_0159.jpg](https://cdn-learn.adafruit.com/assets/assets/000/022/372/medium640/adafruit_products_DSC_0159.jpg?1420755936)

![adafruit_products_batt_charger.jpg](https://cdn-learn.adafruit.com/assets/assets/000/022/373/medium640/adafruit_products_batt_charger.jpg?1420756033)

After cutting those traces, place the components back in the case as pictured and measure out the length of wire needed to get to the switch. The Trinket slides into the slots with a cut out to access the USB port.

&nbsp;

Bend the leads on the switch 90° so it'll fit on its ledge above the Trinket, and solder to the LiPoly backpack.&nbsp;

![adafruit_products_DSC_0163.jpg](https://cdn-learn.adafruit.com/assets/assets/000/022/374/medium640/adafruit_products_DSC_0163.jpg?1420756448)

![adafruit_products_bentSwitch.jpg](https://cdn-learn.adafruit.com/assets/assets/000/022/375/medium640/adafruit_products_bentSwitch.jpg?1420756523)

![adafruit_products_withSwitch.jpg](https://cdn-learn.adafruit.com/assets/assets/000/022/376/medium640/adafruit_products_withSwitch.jpg?1420756596)

Almost there!!

&nbsp;

&nbsp;

&nbsp;

&nbsp;

&nbsp;

Place all of the components together inside the PocketG\_bottom and measure out the remaining wires.

&nbsp;

![adafruit_products_DSC_0166.jpg](https://cdn-learn.adafruit.com/assets/assets/000/022/377/medium640/adafruit_products_DSC_0166.jpg?1420756896)

Remove the components from the case and solder together the remaining wires:

Trinket GPIO #2 ----\> NeoPixel Data Input  
Trinket 5V ----------\> NeoPixel 5V  
Trinket GND --------\> NeoPixel GND  
Trinket GND --------\> LiPoly Backpack GND   
Trinket BAT+ --------\> LiPoly Backpack BAT  
Trinket 5V ----------\> LiPoly Backpack 5V

It should look something like this!:

![](https://cdn-learn.adafruit.com/assets/assets/000/022/378/medium800/adafruit_products_DSC_0168.jpg?1420757661)

Place the mirrored acrylic into the case, and place each component in. The Trinket and switch have designated spots, whereas the&nbsp;Lipo battery and LiPoly backpack sit freely in the top and right (respectively) within the hollow frame. Clean the acrylic thoroughly to&nbsp;remove any dust/fingerprints. They'll be pretty obvious once it's lit up.

&nbsp;

In order to slide the Trinket into place, you may have to cut down the exposed excess wire/solder on the underside so it sits as flush as possible.

&nbsp;

When all the components are in, make sure the wires all fit around the corners so they don't interfere with it closing. Take the top half and slip it on over the rest of the assembly. The pieces will press fit together with a little force.

![adafruit_products_DSC_0139.jpg](https://cdn-learn.adafruit.com/assets/assets/000/022/379/medium640/adafruit_products_DSC_0139.jpg?1420757916)

![adafruit_products_DSC_0143.jpg](https://cdn-learn.adafruit.com/assets/assets/000/022/380/medium640/adafruit_products_DSC_0143.jpg?1420757941)

![adafruit_products_DSC_0169.jpg](https://cdn-learn.adafruit.com/assets/assets/000/022/381/medium640/adafruit_products_DSC_0169.jpg?1420757968)

![adafruit_products_DSC_0170.jpg](https://cdn-learn.adafruit.com/assets/assets/000/022/382/medium640/adafruit_products_DSC_0170.jpg?1420758023)

![](https://cdn-learn.adafruit.com/assets/assets/000/022/405/medium800/adafruit_products_DSC_0176.jpg?1421094994)

Now we're ready to put some code on there!

# Pocket Galaxy

## Code

Once the case is put together, the reset button to upload on the Trinket is inaccessible. Fortunately it enters the bootloader for a short period of time whenever it is powered over USB. So, once the code is ready, plug it in and hit upload!&nbsp;

I adapted the StrandTest code from the NeoPixel library to only run the rainbow pattern (and slightly faster), but any LED patterns can be used! Here's mine below:

```auto
#include &lt;Adafruit_NeoPixel.h&gt;

#define PIN 2

// 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(12, PIN, NEO_GRB + NEO_KHZ800);

// IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across
// pixel power leads, add 300 - 500 Ohm resistor on first pixel's data input
// and minimize distance between Arduino and first pixel.  Avoid connecting
// on a live circuit...if you must, connect GND first.

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

void loop() {
  rainbow(10);
}


void rainbow(uint8_t wait) {
  uint16_t i, j;

  for(j=0; j&lt;256; j++) {
    for(i=0; i&lt;strip.numPixels(); i++) {
      strip.setPixelColor(i, Wheel((i+j) &amp; 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) {
  WheelPos = 255 - WheelPos;
  if(WheelPos &lt; 85) {
   return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  } else if(WheelPos &lt; 170) {
    WheelPos -= 85;
   return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  } else {
   WheelPos -= 170;
   return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
  }
}
```


## Featured Products

### Adafruit LiIon/LiPoly Backpack Add-On for Pro Trinket/ItsyBitsy

[Adafruit LiIon/LiPoly Backpack Add-On for Pro Trinket/ItsyBitsy](https://www.adafruit.com/product/2124)
If you have an ItsyBitsy or Pro Trinket you probably know it's the perfect little size for a portable project. This LiPoly backpack makes it really easy to do! Instead of wiring 2 or 3 boards together to make a charging system, this little PCB sits on top of the PCB and allows a...

Out of Stock
[Buy Now](https://www.adafruit.com/product/2124)
[Related Guides to the Product](https://learn.adafruit.com/products/2124/guides)
### Adafruit Trinket - Mini Microcontroller - 5V Logic

[Adafruit Trinket - Mini Microcontroller - 5V Logic](https://www.adafruit.com/product/1501)
 **Deprecation Warning: The Trinket bit-bang USB technique it uses doesn't work as well as it did in 2014, many modern computers won't work well. So while we still carry the Trinket so that people can maintain some older projects, we no longer recommend it.** <a...></a...>

Out of Stock
[Buy Now](https://www.adafruit.com/product/1501)
[Related Guides to the Product](https://learn.adafruit.com/products/1501/guides)
### Lithium Ion Polymer Battery - 3.7v 100mAh

[Lithium Ion Polymer Battery - 3.7v 100mAh](https://www.adafruit.com/product/1570)
Lithium-ion polymer (also known as 'lipo' or 'lipoly') batteries are thin, light, and powerful. The output ranges from 4.2V when completely charged to 3.7V. This battery has a capacity of ~100mAh for a total of about 0.4 Wh. If you need a larger battery, <a...></a...>

In Stock
[Buy Now](https://www.adafruit.com/product/1570)
[Related Guides to the Product](https://learn.adafruit.com/products/1570/guides)
### Breadboard-friendly SPDT Slide Switch

[Breadboard-friendly SPDT Slide Switch](https://www.adafruit.com/product/805)
These nice switches are perfect for use with breadboard and perfboard projects. They have 0.1" spacing and snap in nicely into a solderless breadboard. They're easy to switch no matter what size fingers you have, but not so easy that they'll get flipped by accident. Work great as...

In Stock
[Buy Now](https://www.adafruit.com/product/805)
[Related Guides to the Product](https://learn.adafruit.com/products/805/guides)
### Adafruit NeoPixel Digital RGB LED Strip - Black 60 LED 4m

[Adafruit NeoPixel Digital RGB LED Strip - Black 60 LED 4m](https://www.adafruit.com/product/1461)
You thought it couldn't get better than [our world-famous 32-LED-per-meter Digital LED strip](http://adafruit.com/products/306) but we will prove you wrong! You wanted **twice the LEDs**? We got it (well, it's 1.875 times as many but that's within a margin of error)....

Out of Stock
[Buy Now](https://www.adafruit.com/product/1461)
[Related Guides to the Product](https://learn.adafruit.com/products/1461/guides)
### USB cable - A/MiniB

[USB cable - A/MiniB](https://www.adafruit.com/product/260)
This here is your standard A-miniB USB cable, for USB 1.1 or 2.0. Perfect for connecting a PC to your Teensy v2, USB Lipo charger w/Mini B connector, among other things.

Approximately 3 feet / 1 meter long

Color may vary!

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/260)
[Related Guides to the Product](https://learn.adafruit.com/products/260/guides)
### PrintrBot Simple Metal 3D Printer - Black - Assembled

[PrintrBot Simple Metal 3D Printer - Black - Assembled](https://www.adafruit.com/product/1760)
New from Printrbot, the Metal Simple is a brand new rock solid, all metal, fully-assembled Printrbot Simple! As opposed to the [Printrbot Simple Kit](http://www.adafruit.com/products/1735), all of the laser cut wood parts have been replaced by rock solid metal and assembled. In...

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/1760)
[Related Guides to the Product](https://learn.adafruit.com/products/1760/guides)
### Premium Male/Male Jumper Wires - 40 x 6" (150mm)

[Premium Male/Male Jumper Wires - 40 x 6" (150mm)](https://www.adafruit.com/product/758)
Handy for making wire harnesses or jumpering between headers on PCB's. These premium jumper wires are 6" (150mm) long and come in a 'strip' of 40 (4 pieces of each of ten rainbow colors). They have 0.1" male header contacts on either end and fit cleanly next to each other...

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

## Related Guides

- [The PICsellator](https://learn.adafruit.com/the-picsellator.md)
- [NeoPixel Bracelet](https://learn.adafruit.com/neopixel-bracelet.md)
- [DRAFT PUNK](https://learn.adafruit.com/draft-punk.md)
- [Trinket RGB Shield Clock](https://learn.adafruit.com/trinket-rgb-shield-clock.md)
- [Trinket “Question Block” Sound Jewelry](https://learn.adafruit.com/trinket-question-block-sound-jewelry.md)
- [3D Printed Adabot Figurine](https://learn.adafruit.com/3d-printed-adabot-figurine.md)
- [Larson Scanner Shades (Trinket-Powered NeoPixel LED Strip Glasses)](https://learn.adafruit.com/larson-scanner-shades.md)
- [Adding Third Party Boards to the Arduino v1.6.4+ IDE](https://learn.adafruit.com/add-boards-arduino-v164.md)
- [Adafruit ItsyBitsy nRF52840 Express](https://learn.adafruit.com/adafruit-itsybitsy-nrf52840-express.md)
- [Neopixel Cosmic Turtle Necklace](https://learn.adafruit.com/neopixel-led-magnetic-pendant-necklace.md)
- [Genesis Poi: DotStar LED Persistence-of-Vision](https://learn.adafruit.com/genesis-poi-dotstar-led-persistence-of-vision-poi.md)
- [Electronic Animated Eyes for ARM Microcontrollers](https://learn.adafruit.com/animated-electronic-eyes.md)
- [Free-Wired 3x3x3 NeoPixel Cube](https://learn.adafruit.com/free-wire-3x3x3-neopixel-cube.md)
- [Animated Flame Pendant](https://learn.adafruit.com/animated-flame-pendant.md)
- [Adafruit Arduino IDE Setup](https://learn.adafruit.com/adafruit-arduino-ide-setup.md)
