第三天



 

展示你們的成果!

 

 

Recognize it: RFID

我們可以找到有很多用於識別物件/人的方法, 比較常見的就是 Bar Code:

-

Bar Code is simply a pattern of dark and light lines or cells used to encode an alphanumeric string. A scanner read the "image" and send it to the computer to interpreting the widths of the light and dark bands as zeros or ones. Of course, it is done by the photodiode, it is far away from what we will use: QRCode.

 

另外, 有不同類型的識別方法:

例如 Face detection:

-

 

路牌識別

-

 

其實以上種種都是 Pattern Recognition. 你們可能看過 reactable, 或者 micro+playground的 react memory.

-

-

-

另外, 由日本研究, 現在日本非常流行的有 QRCode.

"QR stands for Quick Response. It is created in Japan originally for tracking the vehicle parts. But you can see it is attached to every single items in Japan everywhere like magazine, product, even can use QRCode to pay bill in shops.

It is kind of the optical way to do the pattern recognition. If you have your mobile phone a Japan version or from Japan Brand, most of them has a QRCode reader as most of the mobile phone comes with camera. Even the JAVA platform J2ME has a library to read the QRCode. "

-

Daniel Shiffman has made a library for Processing: pqrcode. http://www.shiffman.net/p5/pqrcode/. Just simply download the library and put into Processing.

Online QRCode generator:

http://qrcode.kaywa.com/

Case Studies

The voice of the street: The voice of the street have provided a service for street artists. Combining street art, QR codes and Google Maps the service allows street artists to communicate with the viewer and visa versa.

-


 

Pet Shop Boys - MV - Integral


 

ConQwest

-

http://playareacode.com/work/conqwest/


 

我們現在要玩的就是用於你們休悠卡的 RFID: 射頻識別

Radio Frequency Identification: RFID

"Radio-frequency identification (RFID) is an automatic identification method, relying on storing and remotely retrieving data using devices called RFID tags or transponders.

An RFID tag is an object that can be applied to or incorporated into a product, animal, or person for the purpose of identification using radiowaves. Some tags can be read from several meters away and beyond the line of sight of the reader.

Most RFID tags contain at least two parts. One is an integrated circuit for storing and processing information, modulating and demodulating a (RF) signal, and other specialized functions. The second is an antenna for receiving and transmitting the signal. A technology called chipless RFID allows for discrete identification of tags without an integrated circuit, thereby allowing tags to be printed directly onto assets at a lower cost than traditional tags."

Here in Hong Kong, we have a very great RFID system around us everyday: Octopus Card!

-

Or in Taiwan "悠遊卡"

 

 

RFID and Art

By using RFID, there are many interactive art interact with their audience. Here is some of the references.

"RFID Light Sequencer"
2006
ISHIBASHI Motoi+MANABE Daito
http://www.ntticc.or.jp/Archive/2006/Kidsprogram/Work/RFID.html


 

"iTea"
David Kousemaker
http://www.mediamatic.net/artefact-22745-en.html

Straitjacket Embrace!
David Kousemaker
http://www.lancelmaat.nl/1samen/StraitjacketEmbrace/StraitJacket.html


"Transmission"
Meghan Trainor
http://meghantrainor.com/portfolio/03_nerd/003_nerd.html

 

"Filter"
Meghan Trainor
http://meghantrainor.com/portfolio/03_nerd/003_nerd.html


"ET"
Yuichiro Katsumoto

 

Extension of "Amagatana"

 

 

 

S.U.I. -Smart Urban Intelligence-
2006
computer, video projector, stereo speakers, smartcard reader & smart cards
C & Java with JMF, JSAPI
Prix Ars Electronica 2006, Honorary Mention Interactive Art
Ryota Kimura

 

RFID Snakes and Ladders

Arphield Recordings

