element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Merry Boxes & LEDs
  • Challenges & Projects
  • Project14
  • Merry Boxes & LEDs
  • More
  • Cancel
Merry Boxes & LEDs
Blog Holiday Lights and Music Festival With Love and Cheer
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Merry Boxes & LEDs to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: ipv1
  • Date Created: 12 Jan 2019 12:11 PM Date Created
  • Views 3771 views
  • Likes 16 likes
  • Comments 13 comments
  • merryboxesledsch
  • ip_iot
  • holidayspecial19ch
  • merryboxesleds
  • buildapresentch
Related
Recommended

Holiday Lights and Music Festival With Love and Cheer

ipv1
ipv1
12 Jan 2019
    • Video
    • The Python Server
      • Working
      • Dollar stuff
    • BBC Micro bit remotes
      • Working
    • Model Construction (on a budget)
    • The code
    • Conclusion

Christmas is a very special time of year for me and my family. Every year, we celebrate the holidays by making a project together and it becomes a memory for me and my wife.

 

Having moved across the continent, this year's project is one that is on a budget. I started by procuring items from the dollar store and with a handful of components that I brought with me, my wife, my son and I set out to build a mini Christmas festival. I will be keeping the explanation brief though the discussion can be a lengthy one.

 

Our project consists of 2 parts which are intended to serve two different purposes. The first part is designed with the Raspberry Pi at the centre and Texas Instruments BLE lights as the end devices along with a sense hat for good measure. Python based web app allows for the control of colours for the budget tree as well as the jolly snowman.

The second part employs two BBC:Micro bits talking to each other wirelessly and are allow for the control of a string of lights and a musical house.

 

Take a look at the video and then we can walk through the construction.

 

Video

 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

The Python Server

 

The Texas Instruments BLE lights can be connected to via a number of methods. I wrote about talking to them via NodeJS over at HackADay making them IoT Lights and wanted to challenge myself to use python instead.

 

Here is a basic block diagram of the plan.

 

image

 

Working

 

The Raspberry Pi 3 runs a Python Flask Server that does two things.

 

1. It serves up html/css/js files that are requested by a web browser. The loaded page contains a GUI with coloraturas pickers as well as action buttons. The page is also loaded with a javascript element that allows coloraturas picker data to be sent via simple REST like call to the python server.

 

2. The Flask server also exposes a REST like API that allows a client to select a light and send it coloraturas data

 

Once the web page is loaded, the user can use a coloraturas picker for a particular light. Once the user make a selection, a REST call is trigged and the RGB data is sent to the Flask server. This is translated from text to hex values and passed onto the Bluetooth LE module.

 

The Bluetooth LE module is also written in python and allows for the scanning and then communication with BLE lights. The UUIDs are made part of the module and hence once the RGB values are passed to it, it scans for BLE light presence. If found, it then updates the BLE light's characteristics thereby changing the light.

 

There are a number of components to this and the code is flexible enough to allow future expansion. I also added an animation function that sends varying RGB data to the lights making them change colour in sync with each other.

 

Dollar stuff

 

Both the tree and snowman are dollar store bought outs and I implanted the LED lights to make things work. Neo-Pixel strip are way too expensive for us right now and would also require an external power source. I did get an RGB LED strip from Peter Sir but buying an SMPS, LED driver, PCB etc etc was not in my budget this year.

 

BBC Micro bit remotes

 

My son is almost three and he loves to play around with machines and buttons. I wanted to give him the ability to interact with the Christmas project and hence I opted for the wireless control.

 

Working

 

One of the Microbits have the pins broken out and I used 2N3904 NPN Transistors as switched to turn ON and OFF two things. First was an LED strip which was procured at the dollar store and the LEDs change colour due to their internal circuitry.

 

image

 

Second, is a small house with a music chip that plays the Christmas carols which was perfect. After hacking it open, I connected the transistor and resistor directly to the contact.

The code sends commands to toggle the GPIOs ON and OFF and the state is saved within the remote itself.

 

I also employ the LED matrix to display a merry Xmas once the microbit is glued atop the small house.

 

One button allows for toggling the lights while the other button allows for control over the music (and message board).

 

I could have easily connected the Microbit to the Raspberry Pi by the use of GPIOs.

 

Model Construction (on a budget)

 

Water colours can and will bring out the child in everyone and my better half was more than happy to create a model. Cotton for snow and just paint and crayons made this project a family effort. After all its all about bringing everyone together. image

 

image

 

