tag:blogger.com,1999:blog-63618410099055395322024-03-05T14:54:42.747-08:00Designing Home ScanUnknownnoreply@blogger.comBlogger1125tag:blogger.com,1999:blog-6361841009905539532.post-49929178549457298092012-03-10T09:23:00.021-08:002012-03-16T08:59:56.966-07:00Designing Home Scanlooking at the world surrounding RFID and the contactless interaction it creates inspired me to think of where this seemingly magic transfer of data will be placed in the future of modern technology. My first thoughts were immediately drawn towards the smart phone craze, specifically iOS and android applications. I started to scan the internet and found out that Apple had been awarded a patent for RFID tag readers (that doubled up as transponders) in touch screen devices. I asked myself what type of applications would be created when RFID phones take a step up to the interactive media platform. So my journey into creating Home Scan began and it has given me the opportunity to design and develop a proof of principle prototype that uses RFID as a mechanism for media delivery. The interaction is not limited to Using the IPhone I can also use tags in the form of key rings to carry out the same function and then use your iPhone to remotely control your media.<br />
<br />
The first idea that I have had is to create an RFID reader that plays music when the right tag has been read the reason for this is to allow you to listen to your favourite Playlist with the greatest amount of speed without ever having to approach your stereo or laptop. I want to then be able to control this from your phone. I have no Idea if this is even possible but I will start with some research to see if it can be achieved. <br />
<br />
What will I need?<br />
<br />
I have an Arduino that I have programmed that allows me to read tags from a transponder Below is the piece of code that I have programmed it with and a photograph of what the reader looks like when it has been set up. I want to create a piece of software that allows me to access media files on my computer with the use of a transponder to call up the various media.<br />
<br />
<pre class="brush: csharp">/* RFID ID12
*/
char val = 0; // variable to store the data from the serial port
void setup() {
Serial.begin(9600); // connect to the serial port
}
void loop () {
// read the serial port
if(Serial.available() > 0) {
val = Serial.read();
Serial.print(val, BYTE);
}
}
</pre><pre class="brush: csharp"></pre><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivTrpi21znbomYKVGuUvkO4YCllAe9255l33j0akauBylxg_Kbcl1nN-owdr1sLtlKsVhpmptyd-YlFqd6F_ZbvPV0qABnhhCHxu2Cl3vdt8n2PsVMRW8ic5yk95fhM5QyTfCFW7MH62c/s1600/IMG_0362.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="300" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivTrpi21znbomYKVGuUvkO4YCllAe9255l33j0akauBylxg_Kbcl1nN-owdr1sLtlKsVhpmptyd-YlFqd6F_ZbvPV0qABnhhCHxu2Cl3vdt8n2PsVMRW8ic5yk95fhM5QyTfCFW7MH62c/s400/IMG_0362.JPG" width="400" /></a></div><div class="separator" style="clear: both; text-align: center;">This is the ID-12 RFID Reader which is used with Arduino to read various tags that transmits at a frequency of 125kHz </div><div class="separator" style="clear: both; text-align: center;"></div><div style="text-align: right;"><div style="text-align: center;"><br />
</div><div style="text-align: center;"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9wi9jaKjCWbwsBjdmJHX5zcQDwDBwM16eisbJyHd8gOuQuATxkLx6Euh6n8n14sXHei_HyvhVT476W-cRGQoNPjQjXn_oIDDEkxnzxsQVsDYHswPsafDnLw8EC9AKpwgxsBtNd0pI2pw/s1600/IMG_0371.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="300" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9wi9jaKjCWbwsBjdmJHX5zcQDwDBwM16eisbJyHd8gOuQuATxkLx6Euh6n8n14sXHei_HyvhVT476W-cRGQoNPjQjXn_oIDDEkxnzxsQVsDYHswPsafDnLw8EC9AKpwgxsBtNd0pI2pw/s400/IMG_0371.JPG" width="400" /></a></div></div><div style="text-align: center;"><br />
</div><div style="text-align: center;">This picture shows some of the wiring used to make it work and below is the schematic of how the reader is connected to the Arduino<br />
<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbGkOn2350n1h1f8fLNCWNAidCWQggYKdYdcNPwq5DCcxHoDi3mXECt9bPt5XH8feNuz4JmFbyJ9q35H7CoOOoxKk7jZVkYz3r85wuLUMISDwSCtwfeiJPq-F1LITm1y8ZPJIkDZhOYLHd/s1600/Shem.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" height="272" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbGkOn2350n1h1f8fLNCWNAidCWQggYKdYdcNPwq5DCcxHoDi3mXECt9bPt5XH8feNuz4JmFbyJ9q35H7CoOOoxKk7jZVkYz3r85wuLUMISDwSCtwfeiJPq-F1LITm1y8ZPJIkDZhOYLHd/s400/Shem.jpg" width="400" /></a></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4mBw3KBCEkHqnGzFOLiDQ3v2GcwaRPxQmIfNIPte6U8GKEnQxJ37HIzeWCA9mNSUrWyzml6bCq3DpkopSkJZqcOqoFGERWvVc39XLh_2ap3-0j_OjRQH9Q4A6ZN2933Lpfhyk1WKLK-co/s1600/Dia.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4mBw3KBCEkHqnGzFOLiDQ3v2GcwaRPxQmIfNIPte6U8GKEnQxJ37HIzeWCA9mNSUrWyzml6bCq3DpkopSkJZqcOqoFGERWvVc39XLh_2ap3-0j_OjRQH9Q4A6ZN2933Lpfhyk1WKLK-co/s400/Dia.jpg" width="326" /></a></div><div class="separator" style="clear: both; text-align: center;"><br />
</div><div class="separator" style="clear: both; text-align: left;"></div><div class="MsoNormal"><div style="text-align: left;">To create this software I am going to use a language called processing, processing is an open source language and programming environment that allows you to create animations, images and interactions. Processing and Arduino have been built to communicate with each other very well and allows you to create many great interactive projects for prototyping. This is why I have chosen to build Home Scan using these tools.</div></div><div class="MsoNormal"><div style="text-align: left;"><br />
</div></div><div class="MsoNormal"><div style="text-align: left;">After spending hours trying to get a piece of code that will work I have come up with this piece below. It works very effectively and it allows me to open up any file or program on my computer. It has been a long process getting there, at first when I scanned a tag related to the link I wanted to open I ended up opening hundreds of url’s which overloaded my laptops memory and caused it to crash. I have modified this code below to allow me to call on links when a unique tag has been read.</div></div><div class="MsoNormal"><br />
</div><div class="MsoNormal"><br />
</div><br />
<div class="separator" style="clear: both; text-align: right;"></div></div></div><div class="separator" style="clear: both; text-align: -webkit-auto;"><br />
</div><pre class="brush: csharp"></pre><br />
<pre class="brush: csharp">/*
import processing.serial.*;
import cc.arduino.*;
Serial myPort;
String tagID = “”;
void setup(){
size (600, 200);
println(Serial.list());
String portnum=Serial.list()[0];
myPort = new Serial(this, portnum, 9600);
myPort.buffer(16);
Pfont myFont= createFont(Pfont.list()[2],24);
textFont(myFont);
}
void draw(){
background(0);
println (tagID);
if(tagID.equals(“000000024C”)) //I Tag
{
link(“http://www.homescan.org/recipe.html”);//link to be called when tag is read
tagID =””;
}
if (tagID.equals(“”))
{
//link (“C:/Users/Brian/Desktop/RFIDAdventureS1.swf”);
tagID=””;
}
if (tagID.equals(“1F001AA747”))
{
//link (“C:/Users/Brian/Desktop/RFIDAdventure.swf”);
tagID=””;
}
}
void serialEvent(Serial myPort){
String inputString= myPort.readString();
tagID = parseString(inputString);
}
String parseString (String thisString) {
String tagString=””;
char firstChar =thisString.charAt(0);
char lastChar =thisString.charAt(thisString.length()-1);
if ((firstChar==0x02) && (lastChar ==0x03)){
tagString= thisString.substring(1,11);
}
return tagString;
}
</pre><div class="separator" style="clear: both; text-align: center;"><iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.blogger.com/video.g?token=AD6v5dwItSDjQg0UhBSKx2fGFTprP84d0llowgOLSfXsTSOXgjPie4zlvz37wWANfw73Fg4_jd8QyO-GaPBMz2_erw' class='b-hbp-video b-uploaded' frameborder='0'></iframe></div><div class="separator" style="clear: both; text-align: center;"><br />
</div><div class="separator" style="clear: both; text-align: center;"></div><div class="MsoNormal" style="text-align: left;">Now that I have the code and hardware working the way I want it to I need to link it up to the correct files that I want to play. I have decided to use a band called Muse to signify my music play list and Marina and the Diamonds to represent my girlfriends playlist so that the demo shows how it would work if the house had multiple occupants. I also would like to use key fobs as well as the iPhone to start music and videos the reason for this is that children that are too young to work a phone, DVD player or stereo can access their favourite CD’s or videos by swiping it over the home scan reader. </div><div class="MsoNormal" style="text-align: left;"><br />
</div><div class="MsoNormal" style="text-align: left;">I have found an application that is going to work perfectly to control the media on my computer to represent how the home scan phone app would work if it was taken past the prototyping stages. The application is called mobile mouse pro and costs about £1.50 from the app store. This app allows me to control media players such as Gom by customising the interface to play pause fast forward and skip music and video. Below is a photo graph of what the interface looks like.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://apcmag.com/images/2011/mobilemouseiphone.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="279" src="http://apcmag.com/images/2011/mobilemouseiphone.jpg" width="320" /></a><iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.blogger.com/video.g?token=AD6v5dw488qDhwp8P7EpUQ1IHpZOjBag-YgzUgGA1wudhxeOTA6uAEW95f3C_RhBVDf8V4NY2PzrOXTSODMSzpHPAQ' class='b-hbp-video b-uploaded' frameborder='0'></iframe></div><br />
</div><br />
<div style="text-align: center;"><div style="text-align: left;"></div><h2 align="center" style="text-align: center;"><span style="color: #1f497d;">This is the</span><span style="color: #1f497d;"> interface I have designed for the home scan iPhone app and how it would function.<o:p></o:p></span></h2><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7RZG1KdQfKL0k4nioiQWxUlrsUfXlqo5TYkGG5DHuOz_tlQWT4EfdrawX2iLrphTAKtUHFBbq-Dv5HC6Qex-YiN0kPgQmjozMQWTCyLvQW-idruRz8NAP4axNMKrmafYmtl1uJ-uNfpY/s1600/iphonedesign.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="440" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7RZG1KdQfKL0k4nioiQWxUlrsUfXlqo5TYkGG5DHuOz_tlQWT4EfdrawX2iLrphTAKtUHFBbq-Dv5HC6Qex-YiN0kPgQmjozMQWTCyLvQW-idruRz8NAP4axNMKrmafYmtl1uJ-uNfpY/s640/iphonedesign.jpg" width="640" /></a></div><div><span style="color: #1f497d;"><br />
</span></div></div><br />
<div class="MsoNormal">So I have created the media interface but I would like home scan to do more than just call on links from my computer, I envision the use of RFID technology in the future to be a part of our everyday lives at home work and play. I am focusing mostly on how I think it will be used in our homes and what devices we will control with it. I would like to use a lighting system that can be activated using RFID for this I will use some led’s and a piece of code that will allow the Arduino to read a tag and use that information to activate the light. The piece of code that I have been working on can be found below<b>. </b> </div><div class="MsoNormal"><br />
<pre class="brush: csharp">#include <newsoftserial.h>
NewSoftSerial rfidSerial = NewSoftSerial(8,7);
char code[20];
int ledPin = 9;
int ledPin1 = 10;
int val = 0;
int bytesread = 0;
char ledOn1[] = "1F001AAC16";//1 //Led 1 On
char ledOff1[] ="1F001A9DB6";//2 //Led 1 Off
char ledOn2[] = "2800189B40";//3 //Led 2 on
char ledOff2[] = "280018B406";//4 //Led 2 Off
void setup()
{
Serial.begin(9600); //open serial
rfidSerial.begin(9600); //open serial
pinMode ((13), OUTPUT);
pinMode(ledPin, OUTPUT);
pinMode(ledPin1, OUTPUT);
}
void loop()
{byte brightness;
if (Serial.available()) {
// read the most recent byte (which will be from 0 to 255):
brightness = Serial.read();
// set the brightness of the LED:
analogWrite(ledPin, brightness);
analogWrite(ledPin1, brightness);}
val = 0;
if(rfidSerial.available() > 0) {
if((val = rfidSerial.read()) == 2) { // check for header
bytesread = 0;
while(bytesread < 10)
if( rfidSerial.available() > 0) {
// read 12 digit code
val = rfidSerial.read();
if(val == 3)
{ // if header or stop bytes before the 10 digit reading
break; // stop reading
}
if(val != 2)
{
code[bytesread] = val; // add the digit
bytesread++; // ready to read next digit
code[bytesread] = '\0'; // add the NULL
}
}
if(bytesread >= 10)
{
for(int i=0; i<bytesread; (serial.available()="" add="" always="" cause="" delay?="" i++)="" if="" int="" is="" no="" not="" problem="" reading="" remove="" rfidserial.print("");="" right="" serial.println(tag);="" tag="" text="" while="" with="" {="" }=""> 0)
{
//pos=map(val,0,12,0,179);
//myservo.write(val);
//value *= 10;
//value = (Serial.read());//
//delay(100);
brightness = Serial.read();
// set the brightness of the LED:
analogWrite(ledPin, brightness);
analogWrite(ledPin1, brightness);
}
}
}
}
int FindValidTag(char *code)
{
if(strcmp(code, ledOn1) == 0){
digitalWrite(9, HIGH);
digitalWrite (10, HIGH);
return 1;
}
else if(strcmp(code, ledOff1) == 0){
digitalWrite(9, LOW);
digitalWrite (10, LOW);
return 2;
}
else if(strcmp(code, ledOn2) == 0){
digitalWrite(10, HIGH);
return 1;
}
else if(strcmp(code, ledOff1) == 0){
digitalWrite(10, LOW);
return 2;
}
else{
return 0;
}
}
</bytesread;></newsoftserial.h></pre><br />
</div><div class="MsoNormal"><br />
</div><div class="MsoNormal"><br />
</div><div class="MsoNormal"><br />
</div><div class="MsoNormal"><br />
</div><div class="MsoNormal">In order to control the brightness of the light I first tried to use processing, processing allowed me to use the x coordinates of the mouse to change the brightness, the window I was presented with was very limited in size and only gave me 256 x 196px as the active area I could hover my mouse over.</div><br />
<span style="font-family: Calibri, sans-serif; font-size: 11pt; line-height: 115%;"><br />
</span><br />
<div class="separator" style="clear: both; text-align: center;"><iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.blogger.com/video.g?token=AD6v5dwjeBpvVDaHAxVIydZFxvX9yvl2Ob6th1sKx7QNI4WLZDwEbXRSlz1A6XPOwsSIXJHItg_eI1tz8NO4fKknIA' class='b-hbp-video b-uploaded' frameborder='0'></iframe></div><div style="text-align: center;"><span style="font-family: Calibri, sans-serif; font-size: 11pt; line-height: 115%;"><br />
</span></div><div style="text-align: center;"><span style="font-family: Calibri, sans-serif; font-size: 11pt; line-height: 115%;"><br />
</span></div><div style="text-align: center;"><span style="font-family: Calibri, sans-serif; font-size: 11pt; line-height: 115%;">Below is the code I used in processing to make this possible </span></div><div style="text-align: center;"><span style="font-family: Calibri, sans-serif; font-size: 11pt; line-height: 115%;"><br />
</span></div><div style="text-align: center;"><span style="font-family: Calibri, sans-serif; font-size: 11pt; line-height: 115%;"><br />
</span></div><pre class="brush: csharp">import processing.serial.*;
Serial port;
void setup() {
size(256, 150);
println(“Available serial ports:”);
println(Serial.list());
// Uses the first port in this list (number 0). Change this to
// select the port corresponding to your Arduino board. The last
// parameter (e.g. 9600) is the speed of the communication. It
// has to correspond to the value passed to Serial.begin() in your
// Arduino sketch.
Port = new Serial(this, Serial.list()[0], 9600);
// If you know the name of the port used by the Arduino board, you
// can specify it directly like this.
//port = new Serial(this, “COM1”, 9600);
}
void draw() {
// draw a gradient from black to white
for (int I = 0; I < 256; i++) {
stroke(i);
line(I, 0, I, 150);
}
// write the current X-position of the mouse to the serial port as
// a single byte
port.write(mouseX);
}
</pre><pre class="brush: csharp"></pre><br />
This amount of space is not good enough for me because I want to use the remote mouse for controlling the LED; this will be done simply by connecting to the server and then using the x coordinates to control the lights. The fact that it is so small I will have to keep the pointer in that one area the whole time for the demo which is not very practical. So I have had a look around and found that if I use a program called MAX/MSP which I have been recently introduced to can also communicate very well with the Arduino. The web page I found the fundamental Arduino code (http://arduino.cc/en/Tutorial/Dimmer) also had a simple patch that carried out the same function. I have learned a bit about this software and have found out that I can create a patch that will track my mouse pointers coordinates numerically; I have also discovered if I attach the numeric data to a slider it will scale up and down in accordance to the numbers it reads. And then by using a message called scale I can set the size of the active area to be the same size of an iPhone screen which in turn when moved along the x axis I can very effectively control the brightness of the led from 0 – 255. <br />
<br />
<div class="separator" style="clear: both; text-align: center;"><iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.blogger.com/video.g?token=AD6v5dwj0qleB2qwM_tmTr_TH4flcwY0vTPNei4U88rSInpQgr6dZLOj9cxBhiXlsY-dVGjt3sW48YDyF9hgchcHTg' class='b-hbp-video b-uploaded' frameborder='0'></iframe></div><br />
<span style="font-family: Calibri, sans-serif; font-size: 11pt; line-height: 115%;">The best thing about the code I have used for the LED dimmer is that I can also include another piece of code I adapted to use RFID to switch the LED on. </span>The advantage of this is that I may be able to scan the tag which will switch on the light then I can use my iPhone to control the brightness<span style="font-family: Calibri, sans-serif; font-size: 11pt; line-height: 115%;"> </span><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgO2eAa4O3K4xBEsNLpXY28hSAWEkAb-ovE74NhjUBNwxxCc2uYGxVr39ySVOmNYKTsEKJVNMpWARBz0x_ydYJGW9lwOj7KSUgKmhbOFKL_vNc5BUUPODm-5Q5okI9g1SotJdmiqy7hnjA/s1600/Iphone+dimmer.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="451" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgO2eAa4O3K4xBEsNLpXY28hSAWEkAb-ovE74NhjUBNwxxCc2uYGxVr39ySVOmNYKTsEKJVNMpWARBz0x_ydYJGW9lwOj7KSUgKmhbOFKL_vNc5BUUPODm-5Q5okI9g1SotJdmiqy7hnjA/s640/Iphone+dimmer.JPG" width="640" /></a></div> <span style="font-family: Calibri, sans-serif; font-size: 11pt; line-height: 115%;"> </span><br />
<span style="font-family: Calibri, sans-serif; font-size: 11pt; line-height: 115%;">After many trial and error attempts I have finally got a piece of code working that allows me to scan the appropriate tag to switch on the light. Something that started off to be something I thought would be simple has again taken me days to figure out. But I am glad I have stuck with it. I have also decided to drop the processing code to call up media files I mentioned earlier and use a MAX patch for all the functions that I need. I have spent a lot of time developing this patch so that when I demo the various interactions I will not have to switch one program off just to start up another. I have discovered a MAX patch that allows me to use the original Arduino core RFID code along with the patch. When a tag is read it is stored in a list. As each new card is added so too is a numerical output. The numbers ascend as each new tag is added, I can use this output to carry out a range of functions using a bang and select message. </span><br />
<span style="font-family: Calibri, sans-serif; font-size: 11pt; line-height: 115%;"><br />
</span><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgiCw1hPY68he8LgRnCicksVlscTc50HvROR_nujgbKm9FWrCq_t91scb0tjXV35a8lSWkYB3G47KPKTja2tWl9SENSDl4JIkmKwfokUjCu7tJ-oyrjeWgxn51QSInjjxliZXqmwTEe-r8/s1600/led+rfid.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="401" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgiCw1hPY68he8LgRnCicksVlscTc50HvROR_nujgbKm9FWrCq_t91scb0tjXV35a8lSWkYB3G47KPKTja2tWl9SENSDl4JIkmKwfokUjCu7tJ-oyrjeWgxn51QSInjjxliZXqmwTEe-r8/s640/led+rfid.jpg" width="640" /></a></div><span style="font-family: Calibri, sans-serif; font-size: 11pt; line-height: 115%;"><br />
</span>Unknownnoreply@blogger.com0