<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ed&#039;s World &#187; radio</title>
	<atom:link href="http://www.jellard.co.uk/tag/radio/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jellard.co.uk</link>
	<description>Bringing data into real life in a meaningful way</description>
	<lastBuildDate>Fri, 14 May 2010 15:00:43 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>AM Transmitters Arrived</title>
		<link>http://www.jellard.co.uk/2009/10/am-transmitters-arrived/</link>
		<comments>http://www.jellard.co.uk/2009/10/am-transmitters-arrived/#comments</comments>
		<pubDate>Wed, 28 Oct 2009 19:47:29 +0000</pubDate>
		<dc:creator>Ed</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Home automation]]></category>
		<category><![CDATA[AM comms]]></category>
		<category><![CDATA[automation]]></category>
		<category><![CDATA[home easy]]></category>
		<category><![CDATA[radio]]></category>

		<guid isPermaLink="false">http://www.jellard.co.uk/?p=24</guid>
		<description><![CDATA[The AM devices arrived, and thanks to some great blogs, I'm controlling home easy devices via a web page/arduino!]]></description>
			<content:encoded><![CDATA[<p>Farnell delivered two packages, ordered at 4PM, the next day via UPS &#8211; very impressive, must have costed more than the £8 it cost me (free P&amp;P).</p>
<p>So, with the help of the <a href="http://www.arduino.cc/playground/Code/HomeEasy">arduino playground</a> and <a href="http://code.google.com/p/homeeasyhacking/source/browse/#svn/trunk/Arduino">homeeasyhacking</a>, my arduino could receive and transmit home easy messages.</p>
<p><img style="float: right;" src="http://www.jellard.co.uk/wp-content/uploads/2009/10/IMG_4472-300x221.jpg" alt="Prototype" /></p>
<p>The photo shows my prototype of all parts of the project (ambient light &#8211; bit of paper coiled up, will be improved soon &#8211; and home easy controller).</p>
<p>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&#8217;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 &#8211; I&#8217;m a cheap-skate!</p>
<p>To use the following code, first download the HomeEasy package from  <a href="http://code.google.com/p/homeeasyhacking/source/browse/#svn/trunk/Arduino">homeeasyhacking</a>, add the .h and .cpp file (Sketch &gt; Add File), then copy and paste the following code.  Upload it, then start the serial monitor.</p>
<p>Press a button on a home easy remote and you should see the sender code &#8211; copy this, and replace &#8220;2427994&#8243; 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&#8217;t plugged your computer into that device &#8211; I eventually got the code working only to kill my computer&#8217;s power, oops!</p>
<p>To control another device, change the setHEDevice(0) line.<br />
<span id="more-24"></span><br />
<code>#include "HomeEasy.h"<br />
HomeEasy homeEasy;<br />
int onOff = 0;<br />
bool bit2[26]={};<br />
bool bit3[4]={};<br />
int txPin = 6;<br />
</code><code><br />
void setup(){<br />
homeEasy = HomeEasy();<br />
homeEasy.registerAdvancedProtocolHandler(processReceivedRemote);<br />
homeEasy.init();<br />
pinMode(txPin, OUTPUT);<br />
Serial.begin(9600);<br />
setHEDevice(0);  //Set destination home easy device (first device, 0)<br />
itob(2427994,26); //Sender code from remote control - change this to match yours<br />
transmit(1);<br />
delay(10);<br />
transmit(1);<br />
delay(1000);<br />
transmit(0);<br />
delay(10);<br />
transmit(0);<br />
}</code></p>
<p><code>void loop(){<br />
//do nothing regularly<br />
}</code></p>
<p><code>void processReceivedRemote(unsigned long sender, unsigned int recipient, bool on, bool group) {<br />
Serial.print("Sender: ");<br />
Serial.print(sender);<br />
Serial.print("\nRecipient: ");<br />
Serial.print(recipient);<br />
Serial.print("\nOn: ");<br />
Serial.print(on);<br />
Serial.print("\nGroup: ");<br />
Serial.print(group);<br />
Serial.print("\n\n");<br />
}</code></p>
<p><code>void transmit(int blnOn) {<br />
int i;<br />
// Do the latch sequence..<br />
digitalWrite(txPin, HIGH);<br />
delayMicroseconds(275);     // bit of radio shouting before we start.<br />
digitalWrite(txPin, LOW);<br />
delayMicroseconds(9900);     // low for 9900 for latch 1<br />
digitalWrite(txPin, HIGH);   // high again<br />
delayMicroseconds(275);      // wait a moment 275<br />
digitalWrite(txPin, LOW);    // low again for 2675 - latch 2.<br />
delayMicroseconds(2675);<br />
// End on a high<br />
digitalWrite(txPin, HIGH);<br />
// Send HE Device Address<br />
for (i=0; i&lt;26;i++) {<br />
sendPair(bit2[i]);<br />
}<br />
// Send 26th bit - group 1/0<br />
sendPair(false);<br />
// Send 27th bit - on/off 1/0<br />
sendPair(blnOn);<br />
sendPair(bit3[0]); //MSB<br />
sendPair(bit3[1]);<br />
sendPair(bit3[2]);<br />
sendPair(bit3[3]); //LSB<br />
digitalWrite(txPin, HIGH);   // high again (shut up)<br />
delayMicroseconds(275);      // wait a moment<br />
digitalWrite(txPin, LOW);    // low again for 2675 - latch 2.<br />
}<br />
void sendPair(boolean b) {<br />
// Send the Manchester Encoded data 01 or 10, never 11 or 00<br />
if(b)  {<br />
sendBit(true);<br />
sendBit(false);<br />
}  else  {<br />
sendBit(false);<br />
sendBit(true);<br />
}<br />
}<br />
void sendBit(boolean b) {<br />
if (b) {<br />
digitalWrite(txPin, HIGH);<br />
delayMicroseconds(310);   //275 orinally, but tweaked.<br />
digitalWrite(txPin, LOW);<br />
delayMicroseconds(1340);  //1225 orinally, but tweaked.<br />
} else {<br />
digitalWrite(txPin, HIGH);<br />
delayMicroseconds(310);   //275 orinally, but tweaked.<br />
digitalWrite(txPin, LOW);<br />
delayMicroseconds(310);   //275 orinally, but tweaked.<br />
}<br />
}<br />
void itob(unsigned long integer, int length)<br />
{  //needs bit2[length]<br />
  // Convert long device code into binary (stores in global bit2 array.)<br />
 for (int i=0; i&lt;length; i++){<br />
   if ((integer / power2(length-1-i))==1){<br />
     integer-=power2(length-1-i);<br />
     bit2[i]=1;<br />
   }<br />
   else bit2[i]=0;<br />
 }<br />
}<br />
void setHEDevice(int integer) {<br />
int length = 4;<br />
  // Convert long device code into binary (stores in global sendDevice array.)<br />
  for (int i=0; i&lt;length; i++){<br />
    if ((integer / power2(length-1-i))==1){<br />
      integer-=power2(length-1-i);<br />
      hedevice[i]=1;<br />
    }<br />
    else hedevice[i]=0;<br />
  }<br />
}<br />
unsigned long power2(int power){    //gives 2 to the (power)<br />
 unsigned long integer=1;<br />
 for (int i=0; i&lt;power; i++){<br />
   integer*=2;<br />
 }<br />
 return integer;<br />
}<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jellard.co.uk/2009/10/am-transmitters-arrived/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