Some Christmas toothpicks and ornaments later, we had a small village with Santa Clause, reindeers and a cottage. My son added his collection of Paw Patrol pups and I added a Lego Anakin Skywalker with R2D2. Everyone had a lot of fun

 

The code

 

Yes the entire code is up on GitHub and you can download and modify as you like. I am learning better python and hence packaging things was something new.

 

Head on over to http://github.com/inderpreet/py_e14_holiday_lights_and_music

 

I am yet to do a setup script though manually installing the modules is quite simple.

""" 
    @file bbc_recieve
    @brief BBC microbit Receiver  By Inderpreet Singh
"""
import radio
import random
from microbit import display, Image, button_a, sleep

radio.on()

def mOn():
    pin0.write_digital(1)
    
def mOff():
    pin0.write_digital(0)

def lOn():
     pin1.write_digital(1)

def lOff():
     pin1.write_digital(0)

# Event loop.
while True:
    # Incomming
    incoming = radio.receive()
    if incoming == 'm-on':
        mOn()
    elif incoming == 'm-off':
        mOff()
     elif incoming =='l-on':
        lOn()
     elif incoming = 'l-off':
        lOff()

 

""" 
    @file bbc_tx
    @brief BBC microbit Receiver  By Inderpreet Singh
"""
import radio
import random
from microbit import * #import display, Image, button_a, sleep, button_b, 

music = False
lights = False
shake = False
count = 0

radio.on()

def toggleMusic():
    global music
    if music == False:
        music = True
        radio.send('m-on')
    elif music == True:
        music = False
        radio.send('m-off')
        
def toggleLights():
    global lights
    if lights == False:
        lights=True
        radio.send('l-on')
    elif lights == True:
        lights = False
        radio.send('l-off')

# Event loop.
while True:

    if button_a.was_pressed():
        toggleMusic()
        
    if button_b.was_pressed():
        toggleLights()
    
    if accelerometer.was_gesture('shake') and shake == False:
        lights = True
        music = True
        radio.send('l-on')
        radio.send('m-on')
        shake = True
        count = 30
        sleep(1)
    
    if shake == True:
        count = count - 1
        if count == 0:
            lights = False
            music = False
            radio.send('l-off')
            radio.send('m-off')
            shake = False

    sleep(1)

Conclusion

 

Christmas is all about family and I a feel these projects have become a tradition for us. We did the best we could given the limited resources and budget I have this year and I am hoping my son will be an active participant next year. I ventured into Python for this project and learned about creating a web server as well as implementing a REST API. I also got the chance to put the BBC Microbit in the hands of my son and I am hoping this will escalate.

 

I hope you had as much fun watching and reading as we had making it. Thanks again and belated happy holidays.

  • Sign in to reply

Top Comments

  • 14rhb
    14rhb over 6 years ago +4
    Hi Inderpreet, That is just so magical - I love all the BLE connectivity you have added. Doing this as a family is fantastic. It must be a shame to pack it up after the festive season. Rod
  • dougw
    dougw over 6 years ago +4
    Awesome interactive diorama. Lots of clever detail. Lots of technology behind the scenes. And lots of fun. Well done!
  • ipv1
    ipv1 over 6 years ago in reply to DAB +4
    @DAB sir, balearicdynamics , ntewinkel Thank you. Its become a tradition of sorts and a fun one at that. Thanks to everyone and especially Robert Peter Oakes for lending me a scope and soldering station…
  • shabaz
    shabaz over 6 years ago

    Hi Inderpreet!

     

    It was fun seeing your project, very thorough and detailed as usual, and what a cute kid! I hope you all had a great Xmas and start to the new year.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • ntewinkel
    ntewinkel over 6 years ago in reply to ipv1

    I was quite surprised by it too once I started programming it - I was expecting something of a toy for kids to get started with, but this thing has some seriously advanced capabilities!

     

    I do love the ease of simply snapping on some alligator clip patch cords too image

     

    -Nico

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • ipv1
    ipv1 over 6 years ago in reply to dubbie

    The BBC microbit has a lot more power considering that it can be programmed using a tablet or smartphone. The python packages provided are brilliant to say the least. Makes things amazingly simple.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • dubbie
    dubbie over 6 years ago

    I like the diorama concept of it all. It also seems amazing what a BBC micro:bit can do.

     

    Dubbie

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • balearicdynamics
    balearicdynamics over 6 years ago in reply to ipv1

    Happy to be part of the band!

     

    Enrico

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • More
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube