# Magical Mistletoe

## Overview

![](https://cdn-learn.adafruit.com/assets/assets/000/021/851/medium800/proximity_ProductShot2.jpg?1418927394)

This holiday season, shed some&nbsp;light on&nbsp;your relationship with glowing mistletoe. The magic comes from a motion sensor, Trinket and LED sequins. When motion under the mistletoe is sensed, the berries light up!

![](https://cdn-learn.adafruit.com/assets/assets/000/021/761/medium800thumb/proximity_trinket_Mistletoe4.jpg?1448314296)

# Magical Mistletoe

## Tools & Supplies

![](https://cdn-learn.adafruit.com/assets/assets/000/021/697/medium800/trinket_Parts.jpg?1418424518)

If you like soldering and crafting, this intermediate&nbsp;project is for you. We'll be using a Trinket and a motion sensor, so make sure you review the following guides:

- [Introducing&nbsp;Trinket](../../../../introducing-trinket)
- [PIR Motion Sensor](../../../../pir-passive-infrared-proximity-motion-sensor)

Here's the supplies you'll need:

- [Trinket 3.3V](http://www.adafruit.com/product/1500)
- [USB Cable A/Mini B](http://www.adafruit.com/product/260)
- [JST-PH 2-Pin SMT Right Angle Connector](http://www.adafruit.com/product/1769)
- [LiPoly Battery-3.75V 500mAh](http://www.adafruit.com/product/1578)
- [LED Sequins Warm&nbsp;White - 10 (2 packs)](http://www.adafruit.com/product/1758)
- [PIR Motion Sensor](http://www.adafruit.com/product/189)
- [Silicone Cover Stranded Wire 30AWG&nbsp;- 2 colors/2 meters each](https://www.adafruit.com/product/2006)
- Soldering&nbsp;Equipment and Tools
- Dremel tool
- Hot Glue Gun
- Breadboard and wires for testing parts (helpful)
- Mistletoe Bunch (I used the one on [Afloral.com](http://www.afloral.com/Silk-Flowers-Artificial-Flowers-Fake-Flowers/Greenery-Leaves-Grasses-and-Branches/Mistletoe-Hanger-in-Green-and-White-15-Long?utm_medium=shoppingengine&utm_source=googlebase&cvsfa=3651&cvsfe=2&cvsfhu=534c4b2d5842443135352d47522f5748&gclid=CNmhk6HVwcICFeVj7AodYFoAHA))
- Green Felt (Approx. 5" square)
- White Wide Satin Ribbon - Approx. 1 yd.
- Floral Tape (available in craft stores)
- Scissors
- [Needle](http://www.adafruit.com/product/615)&nbsp;and Thread

# Magical Mistletoe

## Circuit Diagram

![](https://cdn-learn.adafruit.com/assets/assets/000/021/700/medium800/trinket_Mistletoe_bb.png?1418593120)

Note that the Trinket is oriented up in this diagram in order to make the pins easily readable. In the finished project, the Trinket will be oriented in the opposite direction with the USB and battery jacks facing down. You may have to adjust this configuration with more or less parallel wired LED sequins for your own mistletoe bunch. The bunch I chose has five branches, so I decided to&nbsp;put LEDs on four of them and leave the center one for the motion sensor. The branches are coded to light up staggered, so you may have to tweak the code since your branches may be labeled differently from mine. Have fun with it.

PIR Sensor Power (Red) --\> Trinket 3V

PIR Sensor Black (Ground) --\> Trinket GND

PIR Sensor Yellow (Output) --\> Trinket Pin 0

LED Branch 1 (+) --\> Trinket Pin 1

LED Branch 2 (+) --\> Trinket Pin 2

LED Branch 3 (+) --\> Trinket Pin 3

LED Branch 4 (+) --\> Trinket Pin 4

All LED Branches (-) --\> Trinket GND

&nbsp;

&nbsp;

# Magical Mistletoe

## Test the Sensor

It's good to become familiar with the motion sensor, so first set up a breadboard according to the [instructions here](../../../../pir-passive-infrared-proximity-motion-sensor/testing-a-pir). You can use either a 3 or 4 battery set-up, so don't panic when you see two battery cases. Have fun waving your hand around.&nbsp;Make sure you try moving the bracket as suggested in the "Triggering" section, so you understand how the sensor works.&nbsp;

![](https://cdn-learn.adafruit.com/assets/assets/000/021/677/medium800/trinket_proximity_pirtestsch.gif?1448032657)

![](https://cdn-learn.adafruit.com/assets/assets/000/021/678/medium800/trinket_proximity_pirtestbb.gif?1448032652)

# Magical Mistletoe

## Prepare Parts

 **Solder the JST Connector to Trinket**

There is a great demonstration of how to do this [here](../../../../adafruit-audio-fx-sound-board/powering-it). Notice they are using the Audio FX Sound Board here, but it's the same technique that we'll&nbsp;use on the Trinket. Start by soldering&nbsp;one of the short side pad footprints on the Trinket and tack the JST into place&nbsp;Then you can properly solder the last three pads without it moving around.

![](https://cdn-learn.adafruit.com/assets/assets/000/021/695/medium800/trinket_adafruit_products_jsttack1.jpg?1418416151)

 **Solder a Wire to the&nbsp;PIR Sensor**

Usually the sensor is used with a larger battery pack, but in order to use the&nbsp;LiPoly, which is a smaller voltage, you'll need to solder a wire to bypass the regulator. The regulator is labeled 7133-1 and has three pins&nbsp;on one side, with a tab on the other. You will be soldering a short wire from the first pin of the regulator to the pad&nbsp;of the&nbsp;resistor located right near the red wire of the sensor's power cable. Make sure you tin both sides of the wire first, and it helps if you use a third arm and tweezers. Solder the regulator pin wire first, to make your life easier. When finished, plug the sensor wires into their jack on the sensor.

Info: 

![](https://cdn-learn.adafruit.com/assets/assets/000/021/696/medium800/trinket_Jumper.jpg?1418419620)

# Magical Mistletoe

## Attach LED Sequins

Pick an outside longer branch to start with. Longer branches will get 3 LEDs, while shorter branches will get 2.&nbsp;Choose three large berries and remove them--we'll deal with those later. For now, we will be doing the wiring for the LED sequins that will replace them.

![proximity_Sprig.jpg](https://cdn-learn.adafruit.com/assets/assets/000/021/822/medium640/proximity_Sprig.jpg?1418838686)

Start at the LED near&nbsp;the tip of the branch. Cut and strip a piece of green wire long enough to go from the (+) of that&nbsp;LED to the (+) of the next LED. Now cut and strip a&nbsp;piece of white wire that will go&nbsp;betweem the&nbsp;(-) of those two&nbsp;LEDs. Solder them in place.&nbsp;Continue the same process for the other LEDs. Two wires on the same end can be twisted and soldered as one. Be sure to leave 4" tails of wire after the last LED to attach to the Trinket.

![proximity_ledSolider2.jpg](https://cdn-learn.adafruit.com/assets/assets/000/021/770/medium640/proximity_ledSolider2.jpg?1418766921)

![proximity_2leds.jpg](https://cdn-learn.adafruit.com/assets/assets/000/021/771/medium640/proximity_2leds.jpg?1418766934)

As you complete a row of LEDs, test their wiring with a small watch battery to be sure they work. Then, use floral tape to wrap each wired branch. Stretch the tape slightly as you go, so the tape adheres. Take the tape all the way to the end of the branch and cover the wires as best as you can. Now repeat wiring and wrapping for the other branches.&nbsp;

![proximity_berryTape.jpg](https://cdn-learn.adafruit.com/assets/assets/000/021/772/medium640/proximity_berryTape.jpg?1418768547)

![proximity_toeTaped.jpg](https://cdn-learn.adafruit.com/assets/assets/000/021/778/medium640/proximity_toeTaped.jpg?1418770425)

# Magical Mistletoe

## Solder Trinket and Sensor

Take the black (-) wire of the sensor and solder it onto the GND of Trinket **on the reverse side** &nbsp;of the board. Now gather all the negative wires (white), and twist the ends together until they form a single wire. It helps to rubberband the other wires out of the way. Tin the end of the white wires.

![proximity_sensorSolider.jpg](https://cdn-learn.adafruit.com/assets/assets/000/021/786/medium640/proximity_sensorSolider.jpg?1418771525)

![proximity_HANDWIRES.jpg](https://cdn-learn.adafruit.com/assets/assets/000/021/788/medium640/proximity_HANDWIRES.jpg?1418771593)

Solder the end of the white wires onto the GND of Trinket. Having problems? You can always cut a short piece of white wire and solder it to the GND on Trinket and then solder the 4 white LED wires to that. Just make sure to apply electrical tape or heat shrink tubing at the junction.

![proximity_boardwired.jpg](https://cdn-learn.adafruit.com/assets/assets/000/021/803/medium640/proximity_boardwired.jpg?1418774963)

Continue to solder the rest of the wires to their correct pins on Trinket. Make sure not to trim the length of the wires on the sensor. You may need to adjust the height later once you hang the mistletoe, and it is better to keep it longer rather than shorter.

![proximity_boardCU.jpg](https://cdn-learn.adafruit.com/assets/assets/000/021/804/medium640/proximity_boardCU.jpg?1418775078)

Place the Trinket between two branches near the top of the bundle, preferably towards the back. Using thread, attach it using the four mounting holes. You should loop the thread a few times through each hole to make sure it is secure.

![proximity_tieOn.jpg](https://cdn-learn.adafruit.com/assets/assets/000/021/805/medium640/proximity_tieOn.jpg?1418775273)

# Magical Mistletoe

## Finishing Touches

Using the floral tape, wrap the sensor wires,&nbsp;using the same stretching technique used doing the LEDs. Leave the last 1.5" bare so there is no tension near the Trinket.

![proximity_motionSen.jpg](https://cdn-learn.adafruit.com/assets/assets/000/021/799/medium640/proximity_motionSen.jpg?1418773461)

Cut a long piece of green wire and thread it through a&nbsp;mounting hole on the sensor, up through the center of the bundle, looping it near the top around a&nbsp;branch. Then, feed it&nbsp;down to the sensor's other mounting hole. It should hang just shy of the longest branches. Twist the wire to secure it.

![proximity_senHanger.jpg](https://cdn-learn.adafruit.com/assets/assets/000/021/800/medium640/proximity_senHanger.jpg?1418773509)

Next, take the&nbsp;satin ribbon and tie a bow&nbsp;around the top of your bundle.&nbsp;Allow longer pieces to dangle&nbsp;on the sides. The bow helps to hide the electronics. You may want to take an extra piece of the ribbon and tie it to the top of the bundle for hanging, as well.

![proximity_bow.jpg](https://cdn-learn.adafruit.com/assets/assets/000/021/801/medium640/proximity_bow.jpg?1418773917)

To prepare the battery, apply a strong tape around the top of the battery to protect the wires from stress. Then, make a holder from felt. Cut two pieces a little bigger than the battery and stitch the sides and the bottom. At the bottom, leave an opening large enough for the JST plug to dangle.

![proximity_battery.jpg](https://cdn-learn.adafruit.com/assets/assets/000/021/806/medium640/proximity_battery.jpg?1418775493)

![proximity_batteryCase.jpg](https://cdn-learn.adafruit.com/assets/assets/000/021/807/medium640/proximity_batteryCase.jpg?1418775694)

Now, use a Dremel to slice each berry in half. Then, using a hot glue gun, attach the berry slices, sandwiching the LED sequins. The idea is to use as little glue as possible to ensure that the LED can allow heat to dissipate. If you can't get hold of a Dremel, you can try getting opaque beads from a craft store, or experiment with little globs of hot glue applied to just one side of the LEDs.

![proximity_dremmel.jpg](https://cdn-learn.adafruit.com/assets/assets/000/021/808/medium640/proximity_dremmel.jpg?1418775954)

![proximity_berry.jpg](https://cdn-learn.adafruit.com/assets/assets/000/021/810/medium640/proximity_berry.jpg?1418776335)

# Magical Mistletoe

## Code

```auto
/* /////////////////////////////////////
 * Mistletoe Code modified by Leslie Birch with huge thanks to PIRsense Code from Arduino Playground
 * The base code is for the Parallax PIR Sensor, which is similar to the Adafruit PIR Sensor
 * @author: Kristian Gohlke / krigoo (_) gmail (_) com / http://krx.at
 * @date:   3. September 2006 
 *
 * kr1 (cleft) 2006 
 * released under a creative commons "Attribution-NonCommercial-ShareAlike 2.0" license
 * http://creativecommons.org/licenses/by-nc-sa/2.0/de/
 *
 *
 * The sensor's output pin goes to HIGH if motion is present.
 * However, even if motion is present it goes to LOW from time to time, 
 * which might give the impression no motion is present. 
 * This program deals with this issue by ignoring LOW-phases shorter than a given time, 
 * assuming continuous motion is present during these phases.
 *  
 */

/////////////////////////////
//VARS
//the time we give the sensor to calibrate (10-60 secs according to the datasheet)
int calibrationTime = 30;        

//the time when the sensor outputs a low impulse
long unsigned int lowIn;         

//the amount of milliseconds the sensor has to be low 
//before we assume all motion has stopped
long unsigned int pause = 2000;  

boolean lockLow = true;
boolean takeLowTime;  

int pirPin = 0;    //the digital pin connected to the PIR sensor's output
int ledPin1 = 1;
int ledPin2 = 2;
int ledPin3 = 3;
int ledPin4 = 4;


/////////////////////////////
//SETUP
void setup(){
  //Serial.begin(9600);
  pinMode(pirPin, INPUT);
  pinMode(ledPin1, OUTPUT);
  pinMode(ledPin2, OUTPUT);
  pinMode(ledPin3, OUTPUT);
  pinMode(ledPin4, OUTPUT);
  digitalWrite(pirPin, LOW);

  //give the sensor some time to calibrate
  //Serial.print("calibrating sensor ");
    for(int i = 0; i < calibrationTime; i++){
    //  Serial.print(".");
      delay(1000);
      }
   // Serial.println(" done");
   // Serial.println("SENSOR ACTIVE");
    delay(50);
  }

////////////////////////////
//LOOP
void loop(){

     if(digitalRead(pirPin) == HIGH){
       digitalWrite(ledPin1, HIGH);   //the led visualizes the sensors output pin state
       delay (200);
       digitalWrite(ledPin3, HIGH);   //the led visualizes the sensors output pin state
       delay (400);
       digitalWrite(ledPin2, HIGH);   //the led visualizes the sensors output pin state
       delay (200);
       digitalWrite(ledPin4, HIGH);   //the led visualizes the sensors output pin state
       if(lockLow){  
         //makes sure we wait for a transition to LOW before any further output is made:
         lockLow = false;            
        // Serial.println("---");
        // Serial.print("motion detected at ");
        // Serial.print(millis()/1000);
       //  Serial.println(" sec"); 
         delay(50);
         }         
         takeLowTime = true;
       }

     if(digitalRead(pirPin) == LOW){       
       digitalWrite(ledPin4, LOW);  //the led visualizes the sensors output pin state
       delay (200);
       digitalWrite(ledPin2, LOW);  //the led visualizes the sensors output pin state
       delay (400);
       digitalWrite(ledPin3, LOW);  //the led visualizes the sensors output pin state
       delay (200);
       digitalWrite(ledPin1, LOW);  //the led visualizes the sensors output pin state

       if(takeLowTime){
        lowIn = millis();          //save the time of the transition from high to LOW
        takeLowTime = false;       //make sure this is only done at the start of a LOW phase
        }
       //if the sensor is low for more than the given pause, 
       //we assume that no more motion is going to happen
       if(!lockLow && millis() - lowIn > pause){  
           //makes sure this block of code is only executed again after 
           //a new motion sequence has been detected
           lockLow = true;                        
           //Serial.print("motion ended at ");      //output
           //Serial.print((millis() - pause)/1000);
          // Serial.println(" sec");
           delay(50);
           }
       }
  }
```

# Magical Mistletoe

## Use it!

![](https://cdn-learn.adafruit.com/assets/assets/000/021/823/medium800/proximity_ProductShot2.jpg?1418838714)

Time for mistletoe fun! Make sure the cable for the motion sensor is tucked up inside the bundle and that the sensor's lens is clear of leaves. Now, plug in the battery and tuck&nbsp;the case inside&nbsp;the top of the branches. Give the sensor about 30 sec. to calibrate and then try walking under the mistletoe. In a few seconds berries will light up.

Here are some other things to consider. I didn't have to adjust the settings on the motion sensor, but know that there are some listed in the [PIR Motion Sensor Guide](../../../../pir-passive-infrared-proximity-motion-sensor). Also, my floral tape was dark green, but really a lighter green would have blended better. If the color bothers you, consider dabbing some paint on the tape. Finally, there is a red LED that triggers on the Trinket when the motion sensor is in use. So, just put a small piece of dark tape over it and the magic will stay undiscovered.

Happy hacking!


## Featured Products

### Adafruit Trinket - Mini Microcontroller - 3.3V Logic

[Adafruit Trinket - Mini Microcontroller - 3.3V Logic](https://www.adafruit.com/product/1500)
 **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...>

In Stock
[Buy Now](https://www.adafruit.com/product/1500)
[Related Guides to the Product](https://learn.adafruit.com/products/1500/guides)
### JST-PH 2-Pin SMT Right Angle Connector

[JST-PH 2-Pin SMT Right Angle Connector](https://www.adafruit.com/product/1769)
A simple 2-pin connector that is compatible with the "JST PH 2-pin" connector - perfect for soldering to the bottom of our [3.3V Logic Trinket](//www.adafruit.com/products/1500) and [5V Logic Trinket](//www.adafruit.com/products/1501)! These mate perfectly with...

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

[Lithium Ion Polymer Battery - 3.7v 500mAh](https://www.adafruit.com/product/1578)
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 500mAh for a total of about 1.9 Wh. If you need a larger (or smaller!) battery, <a...></a...>

In Stock
[Buy Now](https://www.adafruit.com/product/1578)
[Related Guides to the Product](https://learn.adafruit.com/products/1578/guides)
### Adafruit LED Sequins - Warm White - Pack of 5

[Adafruit LED Sequins - Warm White - Pack of 5](https://www.adafruit.com/product/1758)
Sew a little sparkle into your wearable project with an Adafruit LED Sequin. These are the kid-sister to our popular [Flora NeoPixel](http://www.adafruit.com/products/1260), they only show a single color and they don't have digital control, but that makes them smaller easier to...

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

[PIR (motion) sensor](https://www.adafruit.com/product/189)
PIR sensors are used to detect motion from pets/humanoids from about 20 feet away (possibly works on zombies, not guaranteed). This one has an adjustable delay before firing (approx 2-4 seconds), adjustable sensitivity **and** we include a 1 foot (30 cm) cable with a socket so you...

In Stock
[Buy Now](https://www.adafruit.com/product/189)
[Related Guides to the Product](https://learn.adafruit.com/products/189/guides)
### Silicone Cover Stranded-Core Wire - 30AWG in Various Colors

[Silicone Cover Stranded-Core Wire - 30AWG in Various Colors](https://www.adafruit.com/product/2051)
Silicone-sheathing wire is super-flexible and soft, and its also strong! Able to handle up to 200°C and up to 600V, it will do when PVC covered wire wimps out. We like this wire for being extremely supple and flexible, so it is great for wearables or projects where the wire-harness has to...

Out of Stock
[Buy Now](https://www.adafruit.com/product/2051)
[Related Guides to the Product](https://learn.adafruit.com/products/2051/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)
### Silicone Cover Stranded-Core Wire - 2m 30AWG White

[Silicone Cover Stranded-Core Wire - 2m 30AWG White](https://www.adafruit.com/product/2006)
Silicone-sheathing wire is super-flexible and soft, and its also strong! Able to handle up to 200°C and up to 600V, it will do when PVC covered wire wimps out. We like this wire for being extremely supple and flexible, so it is great for wearables or projects where the wire-harness has to...

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

## Related Guides

- [PIR Motion Sensor](https://learn.adafruit.com/pir-passive-infrared-proximity-motion-sensor.md)
- [Adding Third Party Boards to the Arduino v1.6.4+ IDE](https://learn.adafruit.com/add-boards-arduino-v164.md)
- [Trinket “Question Block” Sound Jewelry](https://learn.adafruit.com/trinket-question-block-sound-jewelry.md)
- [Trinket Powered Rover](https://learn.adafruit.com/trinket-powered-rover.md)
- [Larson Scanner Shades (Trinket-Powered NeoPixel LED Strip Glasses)](https://learn.adafruit.com/larson-scanner-shades.md)
- [Trinket / Gemma Blinky Eyes](https://learn.adafruit.com/trinket-gemma-blinky-eyes.md)
- [Let’s Put LEDs in Things!](https://learn.adafruit.com/lets-put-leds-in-things.md)
- [Tap Tempo Trinket](https://learn.adafruit.com/tap-tempo-trinket.md)
- [Trinket Sound-Reactive LED Color Organ](https://learn.adafruit.com/trinket-sound-reactive-led-color-organ.md)
- [Trinket (& Gemma) Servo Control](https://learn.adafruit.com/trinket-gemma-servo-control.md)
- [Luminous LED Flowers](https://learn.adafruit.com/luminous-led-flowers.md)
- [Laser Dog Goggles](https://learn.adafruit.com/laser-dog-goggles.md)
- [Cyber Tank Girl Cosplay](https://learn.adafruit.com/cyber-tank-girl-cosplay.md)
- [3D Printed Star Trek Communicator](https://learn.adafruit.com/3d-printed-star-trek-communicator.md)
- [Introducing Trinket](https://learn.adafruit.com/introducing-trinket.md)
- [Adafruit Trinket-Modded Stuffed Animal](https://learn.adafruit.com/adafruit-trinket-modded-stuffed-animal.md)
