Friday 4 October 2013

Concatenate a String with a Float

I came up with a very simple and difficult problem with my little Arduino, I couldn't concat a string and a float number, after a few hours on Google I found out the solution:



Helpful link: http://arduino.cc/forum/index.php?topic=103935.0

Lightwave RF Arduino


Intro:
I had some spare time ( and money ) and I decided to make my little flat a beginning of automate house.
I did some research how to control my lights from an Arduino, even knowing that I could replace the normal switch with a relay. This wasnt enough because I wanted to keep the manual system and to be controlled from an Arduino, so after few hours I came up with LightWaveRF system that has been "hacked" and it is possible to be controlled from an Arduino.


LightWaveRF
Their products are working with a simple RF protocol at 434 mhz, and they give you the possibility to control it from your smartphone, remote controller and a webpage.
Some people understood how the protocol works and they just write a simple library to interact with Arduino.
There are various adapter: Light switch, Power socket, Light, Sensor PIR, etc.. and if you get a remote controller and a RF receiver, you can reproduce the same signal from your code.

Sniffing:
I was using this library to find out what ID and what kind of signals the remote controller was sending to the light switch. After a few minutes on the result and few website, I understood how to reproduce the same behaviour with a single click.
I suggest to use the Decode example to get your ID and to understand what kind of signal your are sending. If you have a multi channels remote, you have to be careful on which command and which channel.

Here an example to turn on my light:

Here a little description what message it sends:



Send:
When you got the ID, Channel and which command to send, you re ready to send your first message to your device.
Use the SEND example as based and create your custom message, replace it on the turnOn function and then compile. When the terminal is ready, you should be able to send "1" and whatever you decided to do, it will do it.
Be careful! If something is not working, just try with simple command like ON and OFF, after that move on dimming and mood ones.

Wednesday 13 February 2013

[Python] Monitor directory in linux

Description
I was looking for  something that could tell me when a file has been modified into a specific directory, I found that with Python and Linux, you can use the system call FCNTL.

Solution
The system call FCNTL helps you to monitor a directory and call a personalized function when it is happening.
Below you can find an example that I found on Stack Overflow.


Tuesday 12 February 2013

[JS] Prevent selection when drag

Description
I had a case where I was dragging an object in my canvas and when the mouse was going outside of it, the whole website was selected by my cursor.

Solution
I found this fix that resolve my problem:


Friday 11 January 2013

[JS] Webcam in HTML5



Webcam in HTML5



Introduction
HTML5 has introduced a few months ago this opportunity to access your personal webcam from a webpage, in that way you can avoid to use any flash plugin to grab a snapshot.
You might asking about compatibility with browsers and this is a bad point for this technology because IE still a step behind from other browsers, you can check to this website.

HTML part
You need to add two tags on your page that are the follow:








JS part
The follow part of code is made that will work cross-broswer:




The next part is to get a snapshot when you press on the video object, that is the follow part:



Testing
Now your are ready to try to grab your first snapshot from your webcam, just put everything together and you should see yourself.