Zapped! (http://www.preemptivemedia.net/)

 

Reverse Engineering: RFID Killer!!!!!

Google RFID Zapper!

 

 

RFID with Arduino

RFID with Arduino and Processing

And it is your time to make it. Instead, you just simply need the Arduinio as an input device. I should say just use the serial communication of Arduino, and nothing more. So you don't even need to program the Arduino, but just simply program the client program (reading program), may be, in Processing.

Let's see which devices we will use:

ID Innovations ID12 Reader

RFID Tag

ID12 Breakout (Optional)

Even ID12 Breakout is cheap and useful, but it is just out of stock when we order the equipment and parts.
So you need to hand made this 2mm legs to fit the breadboard.

This is the datasheet of ID12, let's take a look.

Before you do the program in Arduino and Processing, we must need to know the specification of the RFID Tag.Let's take a look now.

The format of the tag is:
STX (ASCII02) + 32 bit ID + ETX (ASCII03)

 

If you do not have the ID-12 Breakout, you need to connect the ciruit like this:

if you are using the breakout board from sparkfun:
Connect the led+resistor to pin 10,
serial connection to pin 9,
ground to pins 1 and 7,
+5v to pins 2 and 11

The following is the program for Arduino

/* 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);
   }
}
 

 

So you are receiving this information from the RFID Tag Reader.


import processing.serial.*;


Serial myPort;      
String tagID = "";  

void setup() {
   size(600,200);
   String portnum = Serial.list()[?];
   myPort = new Serial(this, portnum, 9600);
   myPort.buffer(16);
   PFont myFont = createFont(PFont.list()[2], 24);
   textFont(myFont);
}

                


void draw() {
background(0);
text(tagID, width/4, height/2 - 24);
}



void serialEvent(Serial myPort) {
String inputString = myPort.readString();
tagID = parseString(inputString);
}


String parseString(String thisString) {
String tagString = "";
// first character of the input:
char firstChar = thisString.charAt(0);
// last character of the input:
char lastChar = thisString.charAt(thisString.length() -1);
// if the first char is STX (0x02) and the last char
// is ETX (0x03), then put the next ten bytes
// into the tag string:
if ((firstChar == 0x02) && (lastChar == 0x03)) {
tagString = thisString.substring(1, 11);
}
return tagString;
}

 

Class Works: RFID Trigger Big Load Device

Now you can grab the unique ID of the RFID Tag from the reader. Can you do something with this information?

Okay, you can take some time to think about the interaction.

Here is a very little suggestion:

Remember we can use the Relay box to trigger some high load device like a Desktop Light? It just like something Home Automation: When your is RFID reconginzed Door, once you use the RFID to enter the room, the system knows who you are. Then the system will help you to trigger something like the TV.

 

Or, you may want this complex but powerful version later on:
http://www.arduino.cc/playground/Code/ID12


 

 

討厭電線: Xbee無線通訊

如果你一定要跟其他的Arduino溝通, 或者跟電腦溝通, 你得要用usb或其他線將他們連在一起

你可以用Bluetooth, wifi等無線通訊代替討厭的電線. 這次我們就玩玩Xbee.

Xbee在電子工程同學的眼中應該很熟悉, 他是非常常見用來作無線通訊的module. (模組)

 

看看藝術家怎樣用Xbee

Perform-o-shoes
Experimental devices for performance

Zygote Interactive Ball
tangible interaction

Zygote Interactive Ball at BIP, Italy from Alex Beim on Vimeo.

Shell house
Carolina Pino, more

 

 

Radio Transceivers: XBee

-

In the pervious examples, we have tried RFID to do with something "wireless". But it is super close RF transmission/receive. How about we want to transmit or receive the radio frequency wireless not just in near distance? Just like we receive radio programme with our FM receiver?

"This is the very popular 2.4GHz XBee module from Digi (formally Maxstream). These modules take the 802.15.4 stack (the basis for Zigbee) and wrap it into a simple to use serial command set. These modules allow a very reliable and simple communication between microcontrollers, computers, systems, really anything with a serial port! Point to point and multi-point networks are supported."

Features:

  • 3.3V @ 50mA
  • 250kbps Max data rate
  • 1mW output (+0dBm)
  • 300ft (100m) range
  • Built-in antenna
  • Fully FCC certified
  • 6 10-bit ADC input pins
  • 8 digital IO pins
  • 128-bit encryption
  • Local or over-air configuration
  • AT or API command set
Documents:

This is, as describe, a low cost way to do with Wifi. You can do the prototype with Arduino and build the circuit like this:

-

But you are so luckily that you have me to support you and thanks nkcelectronics selling the Freeduino Arduino XBee Shield Kit. With this kit, you just need to solder them together like playing LEGO. Or you are lazy and have "financial flexible", you can even go spark fun to buy the Kit with Xbee come with. No assemble even needed.

-

The Freeduino Arduino XBee Shield Kit is the PCB board already, what you need to do is just to pick the correct parts and solder in correct location.

And finally you will have something like this:

-

 

Pair of XBee, Pair of transmit and receive:
Step by Step guide to do WIFI communication with XBee

 

Step 1: Configuring the XBee Shield

To configure the XBee shield, you need to know the speciciation of the XBee first. You should at least know the protocol of the XBee.

To do the configuration, you need a program to send data via serial communication.

In PC, there is many program can do this but Hyper Terminal can do this which is come with Windows. (e.g. Bray++)

In MAC or Linux, you can also use the console to do this. (e.g. Zterm, Ubuntu)

-

-

-

You are setting it with the XBee factory setting: 9600:8:n:1. But later on you may change the BPS to 19200 to enhance the faster communication.

You may too scare of the Hyper Terminal. We are so nice to Tom Igoe again. He wrote a Processing Program, which is not even user friendly, (even no interface!) but in the environment that you are familiar and/or comfortable with.

Here you go the Processing Program:

/*
XBee terminal
Language: processing
This program is a basic serial terminal program.
It replaces newline characters from the keyboard
with return characters. It's designed for use with
Linux, Unix, and OS X and XBee radios, because the
XBees don't send newline characters back.
*/
import processing.serial.*;
Serial myPort; // the serial port you're using
String portnum; // name of the serial port
String outString = ""; // the string being sent out the serial port
String inString = ""; // the string coming in from the serial port
int receivedLines = 0; // how many lines have been received
int bufferedLines = 10; // number of incoming lines to keep
void setup() {
size(400, 300); // window size
// create a font with the second font available to the system:
PFont myFont = createFont(PFont.list()[2], 14);
textFont(myFont);
// list all the serial ports:
println(Serial.list());
// based on the list of serial ports printed from the
//previous command, change the 0 to your port's number:
portnum = Serial.list()[0];
// initialize the serial port:
myPort = new Serial(this, portnum, 9600);
}
void draw() {
// clear the screen:
background(0);
// print the name of the serial port:
text("Serial port: " + portnum, 10, 20);
// Print out what you get:
text("typed: " + outString, 10, 40);
text("received:\n" + inString, 10, 80);
}
// This method responds to key presses when the
// program window is active:
void keyPressed() {
switch (key) {
// in OSX, if the user types return,
// a linefeed is returned. But to
// communicate with the XBee, you want a carriage return:
case '\n':
myPort.write(outString + "\r");
outString = "";
break;
case 8: // backspace
// delete the last character in the string:
outString = outString.substring(0, outString.length() -1);
break;
case '+': // we have to send the + signs even without a return:
myPort.write(key);
// add the key to the end of the string:
outString += key;
break;
case 65535:// If the user types the shift key, don't type anything:
break;
// any other key typed, add it to outString:
default:
// add the key to the end of the string:
outString += key;
break;
}
}
// this method runs when bytes show up in the serial port:
void serialEvent(Serial myPort) {
// read the next byte from the serial port:
int inByte = myPort.read();
// add it to inString:
inString += char(inByte);
if (inByte == '\r') {
// if the byte is a carriage return, print
// a newline and carriage return:
inString += '\n';
// count the number of newlines:
receivedLines++;
// if there are more than 10 lines, delete the first one:
if (receivedLines > bufferedLines) {
deleteFirstLine();
}
}
}
// deletes the top line of inString so that it all fits on the screen:
void deleteFirstLine() {
// find the first newline:
int firstChar = inString.indexOf('\n');
// delete it:
inString= inString.substring(firstChar+1);
}

After you copy and Paste it in Processing and run it, you will see something like this

-

So at this moment, you can type something here to send to the XBee.

WAIT!

You should do few more steps before you send the command.

 

Set the Jumper
-

Now, extract the processor from Arduino board and plug the shield in.
Set the jumper to "USB" so that the "gateway" will transfer data between your computer and a wireless network using XBee Modules. And this step is very important that allows you to direct control the maxstream's module through serial commands.

So if you set the jumper to USB, it allows you to do the direct serial communication between USB and XBee.

 

Sending commands for first node

Now, this is a very important step!!!! Follow it up carefully and quickly! (CR is Enter)

1) Enter command mode : +++

