Archive

Posts Tagged ‘Arduino’

Creating an Ambilight mood light for your television

December 3rd, 2009 Ed No comments

In the struggle to find more cool things to do with the arduino, I thought I’d do what someone on twitter had done, make an “Ambilight”, an ambient light behind your TV that colours whatever is behind your TV the same colour as the average colour on your screen – pretty cool!  Some Philips TV have this, but I’m not willing to spend extra on that (and I have a TV).  I read Szymon Kobalczyk’s Blog and thought I’d give it a whirl.  Currently I’m using one of my existing BlinkMs, but I’ve ordered two RGB LED strips and the necessary (hopefully) components from farnell.

The core idea is:

  • Run “Boblightd”, which monitors the screen (excuse the pun) and calculates the average colour, passing it to a program that sends the message via serial to…
  • An arduino listening for colours, and changes the colour of the BlinkM/RGB LED strip accordingly

This is the result of mine on my computer monitor, looks much better in real life (skip to 30-40s for best demo). Will be even better when the RGB LED strip arrives – that’ll be going behind my 42″ TV downstairs.


Read more…

Categories: Arduino Tags: , , , , ,

Scout racing lights – naturally arduino powered!

November 16th, 2009 Ed No comments

Inspired by techcobweb’s SlotCarDuino, the night before our scout group’s “Pinewood Derby” (cars made by the kids from a block of wood race down a track, powered by gravity), I decided to make a traffic-light system, and an indicator to say which car one (as there’s sometimes a debate)!

So, in between power cuts (6 days on the trot of less than 8hrs of power per day), with only a few hours of awake time before the event, I dismantled my home automation system (no loss, given there’s barely any power for the heating) and connected up the breadboard, ambient lights and a couple of wires that will act as trip wires.  As there are no pull-down resistors, and I have absolutely no components, the trip-wire is connected to ground and then digital pin 3.  Running digitalWrite(3, HIGH); enables the pull-up resistor, so whenever the circuit is complete (i.e. car hasn’t driven through the wire) it reads 0.

The way I made the trip-wire was to stick one wire over the track, and rest it in a small uninsulated loop of wire.  A quick trip to the scout hut proved this worked, although was in serious need of some debouncing as the vibrations on the track caused the wire to jump around a little.

Simple but reasonable effective race switch

The main loop of the code is very simple, it reads the two trip wire readings, and if one changes it increments a winning counter.  If that counter is more than 7000 (fairly random number that seems to work), it turns that lane’s ambient light green.  After that happens, when the next trip wire is broken, the appropriate light goes red.

I stole the one component I did have, a switch, from the B&Q ambient light, and wired that up in a similar way to the trip wires.  At the start of the loop, it checks this value to see if it has changed (the button is a normal switch, not a temporary push-button), and if it has changed (after some debouncing), it resets some variables, checks the trip-wires have been reconnected (and if not, flash the appropriate light), then runs the red-amber-green starting sequence.

The kids seemed to like it, and other than the odd dodgy connection, and a particularly streamlined car going under the wire, it worked perfectly!!

Next year will be a little more high-tech as I’ll change the trip-wires to some kind of optical sensor, and possibly have one at the start of the race so we can display track times, speeds etc.  May even make an automatic releaser, we shall see…

Categories: Arduino Tags: , , ,

Home Easy Interrupts everything!

November 7th, 2009 Ed No comments

Ok, so all the parts of the arduino code work fine – just not all at the same time! The setup is as follows:

An interrupt procedure gets the home easy (HE) signal, and sends it to a callback function.  This converts the sender/recipient/state into strings, and then publishes the data to MQTT.  Problem with this is it takes time, and may be interrupted by the next HE signal.  This problem is exaggerated by the HE motion detectors, which send about 15 on/off messages one after the other.   When this happens, MQTT is interrupted and it leaves the arduino in a very strange state – loop() is paused, and nothing happens until it receives another HE signal, which kicks the arduino back into action – but by that time, any signals like “turn off the central heating” will be lost, so my energy efficient house becomes boiling hot!

So, after lots of hitting my head against a wall, my solution is to add the data to a global “string”, and then in the loop() method, to read this string, split it up into the MQ topic and the data to send to it, and then send it.  I have found the WString library crashes the arduino, so it’s all done by manipulating individual characters in the array.  Really missing the simplicity of Java!

And there are more problems…

Read more…

Arduino Central Heating Control (Home Easy Hack)

November 1st, 2009 Ed No comments

Firstly, I have no qualifications in electronics, I do not totally understand all the different types of central heating programmers, so I accept no responsibility for you screwing up your system. As I don’t have proper central heating cable, I the colour coding is way off – there are no earth wires, despite the pictures showing earth-coloured wires. This is safe – neither the central heating programmer nor the home easy device need earths, so I use the earth wires as control lines.

