Christmas Tree Controller

This is a brief explanation how to create a Christmas tree that its LEDs are controlled by the end user from a website. The concept is pretty simple. We need to have a server, a website, a database, a relay, LEDs and of course a Netduino. Obviously this concept can be applied on a RaspberryPi.

Video Demonstration

General Setup

For this project Node.JS was chosen because it has a popular library called Socket.IO and can be easily connected with MongoDB. Socket.IO is a JavaScript library for real time web applications. It enables real-time communication between web clients and servers. MongoDB is a cross-platform document-oriented database which is classified as a NoSQL database. Socket.IO was used to display the Christmas tree’s animation state (controlled by netduino) in real time to all connected users via Node.JS. MongoDB was used to store the user’s LEDs animation.

Here is a step-by-step breakdown structure of what was done:

Step 1 – User enters animation sequence: Selected LED colours with duration in seconds.

Step 2 – Upon submission, the user’s data is stored in MongoDB and emitted via Socket.IO to all connected clients in JSON.

Step 3 – Netduino checks every two seconds with Node.JS if there’s a new animation for playing. If there is, Node.JS gets the data from the database and returns it to Netduino as JSON string. Then Netduino parses the JSON string and plays the animation. Once it finishes, it instructs Node.js to get the next animation.

Step 4 – Another challenging part was how to setup the relay with the batteries, LEDs and Netduino. The following tutorial was followed and implemented: http://www.instructables.com/id/Controlling-AC-light-using-Arduino-with-relay-modu/?ALLSTEPS

 

FrameworkChristmas

 

Advertisements

LED Controller – Android & Netduino

In today’s tutorial we are going to connect Netduino with Android. It is recommended to first read this tutorial to better understand how Netduino works and can be connected to the LEDs.

Netduino-Android2

Netduino-Android1

The first thing that you need to understand is that Netduino can act as a server that accepts web page requests. Based on the content of the web requests, one can turn on/off LEDs. Therefore we can create an Android application that sends HttpPosts and has full control on our LEDs. It sounds easy right?

In our example we hosted the Netduino server locally by connected the Ethernet cable to the router and connected the Nexus 7 via the Wi-Fi.

Netduino 2 – Introduction to Netduino – Traffic lights

You might ask. What is a Netduino? Netduino is an electronics prototyping platform based on the .NET Micro Framework. Yes, you can use C# and Visual Studio to develop!

NET0012-1_0

To understand how Netduino works we are going to build a traffic lights. I suggest that first you install the .NET Micro Framework on your PC from the following link: http://www.netduino.com/downloads/

For this project we need:

  • Netduino 2 (duh…)
  • Wires
  • Breadboard
  • 3 * 47 Ω (resistors)
  • 1 Red LED
  • 1 Green LED
  • 1 Amber LED

One bought the wires, breadboard, resistors and the LEDs from: http://www.ebay.co.uk/itm/121296151553?_trksid=p2059210.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT. The Netduino 2 from: https://www.coolcomponents.co.uk/netduino-plus-2-net-c-development-board.html

Ok let’s start…

A solderless breadboard is a construction base for prototyping of electronics and it does not require soldering thus making it reusable.  The following video explains better how breadboards work and how to attach resistors and LEDs:

Now that you have a better understanding of how to use a breadboard, we can start building our traffic lights. Finally!

Wire the external LEDs and the resistors as shown in the pictures below:

netduinoTrafficLightsPhoto1 netduinoTrafficLightsSetup

In the code below you will notice that one has defined three Output Ports. One port is for our green LED and is set for digital Pin 0. The second port is our amber LED and  is set for digital Pin 1. The third port is our red LED and is set for digital Pin 3. One is also using the Interrupt Port which is the button on the Netduino. When the button is pressed, the traffic light will change it’s state like in the diagram below.

trafficlightStates

The Output port supports a method named ‘Write’ which accepts a Boolean value. When a ‘true’ value is passed our concerned LED will light up and vice versa. The ‘Thread.Sleep’ command is used to pause the traffic light from changing it’s state quickly.

Here is the final result:

IMG_0667