2) It returns you "OK"

3) Then backspace to delete those +++

4) Type ATDL <CR>

5) If return "0", it means no node address has been set in the XBee

6) Type ATBD <CR>

7) If returns you the bps, 3 means 9600bps, 4 means 19200bps

8) In order to change the speed to 19200bps, type ATBD4 <CR>

9) Type ATWR <CR> to write the data to memory

10) Type ATCN <CR> to leave the command mode

11) Now you cannot send any data to Xbee as the bps has been change

12) So now go to the program and change 9600bps to 19200bps

13) Type +++ enter the command mode again

14) It returns "OK"

15) Type ATMY1234 <CR> to set the node source address to 1234

16) To confirm it, Type ATMY <CR> and it will returns you the address "1234"

17) Type ATDL5678 <CR> to se the node destination address "5678"

18) Type ATDL <CR> to confirm the address

19) Type ATDH0 <CR> to set it transmit using a 16-bit address

20) To confirm, type ATDH <CR>

21) Type ATID1111 <CR> to set the PAN (personal address network)

22) To confirm, type ATID <CR>

 

After you finish setting up the first node, go and set the other nodes.

1) repart the step 1) to 12)

2) Do the step 12) to 22) but 5678 instead 1234, 1234 instead 5678

 

Finally the information of the pair of radio is:

  ATMY ATDL ATDH ATID