However, with that over… I’m on a quest to automate my home with arduinos, and central heating is something that “needs” automating. Yes, I could buy a Home Easy central heating controller for £75, but I already have three plugs and in all honesty, nothing to do with them (yet). After reading an article at instructables, I decided to do something similar but hopefully a lot easier. The final result I aimed for was to have my usual central heating/hot water programmer running as usual, but have the home easy plug sitting between it and the pump/boiler so I could make it act like a thermostat. Then, by leaving the central heating on 24×7 on the programmer, I can take full control over it via arduinos and an AM transmitter. Naturally you could use any home easy remote to control the heating as well, but that’s not very exciting! As I’m prone to playing, I also want to be able to bypass the home easy device and let the programmer work as usual – just in case the code/hardware fails!

Read more…

Two-way communication via Nuelectronics ethernet shield…

October 30th, 2009 Ed No comments

…is possible, and does work – but only sometimes.

I struggled last night for several hours trying to get reliable two way communications.  The idea is that every time the arduino receives a home easy command from a remote or motion detector, it sends a message to the MPC-L.  Then, with some funky programming, the server will decide what events to fire off.

Unfortunately while I can reliably receive messages, and reliably send messages, I can’t do both – it just hangs.  I’m thinking it’s the nuelectronics ethernet shield, the software certainly isn’t very nice, so as I’ve only been playing with this for a few days, I’m splashing out on an official shield.  As a by-product of this, it is supported by Nicholas O’Leary’s MQTT code.  So, moving away from last night’s PHP start, I’ll write a small java program to receive these, process them, and fire off any events if need be.

The logic for the event firing will end up being more complicated, but initially, I want a bunch of events/desired actions, and each event has a sequence of signals required, each of which have to happen within a changable amount of time.  Only if a path through the sequence is achieved in the right time will the action be fired.

For example, a motion detector in the hall, and a door open/shut detector on my front door.  An event (i.e. turn off all lights) with a sequence of 1. Motion detector fired, 2. Door opened will detect when someone has just left the house, but obviously you only want it to happen if the time between 1 and 2 isn’t too much, otherwise the person could have walked upstairs and someone else came in through the front door!

I got this working in PHP, so will Java-it-up tonight.  Then will code the more complicated (and more useful) central heating logic (i.e. I want the house at 18 degrees at 7PM, it’s now 16 degrees, and takes 45mins to warm up to 18degrees, so turn on centreal heating at 6.15PM).

AM Transmitters Arrived

October 28th, 2009 Ed 5 comments

Farnell delivered two packages, ordered at 4PM, the next day via UPS – very impressive, must have costed more than the £8 it cost me (free P&P).

So, with the help of the arduino playground and homeeasyhacking, my arduino could receive and transmit home easy messages.

Prototype

The photo shows my prototype of all parts of the project (ambient light – bit of paper coiled up, will be improved soon – and home easy controller).

Wire the data line of the receiver (any of the two work on my receiver) to pin 8, and the data line of the transmitter to pin 6, and connect power/ground/aerials accordingly (I haven’t used an aerial for the receiver yet). A 23cm piece of wire works well as an aerial. All my cables are strands from CAT5 – I’m a cheap-skate!

To use the following code, first download the HomeEasy package from homeeasyhacking, add the .h and .cpp file (Sketch > Add File), then copy and paste the following code. Upload it, then start the serial monitor.

Press a button on a home easy remote and you should see the sender code – copy this, and replace “2427994″ in the code below with yours. Then restart the program, and whatever you programmed the first button on the first slider of the remote should turn off and on. Make sure, unlike me, you haven’t plugged your computer into that device – I eventually got the code working only to kill my computer’s power, oops!

To control another device, change the setHEDevice(0) line.
Read more…

BlinkM Arrived

October 27th, 2009 Ed No comments

BlinkM, 6xAA power-pack container arrived from oomlout (arrived next day, despite being in the middle of postal strikes), along with a free RGB LED – seem like a good place to buy from.

Downloaded the examples and got it working within a few mins.  Slight gotcha was that after I told it to change colour, it changed, then did something else.  Turned out that  a sequence was still running, so I now stop the sequences in the setup() method with BlinkM_stopScript( blinkm_addr );

Categories: Arduino Tags: , ,

First bits arrived

October 26th, 2009 Ed No comments

Freeduino and nuelectronics ethernet shield arrived a couple of days ago, so spent the first evening setting up my machine with Ardiouno 0017 (the development environment/serial monitor) and then started playing with the examples.  Appears to be reasonably simple to do relatively cool things.   Got the LED blinking, a simple webpage being hosted, reflectivity sensor working and ran out of things to do – need more hardware!

Initial plan is to monitor gas usage as I’m currently using currentcost to monitor electricity, so would be nice to get the full picture.

Ordered a BlinkM to start work on an ambient light that will be used to show power consumption, number of emails, traffic, weather – anything really!

Categories: Arduino Tags: