Merry Christmas!

Each year, my roommates and I look for creative alternatives to the traditional Christmas tree. This year, I decided to make our tree interactive. Below is a video of how it works.

 

A flex sensor, attached to the door, bends as the door opens and closes. The sensor produces a unique reading for each angle between the door being completely open and completely closed. The reading is reported back to an arduino which maps the number into an integer between 0-255. This integer is then converted to an 8 bit binary number such as, which is used to determine the pattern of a 1 dimensional cellular automata. The cellular automata looks at the value of the light and its neighbors to create a 3 bit binary number. This number, when converted to base 10, is between 0 and 7, and is used look up a value in the 8 bit pattern. This value, which can be either 0 or 1 is set for each of the lights in the tree.The color of the light at the next step is determined by its own value and its neighbors. If the sum of the three values is less than 1, then the light is red, if its 1 or 2, then its green, and if the sum is 3, then the light is white.

Example sequence of how the Automatree works.

  • Door opened halfway
  • Reading from flex sensor: 657
  • Mapped between 0 and 255: 168
  • Converted to 8 bit binary: 10101000
  • Set new pattern to 10101000
  • Calculate value for each light (0 is off, 1 is on)
  • Create 3 bit number for each light
  • Example: left neighbor is on, light is off, right neighbor is on. 3 bit binary number:  5
  • Look up value of 3 bit binary number in 8 bit binary pattern for each light
  • Example: The 5th integer of 10101000 is (1)
  • Determine the color of the light by adding its value to the value of its neighbors.
  • If sum <1, the color is red. If sum <3, the color is green, if sum = 3, the color is white
  • Left neighbor =1, light =0, right neighbor =0, Final color is (Green)

The interactive tree is a fun way to use emergence to create a bit of festivity around the house during the holiday season. If you would like to recreate the same tree in your home, you can download the arduino code below. Hope you all have a happy holiday!

[Automatree Code]

Leave a Reply

Your email address will not be published.

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.