Radio 1 1234 5678 0 1111
Radio 2 5678 1234 0 1111

 

Step 2: Programming the Arduino to send data with XBee Module

We can even do the command above to set the XBee. But just make it as simple as possible, we just simply program one Arduino with XBee to set out data.

The Arduino you are connecting to the computer is JUST receiving data from other module. So you don't need to program that Arduino.

 

int count=0;



void setup() {

   Serial.begin(19200);

}



void loop() {

   Serial.print(count);
   Serial.println();
   delay(1000);



   count++;

   if (count == 1024) {

     count = 0;

   }
}

 

Is that simple?! Yes! Thanks to the lovely XBee module. It plugs to the TX and RX, so nothing more you need to set, just send and receive!

For the Arduino connect to the computer, no program for it. Just simply plug-out the microprocessor and use it as a serial reader, DONE!

Now turn on the Arduino and Serial Monitor, you will something like this:

-

Move around and try this!


 

Advanced Try 1: More than 1 XBee sending data

In the last example, you set both node address and destination address for both XBee. It just a simple example that you can just exchange between two nodes.

How about more than 2 paired nodes?

You SHOULD NOT set the destination address on the nodes which is connected to the computer.

You SHOULD make three nodes like this:

  ATMY ATDL ATDH ATID
Radio 1 1234 0 0 1111
Radio 2 4567 1234 0 1111
Radio 3 5678 1234 0 1111

Radio 1 is the node connected to the computer. ATDL 0 means receiving all data which is aim to send to it. Radio 2 and Radio 3 both sending data to ATDL 1234, that is sending data to Radio 1.

Of course, if you have already programmed the Microcontroller of Radio 2, you should now program the Radio 3 as well. At least make something different in order to see in the terminal 2 different nodes are sending data to the Radio 1.

Do it yourself now!

