Tweeting Christmas Tree
![tree.jpg](/proxy/?url=https://content.instructables.com/F5Y/8DDS/GUQ4JXN7/F5Y8DDSGUQ4JXN7.jpg&filename=tree.jpg)
It's Christmas season once again and that means its time to get together with all of your friends and family to share in the joys of the holiday spirit. In past times, with all of the food, drink and merriment, it has been easy to get too lazy to get up off the couch and change the tree's lighting. Fortunately, we are living in the modern era, and this no longer needs to be a problem. With the assistance of our good friend, the Arduino and a Twitter-enabled cellphone, you can now update the tree as you slouch in a food-induced coma on the couch. Simply tweet the colors you would like to see lit and the tree will light up like Christmas magic.
Go Get Stuff
![1A.jpg](/proxy/?url=https://content.instructables.com/FSD/MXYV/GULNWH6J/FSDMXYVGULNWH6J.jpg&filename=1A.jpg)
You will need:
- (x2) Arduino Uno
- (x2) Wireless SD shield
- (x2) XBee transceivers
- 8 x 6 x 3 project enclosure
- Laser cut panel (file) ***
- (x4) sockets
- 12 awg stranded wire
- 22 awg red and black solid core wire
- (x1) Multipurpose PCB
- (x4) 9V relay (2A @ 120V)
- (x4) 2N3904 transistors
- DPDT rocker switch
- 9V battery connectors
- 9V battery
- 9V battery holder
- M-type power plug
- Lamp cord
- Wire nut (large enough to hold five 12 awg wires)
- (x4) 6-32 x 1/2"
- (x4) 4-40 x 1-1/2"
- 4-40 x 1/2"
- (x4) 6-32 nuts
- (x5) 4-40 nuts
- (x4) adhesive rubber pads (optional)
- USB A/B cable
- A computer
*** If you don't have a laser cutter, you can use a cutting service like Ponoko or print out the file and use it as a cutting guide for making the panel with more traditional tools.
Downloads
Assemble Arduinos
![26A.jpg](/proxy/?url=https://content.instructables.com/FFI/4MKN/GUYGWXXE/FFI4MKNGUYGWXXE.jpg&filename=26A.jpg)
![26C.jpg](/proxy/?url=https://content.instructables.com/F9R/W6OG/GUVU1Q0R/F9RW6OGGUVU1Q0R.jpg&filename=26C.jpg)
![26D.jpg](/proxy/?url=https://content.instructables.com/FCN/OT8P/GUYGWXXR/FCNOT8PGUYGWXXR.jpg&filename=26D.jpg)
![26E.jpg](/proxy/?url=https://content.instructables.com/FY5/MYB3/GUYGWXYE/FY5MYB3GUYGWXYE.jpg&filename=26E.jpg)
Place the wireless SD shield onto the Arduino.
Next, place the XBee transceiver into the socket of the the wireless SD shield such that the antenna is closer to the edge of the board.
Next, place the XBee transceiver into the socket of the the wireless SD shield such that the antenna is closer to the edge of the board.
Wire the Outlets
![2A.jpg](/proxy/?url=https://content.instructables.com/F0W/XF24/GUKAQX6T/F0WXF24GUKAQX6T.jpg&filename=2A.jpg)
![2B.jpg](/proxy/?url=https://content.instructables.com/F50/MWN3/GUKZRN1C/F50MWN3GUKZRN1C.jpg&filename=2B.jpg)
![2C.jpg](/proxy/?url=https://content.instructables.com/F38/XIGT/GULNWH7E/F38XIGTGULNWH7E.jpg&filename=2C.jpg)
![2D.jpg](/proxy/?url=https://content.instructables.com/FNV/0EE3/GUKAQX6V/FNV0EE3GUKAQX6V.jpg&filename=2D.jpg)
![2E.jpg](/proxy/?url=https://content.instructables.com/F9K/W21S/GULNWH7K/F9KW21SGULNWH7K.jpg&filename=2E.jpg)
Attach a 12 gauge wire to each power terminal of the power sockets.
Don't worry about attaching the socket's ground terminal to anything since standard stranded Christmas lights are not grounded.
Don't worry about attaching the socket's ground terminal to anything since standard stranded Christmas lights are not grounded.
Fasten
![3A.jpg](/proxy/?url=https://content.instructables.com/FQ9/OBRK/GULNWH7N/FQ9OBRKGULNWH7N.jpg&filename=3A.jpg)
![3B.jpg](/proxy/?url=https://content.instructables.com/FGT/URVW/GUKAQX6X/FGTURVWGUKAQX6X.jpg&filename=3B.jpg)
![3C.jpg](/proxy/?url=https://content.instructables.com/FMB/IGGF/GUKAQX6Y/FMBIGGFGUKAQX6Y.jpg&filename=3C.jpg)
![3D.jpg](/proxy/?url=https://content.instructables.com/F4M/TANL/GUKZRN2F/F4MTANLGUKZRN2F.jpg&filename=3D.jpg)
Fasten your power sockets to the front panel using nuts and bolts.
Drill a Hole
![4A.jpg](/proxy/?url=https://content.instructables.com/FVX/GLIQ/GUKARMQR/FVXGLIQGUKARMQR.jpg&filename=4A.jpg)
![4B.jpg](/proxy/?url=https://content.instructables.com/FLP/0FST/GUKARMQS/FLP0FSTGUKARMQS.jpg&filename=4B.jpg)
![4C.jpg](/proxy/?url=https://content.instructables.com/FCI/YKVX/GUQ4FV34/FCIYKVXGUQ4FV34.jpg&filename=4C.jpg)
Drill a 5/8" hole for the lamp cord cable centered on the lower edge of one of the shorter side's of the case. In other words, copy what has been done in the pictures.
Knot
![5A.jpg](/proxy/?url=https://content.instructables.com/FEU/CWTE/GUQ4FV3W/FEUCWTEGUQ4FV3W.jpg&filename=5A.jpg)
Pass the lamp cord cable and tie an overhand knot to prevent it from being pulled back through the hole.
When you finally commit to tying the knot, don't forget to leave about 6" of power cable inside the case to work with.
When you finally commit to tying the knot, don't forget to leave about 6" of power cable inside the case to work with.
Wire Nut
![6A.jpg](/proxy/?url=https://content.instructables.com/F6J/3RT2/GUQRPH6L/F6J3RT2GUQRPH6L.jpg&filename=6A.jpg)
![6B.jpg](/proxy/?url=https://content.instructables.com/FDD/1D8V/GUR6IAGP/FDD1D8VGUR6IAGP.jpg&filename=6B.jpg)
![6C.jpg](/proxy/?url=https://content.instructables.com/F6Z/3IMZ/GUKARMSF/F6Z3IMZGUKARMSF.jpg&filename=6C.jpg)
![6D.jpg](/proxy/?url=https://content.instructables.com/FQ5/DVF7/GUR6IAGX/FQ5DVF7GUR6IAGX.jpg&filename=6D.jpg)
Bundle together a corresponding wire from each of the power sockets. In other words, they should all come from the identical terminal of each of the power sockets.
Strip the ends of each of the wires if you have not done so already.
Take one of the wires from the lamp cord. Bundle that with the four wires.
Twist the wire nut firmly onto the wires until they are all securely held in place.
For a little extra protection, I zip tied the bundle of wire directly below the wire nut.
Strip the ends of each of the wires if you have not done so already.
Take one of the wires from the lamp cord. Bundle that with the four wires.
Twist the wire nut firmly onto the wires until they are all securely held in place.
For a little extra protection, I zip tied the bundle of wire directly below the wire nut.
Mark and Drill
![7A.jpg](/proxy/?url=https://content.instructables.com/FTF/MNNJ/GUKARMSG/FTFMNNJGUKARMSG.jpg&filename=7A.jpg)
![7B.jpg](/proxy/?url=https://content.instructables.com/FE5/LT8M/GUKARMSM/FE5LT8MGUKARMSM.jpg&filename=7B.jpg)
![7C.jpg](/proxy/?url=https://content.instructables.com/F4K/63FJ/GUQ4JOS5/F4K63FJGUQ4JOS5.jpg&filename=7C.jpg)
![7D.jpg](/proxy/?url=https://content.instructables.com/FBC/N71A/GUQ4JOS8/FBCN71AGUQ4JOS8.jpg&filename=7D.jpg)
On the inside of the case, place your perfboard and make a mark inside each of its mounting holes.
Next, place the Arduino in a position in which you will be able to plug and unplug your USB cable (once it is affixed to this position). Repeat the process.
When all of the holes are marked on the bottom of the case, drill the circuit board markings using a 9/64" drill bit and the Arduino markings using a 1/8" drill bit.
Next, place the Arduino in a position in which you will be able to plug and unplug your USB cable (once it is affixed to this position). Repeat the process.
When all of the holes are marked on the bottom of the case, drill the circuit board markings using a 9/64" drill bit and the Arduino markings using a 1/8" drill bit.
Build the Circuit
![8A.jpg](/proxy/?url=https://content.instructables.com/FJ0/WHJL/GUS74O5D/FJ0WHJLGUS74O5D.jpg&filename=8A.jpg)
![8B.jpg](/proxy/?url=https://content.instructables.com/F14/C032/GUQ4G6C4/F14C032GUQ4G6C4.jpg&filename=8B.jpg)
![8C.jpg](/proxy/?url=https://content.instructables.com/FWN/EJSB/GUS75I2Z/FWNEJSBGUS75I2Z.jpg&filename=8C.jpg)
![8D.jpg](/proxy/?url=https://content.instructables.com/FMB/PQAB/GUKARUIN/FMBPQABGUKARUIN.jpg&filename=8D.jpg)
![8E.jpg](/proxy/?url=https://content.instructables.com/FGE/8YCA/GUS74O5K/FGE8YCAGUS74O5K.jpg&filename=8E.jpg)
![8F.jpg](/proxy/?url=https://content.instructables.com/F97/WNTC/GUQ4JW39/F97WNTCGUQ4JW39.jpg&filename=8F.jpg)
![8G.jpg](/proxy/?url=https://content.instructables.com/F0P/05O3/GUR6IM9K/F0P05O3GUR6IM9K.jpg&filename=8G.jpg)
![8H.jpg](/proxy/?url=https://content.instructables.com/FMS/JQUJ/GUS74O5O/FMSJQUJGUS74O5O.jpg&filename=8H.jpg)
![8I.jpg](/proxy/?url=https://content.instructables.com/F48/QFQ7/GUS74O5U/F48QFQ7GUS74O5U.jpg&filename=8I.jpg)
![8J.jpg](/proxy/?url=https://content.instructables.com/F21/3OSP/GUKARUJ4/F213OSPGUKARUJ4.jpg&filename=8J.jpg)
![schematic.jpg](/proxy/?url=https://content.instructables.com/FAT/QIC5/GUYMFV95/FATQIC5GUYMFV95.jpg&filename=schematic.jpg)
The Arduino operates at 5V, but the relays operate at 9V. To be able to use the Arduino with the relay, it is necessary to use transistors as controllable switches. When the Arduino pin goes high, the transistor lets 9V from the battery power supply flow through the relay coil, which in turn provides wall current to the socket connected to that particular relay. When the pin goes low, the relay is deactivated and the socket disconnected. In this way, it is possible to turn on and off each of the sockets.
Build the circuit as specified in the schematic, but do not yet worry about Arduino, socket or power connections.
Build the circuit as specified in the schematic, but do not yet worry about Arduino, socket or power connections.
Socket to Me
![9A.jpg](/proxy/?url=https://content.instructables.com/FKQ/8RUE/GUR6IMCB/FKQ8RUEGUR6IMCB.jpg&filename=9A.jpg)
![9B.jpg](/proxy/?url=https://content.instructables.com/FF9/NHQU/GUR6IMCD/FF9NHQUGUR6IMCD.jpg&filename=9B.jpg)
![9C.jpg](/proxy/?url=https://content.instructables.com/F5E/OLI1/GUQ4G6FH/F5EOLI1GUQ4G6FH.jpg&filename=9C.jpg)
Attach the sockets to the N.O. pins on the relay. This is the pin that is not connected when no power is applied to the relay.
Make sure that you note which socket is going to which relay. I solved this problem by labeling the relays from one to four, where one stood in for the socket on the leftmost side of the panel and four was on the far right.
Finally, tie together all of the common pins from all of the relays with the one remaining lamp cord wire. I accomplished this easily by bridging these connections with the common rail on the circuit board and then soldering the lamp wire to the rail.
Make sure that you note which socket is going to which relay. I solved this problem by labeling the relays from one to four, where one stood in for the socket on the leftmost side of the panel and four was on the far right.
Finally, tie together all of the common pins from all of the relays with the one remaining lamp cord wire. I accomplished this easily by bridging these connections with the common rail on the circuit board and then soldering the lamp wire to the rail.
Mount
![10A.jpg](/proxy/?url=https://content.instructables.com/FVA/7TCM/GUR6IMNL/FVA7TCMGUR6IMNL.jpg&filename=10A.jpg)
![10B.jpg](/proxy/?url=https://content.instructables.com/FCC/MJVB/GUS74OZ5/FCCMJVBGUS74OZ5.jpg&filename=10B.jpg)
![10C.jpg](/proxy/?url=https://content.instructables.com/FHX/QM2Y/GUQ4G6MW/FHXQM2YGUQ4G6MW.jpg&filename=10C.jpg)
Pass your 6-32 x 1/2" bolts up through the bottom of the circuit board.
Inside of the case, place the 1/4" spacers onto the bolts.
Put the circuit board on top of the spacers, and then fasten it in place with the nuts.
Inside of the case, place the 1/4" spacers onto the bolts.
Put the circuit board on top of the spacers, and then fasten it in place with the nuts.
Power Switch
![11A.jpg](/proxy/?url=https://content.instructables.com/FD3/NX88/GUS75IRF/FD3NX88GUS75IRF.jpg&filename=11A.jpg)
![11B.jpg](/proxy/?url=https://content.instructables.com/FII/GSJE/GUR6IMOE/FIIGSJEGUR6IMOE.jpg&filename=11B.jpg)
![11C.jpg](/proxy/?url=https://content.instructables.com/FX3/E409/GUS74OZC/FX3E409GUS74OZC.jpg&filename=11C.jpg)
![11D.jpg](/proxy/?url=https://content.instructables.com/FU7/N7Q9/GUKARV61/FU7N7Q9GUKARV61.jpg&filename=11D.jpg)
![11E.jpg](/proxy/?url=https://content.instructables.com/F5F/P181/GUKARV62/F5FP181GUKARV62.jpg&filename=11E.jpg)
![11F.jpg](/proxy/?url=https://content.instructables.com/FFF/6BEC/GUR6IMOG/FFF6BECGUR6IMOG.jpg&filename=11F.jpg)
Pick one of the outer terminals pairs to solder the power connection to. Solder the red and black wires from the 9V plug respectively to each of the terminals in this pair.
Connect a 5" red and black wire to the center pair such that they line up in color with the 9V clip.
Take apart the M-type male connector and slide the protective covering on the wires.
Solder the red wire to the center terminal of the plug. Solder the black wire to the outer barrel terminal.
Twist the cover back onto the plug to hide and protect your soldering.
Connect a 5" red and black wire to the center pair such that they line up in color with the 9V clip.
Take apart the M-type male connector and slide the protective covering on the wires.
Solder the red wire to the center terminal of the plug. Solder the black wire to the outer barrel terminal.
Twist the cover back onto the plug to hide and protect your soldering.
Drill and Mount
![12A.jpg](/proxy/?url=https://content.instructables.com/FTT/WUE3/GUS75ITJ/FTTWUE3GUS75ITJ.jpg&filename=12A.jpg)
![12B.jpg](/proxy/?url=https://content.instructables.com/FU6/DM3U/GUR6IMS8/FU6DM3UGUR6IMS8.jpg&filename=12B.jpg)
![12C.jpg](/proxy/?url=https://content.instructables.com/FJO/HHWY/GUS74P06/FJOHHWYGUS74P06.jpg&filename=12C.jpg)
![12D.jpg](/proxy/?url=https://content.instructables.com/F37/U89C/GUQ4G6PG/F37U89CGUQ4G6PG.jpg&filename=12D.jpg)
![12E.jpg](/proxy/?url=https://content.instructables.com/FGJ/U58L/GUS74P07/FGJU58LGUS74P07.jpg&filename=12E.jpg)
On the side of the case opposite to where the circuit board and Arduino is suppose to mount, mark and drill a 3/4 " hole using a spade bit.
Using the switch's mounting hardware, install the switch into this hole and fasten it firmly in place.
Using the switch's mounting hardware, install the switch into this hole and fasten it firmly in place.
Attach the Arduino
![13A.jpg](/proxy/?url=https://content.instructables.com/F60/S6NW/GUR6IMWD/F60S6NWGUR6IMWD.jpg&filename=13A.jpg)
![13B.jpg](/proxy/?url=https://content.instructables.com/FY0/VCEK/GUS74P0G/FY0VCEKGUS74P0G.jpg&filename=13B.jpg)
![13C.jpg](/proxy/?url=https://content.instructables.com/FUK/EIKU/GUS74P0J/FUKEIKUGUS74P0J.jpg&filename=13C.jpg)
Mount the Arduino to the inside of the case using the 1-1/2" bolts and corresponding 4-40 nuts.
9V Clip
![14A.jpg](/proxy/?url=https://content.instructables.com/FDM/JT4I/GUQ4G6TJ/FDMJT4IGUQ4G6TJ.jpg&filename=14A.jpg)
![14B.jpg](/proxy/?url=https://content.instructables.com/FNC/QMUF/GUR6IN6A/FNCQMUFGUR6IN6A.jpg&filename=14B.jpg)
![14C.jpg](/proxy/?url=https://content.instructables.com/F3N/O6JY/GUS75J1G/F3NO6JYGUS75J1G.jpg&filename=14C.jpg)
Lastly, drill a hole in the bottom of the case in a spot where there is a lot of free space using a 1/8" drill bit.
Fasten the 9V clip into the inside of the case by passing the 4-40 x 1/2" bolt from the inside of the case out. Unlike mounting the relay board and Arduino, the nut should be fastened on the outside of the case.
Fasten the 9V clip into the inside of the case by passing the 4-40 x 1/2" bolt from the inside of the case out. Unlike mounting the relay board and Arduino, the nut should be fastened on the outside of the case.
Program
![15A.jpg](/proxy/?url=https://content.instructables.com/FIM/2O4Y/GUVTYGCE/FIM2O4YGUVTYGCE.jpg&filename=15A.jpg)
Plug in your USB cable, make sure that the switch on the Wireless SD board is toggled to "USB" and program the Arduino with the following code:
When you are done programming it, unplug the USB cable and toggle the switch back to "micro."
When you are done programming it, unplug the USB cable and toggle the switch back to "micro."
Downloads
Connect
![16A.jpg](/proxy/?url=https://content.instructables.com/FVP/LCYI/GUS74P3E/FVPLCYIGUS74P3E.jpg&filename=16A.jpg)
Plug in the wires from the relay board into the female headers on the Arduino board as follows:
Relay/Socket 1 --> Pin 3
Relay/Socket 2 --> Pin 4
Relay/Socket 3 --> Pin 5
Relay/Socket 4 --> Pin 6
Relay coil --> Vin**
Ground --> Ground
**Note that if you find that the Arduino Vin pin is not supplying enough power, you will definately get better results by soldering this wire to the red wire on the power switch that is soldered to the M-type plug (do not connect it to the red wire connected directly to the battery).
Relay/Socket 1 --> Pin 3
Relay/Socket 2 --> Pin 4
Relay/Socket 3 --> Pin 5
Relay/Socket 4 --> Pin 6
Relay coil --> Vin**
Ground --> Ground
**Note that if you find that the Arduino Vin pin is not supplying enough power, you will definately get better results by soldering this wire to the red wire on the power switch that is soldered to the M-type plug (do not connect it to the red wire connected directly to the battery).
Plug It In
![17A.jpg](/proxy/?url=https://content.instructables.com/F10/575S/GUQ4JWE1/F10575SGUQ4JWE1.jpg&filename=17A.jpg)
![17B.jpg](/proxy/?url=https://content.instructables.com/F8Q/7AF3/GUWHGO8U/F8Q7AF3GUWHGO8U.jpg&filename=17B.jpg)
![17C.jpg](/proxy/?url=https://content.instructables.com/FLU/OU9W/GUVU1PXJ/FLUOU9WGUVU1PXJ.jpg&filename=17C.jpg)
Plug the M-type connector into the Arduino and connect the 9V snap to a 9V battery.
Place the battery snugly into the battery clip.
If the light on the Arduino does not turn on right away, try pressing the power switch. It should light up now.
You're now mostly done. Power it down to conserve energy.
Place the battery snugly into the battery clip.
If the light on the Arduino does not turn on right away, try pressing the power switch. It should light up now.
You're now mostly done. Power it down to conserve energy.
Case Closed
![18A.jpg](/proxy/?url=https://content.instructables.com/FKJ/OOWP/GUVU1PYO/FKJOOWPGUVU1PYO.jpg&filename=18A.jpg)
![18B.jpg](/proxy/?url=https://content.instructables.com/FEP/K00M/GUVTYH22/FEPK00MGUVTYH22.jpg&filename=18B.jpg)
![18C.jpg](/proxy/?url=https://content.instructables.com/F3K/YLL2/GUXKZAX5/F3KYLL2GUXKZAX5.jpg&filename=18C.jpg)
Fasten the socket panel firmly in place to close the case.
Add Pads (optional)
![19A.jpg](/proxy/?url=https://content.instructables.com/FMO/JXA9/GUYMFSMM/FMOJXA9GUYMFSMM.jpg&filename=19A.jpg)
![19B.jpg](/proxy/?url=https://content.instructables.com/FK2/ROPO/GUWHGOFE/FK2ROPOGUWHGOFE.jpg&filename=19B.jpg)
A nice finishing touch to the controller box is to add an adhesive rubber in each corner on the bottom of the case.
Setup Python
![F6KVJKQFRBPYL3U.jpg](/proxy/?url=https://content.instructables.com/FHV/0Q0Z/GUYMFSN1/FHV0Q0ZGUYMFSN1.jpg&filename=F6KVJKQFRBPYL3U.jpg)
Before you can go any farther, you need Python.
If you are using a Mac with a recent version of OS X, you should have Python already.
Open the Terminal, type into the command prompt "python" and hit "enter."
This should open up Python.
To see Python do something type the following and then press enter:
print 'hello world'
This will return "Hello World" in the prompt.
To quit Python hit "control-D".
If you don't have Python, you can go download it from python.org and follow the instructions to install.
If you are using a Mac with a recent version of OS X, you should have Python already.
Open the Terminal, type into the command prompt "python" and hit "enter."
This should open up Python.
To see Python do something type the following and then press enter:
print 'hello world'
This will return "Hello World" in the prompt.
To quit Python hit "control-D".
If you don't have Python, you can go download it from python.org and follow the instructions to install.
Dependencies
![dependencies.jpg](/proxy/?url=https://content.instructables.com/F15/PF2O/GUYGWY3E/F15PF2OGUYGWY3E.jpg&filename=dependencies.jpg)
In order for the python script to be able to talk to Twitter and read from the serial port, you are going to need to download and install a series of "packages," which is the Python name for code libraries.
The packages you will need are:
There are instructions for download and installing all of these packages on each of their respective pages.
Keep in mind that simplejson, httplib2, and python-oauth2, are all required for the python-twitter package to work. So, even though we don't specifically call to import in the code, the program will not run properly without them.
The packages you will need are:
There are instructions for download and installing all of these packages on each of their respective pages.
Keep in mind that simplejson, httplib2, and python-oauth2, are all required for the python-twitter package to work. So, even though we don't specifically call to import in the code, the program will not run properly without them.
Setup Twitter API
![cap001.jpg](/proxy/?url=https://content.instructables.com/F5F/VM2Y/GUVTR3OX/F5FVM2YGUVTR3OX.jpg&filename=cap001.jpg)
The next step is to get authorized to use the Twitter API. Go to the Twitter app developer page and enter the account you have created for you Christmas Tree (if you have not done so yet, now would be a good time).
The Twitter app developer page is optimized for people building apps around twitter for other people to use and not people making Christmas Trees responsive to tweets. Fill in the application as best you can.
You will end up at a page which will display a "consumer key" and "consumer secret" number. Below these numbers you will see something about "Your access token." There is probably currently nothing there except a button that says "create access token." Press this button. There now should be two long strings of gibberish labeled "access token" and "access token secret."
Keep this webpage open. You will need to copy and paste these four numbers into your code.
The Twitter app developer page is optimized for people building apps around twitter for other people to use and not people making Christmas Trees responsive to tweets. Fill in the application as best you can.
You will end up at a page which will display a "consumer key" and "consumer secret" number. Below these numbers you will see something about "Your access token." There is probably currently nothing there except a button that says "create access token." Press this button. There now should be two long strings of gibberish labeled "access token" and "access token secret."
Keep this webpage open. You will need to copy and paste these four numbers into your code.
Connect Transmitter
![23A.jpg](/proxy/?url=https://content.instructables.com/FTL/1GY5/GUWHGOEZ/FTL1GY5GUWHGOEZ.jpg&filename=23A.jpg)
Plug in the other Arduino into the computer. Don't worry about programming it. It functions mainly as a pass-through for transmitting serial data.
It is important to make sure that the small switch on the top of the SD wireless shield is set to "USB"
It is important to make sure that the small switch on the top of the SD wireless shield is set to "USB"
Python Script
![cap002.jpg](/proxy/?url=https://content.instructables.com/FP2/5FXT/GUVTYHKW/FP25FXTGUVTYHKW.jpg&filename=cap002.jpg)
Attached below is the python script that checks twitter and sends serial commands to the tree. Download and open this script in a basic text editor. Once downloaded, you may need to rename this file to: twitter_xmas_code.py
Note where in the code it says:
Copy and paste the codes from the Twitter app page into the body of your code as specified.
Also, note where it says:
Replace "copyandpastefromArduinoIDE" with the name of the serial port selected in the Arduino programming environment. You can find this by selecting the "Tools" option from the top menu and then looking at what is checked under the "Serial Port" menu (note the Arduino must be plugged in for the serial port to show up).
After modifying the code, don't forget to save your changes.
Next, open your computer's terminal, and navigate to the directory your python script is in.
Finally, type in the following and press enter:
python twitter_xmas_code.py
Your script should now be running. Leave the terminal open.
Note where in the code it says:
api = twitter.Api(consumer_key='consumerkeyhere', consumer_secret='consumersecrethere', access_token_key='accesskey', access_token_secret='accesssecret')
Copy and paste the codes from the Twitter app page into the body of your code as specified.
Also, note where it says:
ser = serial.Serial('/dev/tty.copyandpastefromArduinoIDE', 9600, timeout=1)
Replace "copyandpastefromArduinoIDE" with the name of the serial port selected in the Arduino programming environment. You can find this by selecting the "Tools" option from the top menu and then looking at what is checked under the "Serial Port" menu (note the Arduino must be plugged in for the serial port to show up).
After modifying the code, don't forget to save your changes.
Next, open your computer's terminal, and navigate to the directory your python script is in.
Finally, type in the following and press enter:
python twitter_xmas_code.py
Your script should now be running. Leave the terminal open.
Downloads
Plug Everything In
![24A.jpg](/proxy/?url=https://content.instructables.com/FJ9/RI61/GUYMFY21/FJ9RI61GUYMFY21.jpg&filename=24A.jpg)
Plug the Christmas lights into the controller box. Make sure you have the right colors plugged into the right sockets. You may want to label them so you don't forget which is which.
Finally, plug the controller box into the wall.
When you are ready to get going, toggle on the power switch on the controller box.
Finally, plug the controller box into the wall.
When you are ready to get going, toggle on the power switch on the controller box.
Tweet
![tree.jpg](/proxy/?url=https://content.instructables.com/FTE/32ZD/GV0L2OJF/FTE32ZDGV0L2OJF.jpg&filename=tree.jpg)
To change the colors tweet at the tree.
You can currently control the tree by tweeting the following color commands:
#red
#green
#white
You can currently control the tree by tweeting the following color commands:
#red
#green
#white