This is for Radio 2 (from the perviously example
int count=0;



void setup() {

   Serial.begin(19200);

}



void loop() {

   Serial.print(count);
   Serial.println();
   delay(1000);



   count++;

   if (count == 1024) {

     count = 0;

   }
}

 

This is for Radio 3 (amend by yourself)
int count=1024;



void setup() {

   Serial.begin(19200);

}



void loop() {
   Serial.print("?");
   Serial.print(count);
   Serial.println();
   delay(1000);


 
   count--;
 
   if (count == 0) {

     count = 1024;

   }
}

 


Advanced Try 2: Dim the LED at Radio 1 from Radio 2

In the past few examples and exercises, you know how to send the data and receive just in the terminal. How you can apply this transmission-receive?

Here now you come with a very simple exercise: change the LED from Radio 2 to Radio 1.

 

Radio 1 is attached a LED light;

Radio 2 is attached with a VR to change the LED light of Radio 1.

 

It is just about how you program the Arduino (if you are using with microcontroller)

 

Let's take a look on how you program to send the data out:

 

Send and Receive Data

This is for the node which is sending data
#define threshold 10
int lastSensorReading = 0;


void setup() {
Serial.begin(19200);
} void loop() { char sensorValue = readSensor();
if (sensorValue > 0) {
Serial.print(sensorValue, DEC);
Serial.print("\r");
} } char readSensor() {
char message = 0;
int sensorReading = analogRead(0);

if (abs(sensorReading - lastSensorReading) >threshold) {
message = sensorReading/4;
lastSensorReading = sensorReading;
}
return message;
}

 

This is for the node which is receiving data
#define threshold 10
int inByte = -1;
char inString[6];
int stringPos = 0; void setup() {
Serial.begin(19200);
} void loop() { if (Serial.available() >0) {
handleSerial();
} } void handleSerial() {
inByte = Serial.read();
if ( (inByte >= '0') && (inByte <= '9')){
inString[stringPos] = inByte;
stringPos++;
}
if (inByte == '\r') {
int brightness = atoi(inString);
analogWrite(9, brightness); for (int c=0; c<stringPos; c++) {
inString[c] = 0;
} stringPos = 0;
} }

 

Advanced Try 3: Two-ways Trans-receive XBee

If the advanced try 2, you know how to do the simple-way transmit or receive. But it is so stupid to fix 1 node is sending data and another node is receiving data.

We want the node can do the trasmit and receive at the same time, how you can do this?

Hint: just simple combine the program above! But pay attention of the destination. You should pair the XBee.

 


 

Advanced Try 4: Broadcast the XBee

In the lat exercise you can just simply do the pair-to-pair send and receive. How about you want to broadcast it?

Open the XBee manual, Page 26 can help you.

Do the same thing with Advanced Try 3, but this time you can get the data from more than 1 XBee.


 

 

iPod + Arduino = Fun!

-

SparkFun 推出了這個PodGizmo, 將iPod的pin完全breakout.

http://pinouts.ru/Devices/ipod_pinout.shtml

我們在這個網頁裡看到iPod每一支pin的功能. 我們可以直接讀取或寫iPod的資料.

最基本的, 你至少也可以做個廉價 iPod speaker , 當然, 這個很爛, 去買一個算吧! 但你可以想個點子玩玩 iPod!!

立即來試試看!


 

More to explore 1: Fritzing

 

-

 

"Fritzing is an open-source initiative to support designers and artists to take the step from physical prototyping to actual product. We are aiming to create a software in the spirit of Processing and Arduino, that allows the designer/artist/researcher/hobbyist to document their Arduino-based prototype and create a PCB layout for manufacturing. The complimenting website helps to share and discuss drafts and experiences as well as to reduce manufacturing costs.

Fritzing is essentially an Electronic Design Automation software with a low entry barrier, suited for the needs of designers and artists. It uses the metaphor of the breadboard, so that it is easy to transfer your hardware sketch to the software. From there it is possible to create PCB layouts for turning it into a robust PCB yourself or by help of a manufacturer. This functionality is currently based on EAGLE."

 

- - Screenshots

PDK: Part Development Kit

If you want to create your own part for Fritizing, you can download the PDK.


 

Arduino With Flash?

Some of you are so friend with other application like MAX/MSP, PD or Flash. Would you interfacing with other application other than Processing?

Here you go:

http://www.arduino.cc/playground/Main/InterfacingWithSoftware

Take Flash as an example, you can make the Serial reading or sending in Processing. By using XML, Processing act as a middleman between Flash and Arduino.

In Flash, you need to use XMLSocket class to communicate with Processing. In the above link, you can find some application help you to do this in a simple way. Or you can try this:

Basic Proxy in Processing
import processing.serial.*;
import processing.net.*;
int socketNumber = 9001; // the port the server listens on
Server myServer; // the server
Client thisClient; // the reference to the client that logs
char terminationString = '\0'; // zero terminator byte
Serial myPort; // the serial port you're using
String portnum; // name of the serial port
String outString = ""; // the string being sent out the serial port
String inString = ""; // the string coming in from the serial port
String socketString = ""; // string of bytes in from the socket
int receivedLines = 0; // how many serial lines have been received
int bufferedLines = 5; // number of incoming lines to keep
void setup() {
size(400, 300); // window size
// create a font with the a font available to the system:
PFont myFont = createFont(PFont.list()[2], 14);
textFont(myFont);
// list all the serial ports:
println(Serial.list());
// based on the list of serial ports printed from the
//previous command, change the 0 to your port's number:
portnum = Serial.list()[0];
// initialize the serial port:
myPort = new Serial(this, portnum, 9600);
// buffer until a newLine:
myPort.bufferUntil('\n');
// start the server:
myServer = new Server(this, socketNumber); // Starts a server
}
void draw() {
// clear the screen:
background(0);
// print the name of the serial port:
text("Serial port: " + portnum, 10, 20);
// Print out what you get:
text("From serial port:\n" + inString, 10, 80);
text("From socket:\n" + socketString, 200, 80);
// if the client is not null, and says something, display
// what it said:
if (thisClient !=null) {
// print out the current client:
text("Active client: " + thisClient.ip(), 10, 60);
// read what the client said:
String whatClientSaid = thisClient.readString();
if (whatClientSaid != null) {
// save what it said to print to the screen:
socketString = whatClientSaid;
// send what it said out the serial port:
myPort.write(socketString);
}
}
}
// this method runs when bytes show up in the serial port:
void serialEvent(Serial myPort) {
// read the String from the serial port:
String whatSerialSaid = myPort.readStringUntil('\n');
if (whatSerialSaid != null) {
// save what it said to print to the screen:
inString = whatSerialSaid;
// if there is a netClient, send the serial stuff to them:
if (thisClient != null) {
// put a zero byte before and after everything you send to Flash:
thisClient.write(terminationString);
// send the actual text string:
thisClient.write(inString);
// add the end zero byte:
thisClient.write(terminationString);
}
}
}
void serverEvent(Server myServer, Client someClient) {
if (thisClient == null) {
// don't accept the client if we already have one:
thisClient = someClient;
}
}

 

This is the Action Script to Test with
var i = 0;        // counter for the number of clicks
createSocket();
function createSocket() {
socket = new XMLSocket();
// 127.0.0.1 is the same as "localhost"
// i.e. an alias to your local machine
socket.connect("127.0.0.1",9001);
// define the functions that get called when these events happen:
socket.onConnect = success;
socket.onClose = closed;
socket.onData = newData;
}
// When you click on the screen, Flash sends a click out
// the server port:
function onMouseUp() {
trace("click");
socket.send("click ");
socket.send(i);
i++;
}
function success() {
trace("socket opened");
socket.send("F\n");// tell proxy it is talking to flash
}
function closed() {
trace("socket closed");
socket.send("Q\n");// tell Proxy Flash is closing socket
}
function newData(inString) {
trace(inString); // trace the packet of data to the Flash
// output screen
}

 

Or you can try it:

http://www.tinker.it/en/Projects/TinkerProxy

 

Except Thinker Proxy, Tinker.it also written an application for OSX to receive serial information and fenerates Apple Script event for OSX. It can allow you to control almost all application on Mac.

 


More Protocols

AppleScript Proxy

Except Thinker Proxy, Tinker.it also written an application AppleScript Proxy for OSX to receive serial information and fenerates Apple Script event for OSX. It can allow you to control almost all application on Mac.

-


SketchTools

-

Sketchtools is a proxy tool as well. It takes MIDI, serial and OSC. And it is originally design for Phidgets, work with MAKE Controller and Teleo.
http://www.sketchtools.com


 

Griffin Proxi

You may know Griffin if you are MAC user. They have a lot of MAC product like powerMate, Airclick, etc.
Grffin Proxi helps to connect the hardware of Griffin to trigger some of the event like open the itunes.
http://proxi.griffintechnology.com/


 

Girder

-
" Girder is the most powerful and feature rich Windows home automation software available. Girder controls programs like WinAmp and Windows Media Player using infrared and wireless remote controls so you can sit back and enjoy your digital library from your couch. In Home Theater PC's, Girder controls Windows programs (media/DVD players) and hardware devices (sound cards, X10 and serial devices such as projectors, and receivers). Girder is the behind the scenes glue providing full control of your multimedia experience."

http://www.promixis.com/


 

OSC
http://www.cnmat.berkeley.edu/OpenSoundControl

DMX512
http://www.arduino.cc/playground/Learning/DMX

 


 

Work with Telephone?

You can work with telephone system! Asterik is an open source private branch telephone exchange (PBX) . You can manage a phone exchange over an IP network. Just like the ordinary phone system, it can make and tak phone calls, save messages, etc.

With Asterik, you can connect the phone and the internet. For example you can let the user send a email over the phone by clicking on the touchtone keypad. Sure you can imagine, with Arduino/Microcontroller, you can let the user control something physical (a lamp, a motor) over the telephone.
http://www.asterik.org


 

 

追加例子1

A Networked Sensing

We are going to apply some of the technique we have learned before: light sensive detector, VR, even a simple button, or complex sensor;

And sensing something: movement, light or any motion in a remoted place "A" with Arduino connected to the computer which is available for connecting to internet;

-
Figure .1
Networked Sensing

 

We provide one of the option and a set of technique and you decide what you gonna make.


 

Making webcam and upload image to a FTP

How about we put a computer with webcam in remote location A. Once it sense some motion with varies sensor and trigger by something, it takes a photo with webcam and upload it to the internet. And we write a Processing program to send us a email to tell us: There is motion! Click this link for photo!

You might need some programs like this:

MAC: Evocam , Evological, http://www.evological.com
Windows: Fwink, http://lundie.ca/fwink

Evocam is shareware while Fwink is freeware. These kind of webcam application would help you capture a photo from webcam and upload it to a FTP server.

-

You need to provide username and password in order to let the program to upload the captured photo to the FTP server.

Of course you can change make a web page to display your lovely captured photo.

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5" />
<title>lovely photo!</title>
                     
</head>
<body>
     <p>Look!</p>
     <p><img src="http://www.example.com/webcam.jpg">
     </p>
</body>
</html>
                   
 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


Sending Email (php: server side)

You can refer the pervious lecture for the Arduino and sensor construction. Let's take a look on how we can write a Processing program to send an email.

You have many method to send email: Javamail, javascript, etc. Now I would like to show you the most simplest and common way to do this with PHP.

function send_mail($to, $subject, $message) {
$from = "keith@the-demos.com";
mail($to, $subject, $message, "From: $from");
}

 

 

 

 

 

This is the "send_mail" function in the php.

We have prepared a sensor reading value named sensorvalue (we will do the program in Processing later on).
So in the php, we receive the Request from a client (Remote location A).

Then we receive the sensorvalue, we should check out whether the value is over the thershold. (Of course, we are doing the same thing in Processing, but just in case.)

And then we can prepare the email content.

<?php
                   
$threshold = ?;    
echo "<html><head></head><body>\n";
foreach ($_REQUEST as $key => $value)
{
   if ($key == "sensorValue") {
     $sensorValue = $value;
   }
}
if ($sensorValue > $threshold) {
   $messageString =
    " email content: at http://www.example.com/arduino.";
   echo $messageString;
   send_mail("keithlyk@gmail.com", "the cat", $messageString);
} else {
   echo "<p> the cat is not on the mat.</p>\n";
}
                       
echo "</body></html>\n";
end;
 

 

 

 

 

 

 

 

 

 

 

 

 

This is the most simplest way to do it.

Of course, you need a PHP server with you. I am trying this with my own server. And you NEED to change the domain for sure.


Sending Mail (Processing: front end side)

We have finished the Server Side, but it will nothing until the Front end side is calling it to take action.

To communicate with HTTP server in Processing, we can use Net Library.

With net library, we can make HTTP request and get the echo back.

import processing.net.*;        
Client client;                  
boolean requestInProgress;      
String responseString = "";    

void setup()
{
   client = new Client(this, "www.example.com", 80);
   // Send the HTTP GET request:
   client.write(
   "GET  /sendmail.php?sensorValue=321 HTTP/1.0\r\n");
   client.write("HOST: www.example.com\r\n\r\n");

   // note that you've got a request in progress:
   requestInProgress = true;
}
 

 

 

 

 

 

 

 

 

 

 

 

 

 

In the above setup function, we build the connection with the server that contain the php file and sending request to the php directly.

"requestInProgress" is the variable that will be used to monitor whether it is requesting the php, if yes, don't request for twice.

In Draw function, we check the response of the request from the server.

void draw()
{
// available() returns how many bytes //have been received by the client:
if (client.available() > 0) {
// read a byte, convert it to a character, //and add it to the string:
responseString +=char(client.read());
// add to a line of |'s on the screen (crude progress bar):
print("|");
}
// if there's no bytes available, either the response
// hasn't started yet, or it's done:
else {
// if responseString is longer than 0 bytes, //the response has started:
if(responseString.length() > 0 ) {
// you've got some bytes, //but now there's no more to read. Stop:
if(requestInProgress == true) {
// print the response:
println(responseString);
// note that the request is over:
requestInProgress = false;
// reset the string for future requests:
responseString = "";
}
}
}
}

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

If you have a php supported server, you can just simply upload the php, then run the processing and see whether you can send the email.

Of course in you are not sending email when sensor sense something in front of with this simple Processing program.

Now, you can make something like this:

void makeHTTPCall() {
if (requestInProgress == false) {
// Open a connection to the host:
client = new Client(this, "example.com", 80);
// form the request string:
String requestString = "/sendmail.php?sensorValue=" + sensorValue;
println(requestString);
// Send the HTTP GET request:
client.write("GET " + requestString + " HTTP/1.1\n");
client.write("HOST: example.com\n\n");
// note that you've got a request in progress:
requestInProgress = true;
}
}

 

 

 

 

 

 

 

 

 

 

It just simple reconstructe the "setup": sending HTTP request into a function "makeHTTPCall".

And reconstructe more on "draw" into a function "checkNetClient".

void checkNetClient()
{
// available() returns how many bytes //have been received by the client:
if (client.available() > 0) {
// read a byte, convert it to a character, //and add it to the string:
responseString +=char(client.read());
// add to a line of |'s on the screen (crude progress bar):
print("|");
}
// if there's no bytes available, either the response
// hasn't started yet, or it's done:
else {
// if responseString is longer than 0 bytes, //the response has started:
if(responseString.length() > 0 ) {
// you've got some bytes, // but now there's no more to read. Stop:
if(requestInProgress == true) {
// print the response:
println(responseString);
// note that the request is over:
requestInProgress = false;
// reset the string for future requests:
responseString = "";
}
}
}
}

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

In setup(), just setup what you need to set to do with the sensor.

In draw(), you just need to check the sensor value and call the makeHTTPCall and checkNetClient once you got the specific value.

void draw() {
// checking the sensor value via serialPort // put the value into sensorValue if (got the value you want) { makeHTTPCall(); } if (requestInProgress) { checkNetClient(); }
}

 

 

 

 

 

 

 

 

 

 

It looks very simple right? Make you own work now!

Extended Readings:
Field Work, Masaki Fijihata: http://www.medienkunstnetz.de/works/field-work/