Anda di halaman 1dari 43

Aalborg University Copenhagen Medialogy MED4 2007

Sensors Technology

Installation of Arduino board, and software utilization examples

Smilen Dimitrov

Sensors Technology – Software utilization of a sensor signal

1

Contents

1 Introduction

3

2 Installation of Arduino software & driver

6

2.1 Arduino "how-to" guide for Windows (test program and IDE + USB driver

installation)

8

14

2.2 Programming the Arduino as data acquisition device

3 Example program Flash

3.1 Files needed

3.2 Programming procedure - example

4 Example program Max/MSP

5 Arduino BT (Bluetooth) specifics

5.1 Powering the Arduino BT

5.2 Arduino and Bluetooth drivers - Microsoft vs. Widcomm on Windows XP

5.3 Arduino IDE - data acquisition software

5.4 Example program Flash

5.5 Example program Max/MSP

Sensors Technology – Software utilization of a sensor signal

18

18

23

25

31

32

35

40

41

42

2

1 Introduction

This document is continuation of the Sensors Technology study sheet "Software utilization of a sensor signal". It is a practical introduction to a the data acquisition board that can be used in this course, the Arduino board.

There are several Arduino boards. In this document, we will discuss two of them. Seen as data acquisition hardware, these boards that can be characterized with:

- 6 analog inputs

- analog input voltage range supperted: 0V - 5V

- sampling rate of max 15 KHz (sampling period min 66,7 µs)

- sampling resolution of max 10 bits (max 1024 quantization levels).

as well as a driver and IDE and API that interfaces well with (among others) Adobe (Macromedia) Flash, or Cycling '74 Max/MSP software development environments. (Note - the above information is taken from the Atmel microcontrollers' [which form the base of the Arduino] datasheet - sampling rate may be lower when all processes are taken into account).

The overview of different Arduino boards is given on the Arduino website:

Here we are going to talk about the Arduino board known as "NG" (new generation), as well as the Bluetooth Arduino (known as Arduino BT) board.

well as the Bluetooth Arduino (known as Arduino BT) board. Figure 1. Left: the Arduino NG
well as the Bluetooth Arduino (known as Arduino BT) board. Figure 1. Left: the Arduino NG

Figure 1. Left: the Arduino NG board (Ref. [1]); right: the Arduino BT board

Sensors Technology – Software utilization of a sensor signal

3

As a preliminary note, the Arduino NG connects to a PC via USB; the USB connection is also the main power supply source for the Arduino NG, and part of this power is made avalable as +5 V supply pins, which we can use to power some circuitry - just like the the Teleo board from Making Things.

On the other hand, Arduino BT connects to a PC via wireless Bluetooth connection. As such, it needs its own power supply - and it is here where one needs to be especially careful:

"

The use of a DC-DC convertor, allowing the board to be powered with a minimum of 1.2 V, but with a maximum of 5.5 V. Higher voltages or reversed polarity in the power supply will kill the board. […]

Only use serial communication at 115200 baud; this is the speed that the module has been configured to use. [2]"

"The Arduino BT is more fragile and easy to break than a regular Arduino board.

Don't power the board with more than 5.5 volts to the or reverse the polarity (power and ground pins) of your power supply, or you might kill the ATmega168 on the Arduino BT. The Arduino BT can, however, run with a minimum of 1.2 volts, making it easier to power with batteries.

You can't remove the ATmega168, so if you kill it, you need a new Arduino BT.

[3]"

In order to start using Arduino boards, we have to first download and install the corresponding Arduino software. One difference from a board like the Teleo, is that we have to program the Arduino board first, so it specifically behaves as a multi channel analog-to-digital convertor (that is, data acquisition hardware) - a board like Teleo had that functionality pre-programmed.

The Arduino IDE software available for download allows for programming of the boards - and at the same time, allows subsequent connectivity with them.

Sensors Technology – Software utilization of a sensor signal

4

Finally, let us mention that Arduino as a platform is open source - there are complete schematics and instructions on how Arduino boards can be assembled manually; in addition all the corresponding software is provided as open source too. Arduino boards can be ordered manufactured as well, with prices far more popular than more expencive boards like the Teleo or Basic Stamp.

This being said, take note that the package one obtains when buying is *only* the boards themselves - the Arduino NG for instance, would need a USB cable as well - but the user needs to obtain it separately.

Additionally, in relation to hardware, take note that the inputs on the Arduino (unlike platforms like the Teleo) provide random values when they are left floating (meaning that nothing is connected to them); to force a reading of zero, one needs to specifically connect them to ground (inputs in boards like Teleo will provide a zero reading even if left floating).

Also, take note that the Arduino inputs are implemented as so-called "crimp socket shells", which are sockets that fit approximately to the dimensions of a jumper pin; as such, they are mostly suited to either jumper cable, or a flat ribbon cable with an appropriate crimp type pin connector - one can fit wire or component terminal pin inside directly, but there is no additional mechanical support so it is unsafe (the Teleo for instance had screw clamp type of print connectors, which means regular wire can be easily fastened just by using a small screwdriver, without the need to solder special connectors).

Finally, a very nice introduction to the concept of Arduino, as well as several simple projects, can be found in the Arduino Booklet [7] here:

Sensors Technology – Software utilization of a sensor signal

5

2 Installation of Arduino software & driver

As mentioned previously, the Arduino platform is open source, so all the documentation and downloads available on the Internet.

Primarily, we need to download the Arduino development environment, in order to program the Arduino. The development environments are given four digit numbers as versions (current version at the time of writing is Arduino 0007 - note the Windows download is around 46 MB), and there are versions for Windows, Linux and Mac OS.

The Arduino IDE software can be downloaded from this page.

Take note that Arduino IDE software is built on Processing ( http://processing.org/ ), which is itself built on Java. So, make sure you have the latest Java installed on the target machine. Also note that the download package contains both the IDE software and the needed USB drivers.

Afterwards, information on usage of the board with Max/MSP or Flash can be obtained from the Tutorials part of the Arduino website, under the "Interfacing with Other Software" section.

However, take note that in the Arduino tutorials "you will find a growing number of examples and tutorials for accomplishing specific tasks or interfacing to other hardware and software with Arduino. For instructions on getting the board and environment up and running, see the Arduino guide. [4]"

The Arduino guide can be found here:

And for instructions for setting up the IDE and the board, we need to turn to the "how- to"s listed there; in particular, the how-to for Windows is located here:

and it contains an in-depth guide on how to install the USB drivers, and run and test the IDE.

Sensors Technology – Software utilization of a sensor signal

6

Afterwards, information on usage of the board with Max/MSP or Flash can be obtained from the Tutorials section of the Arduino website, under the "Interfacing with Other Software" section:

The Arduino tutorial for Max/MSP is situated here:

The Arduino tutorial for Adobe (Macromedia) Flash is situated here:

Both tutorials discuss several methods.

However, as mentioned before, first we need to program the Arduino to behave as a data acquisition board - which we can do through the Arduino IDE. So, in the following part of the section, first few considerations in running the guide for Windows will be noted, and then we proceed on introducing a data acquisition program, taken from one of the Max/MSP Arduino tutorials.

This program, slightly modified, will enable us to use the Arduino as data acquisition board with both Flash and Max/MSP without the need to reprogram it (so in that sense, it will behave like a Teleo). Then we proceed on introducing the methods to interface with the Arduino thus programmed, from Max/MSP and Flash - both of which are again taken from Arduino tutorial projects, but slightly modified.

All of this discussion will be based around the Arduino NG. Afterwards, the document will outline the specific issues of using the Arduino BT to perform the same task using the same software.

Sensors Technology – Software utilization of a sensor signal

7

2.1 Arduino "how-to" guide for Windows (test program and IDE + USB driver installation)

As previously meantioned, the how-to for Windows is located here:

and it contains an in-depth guide on how to install the USB drivers, and run and test the IDE.

Here we can just repeat the steps given on the webpage:

" How To Get Arduino Running on Windows

These are the steps you need to follow in order to be up and running:

1. Get an Arduino board and cable

2. Download the Arduino environment

3. Install the USB drivers

4. Connect the board

5. Run the Arduino environment

6. Upload a program

7. Look for the blinking LED

8. Learn to use Arduino [5]"

The guide is very detailed on installation of USB drivers and the IDE, so please follow the guide for these steps.

NOTE: One possible problem you could get with installation on Windows XP (and earlier), might be trouble with serial port enumeration in Windows - after a succesful installation of USB drivers, if the USB serial port is assigned COM10 or larger by the system, both Max/MSP and Flash may fail to interface with the Arduino board. An easy solution is of course to uninstall the drivers, and try reinstalling them in hope that they get assigned a serial port number lower or equal to 9. However, if that is not possible (as this procedure may require uninstallation of other USB serial port software), few pointers are given in the respective sections on how to overcome this problem further on. However, note this problem should not prevent communication of the Arduino IDE with the board while programming the board.

Sensors Technology – Software utilization of a sensor signal

8

Upon connection to the USB port, if the Arduino NG is configured to use USB as a power supply, the green power supply diode is turned on:

USB connector Power selection jumper External power supply connector
USB
connector
Power selection
jumper
External power
supply connector

Figure 2. Image of the Teleo, showing the gree power supply turned on, powered by USB (USB connector, power selection jumper and external power supply connector)

Keep in mind that you can choose to power the Arduino with an external power supply (which is not needed for some basic sensor applications). The decision on which power supply to use is made through the power selection jumper (see Figure 2), which by default is set to use USB as a power supply.

The installation of the IDE should also be without problems (as on Windows there is no installation) - just expand the files in the downloadable zip archive, provided on:

in a directory of your choice - and the program can be directly ran from arduino.exe. You can also use run.bat - it also checks for any missing components and reports errors.

Figure 3. Contents of the Arduino IDE package for Windows

Figure 3. Contents of the Ar duino IDE package for Windows Sensors Technology – Software utilization

Sensors Technology – Software utilization of a sensor signal

9

Again remember that the IDE is built on Java - although it seems that all necesarry files are included in the donwloadable package, in case of problems, you may want to check using run.bat and see if you get some error messages - it is possible that (re)installation of Java may be necesarry.

The Arduino guide, upon succsesful installation of driver and IDE, continues to discuss the led blink example Arduino program (note that program code under the Arduino / Processing IDE are known as "sketches", which are saved as text files with an extenstion .pde). This program is provided with the Arduino IDE example files:

This program is provided with the Arduino IDE example files: Figure 4.Loading the example led blink

Figure 4.Loading the example led blink program in the Arduino IDE

If the drivers and the IDE is properly installed, and you follow the instructions in the guide on how to get this program running, you shouldn't have any problems in doing so. Note that in the IDE, the process of 'compiling' a program (and checking for compile- time errors) is provided as "Verify":

for compile- time errors) is provided as "Verify": Figure 5. Verify (left) and Upload to I/O
for compile- time errors) is provided as "Verify": Figure 5. Verify (left) and Upload to I/O

Figure 5. Verify (left) and Upload to I/O Board (right) commands in the Arduino IDE

Succesful verification (compilation without errors) is reported like this:

(compilation with out errors) is reported like this: Sensors Technology – Software utilization of a sensor

Sensors Technology – Software utilization of a sensor signal

Figure 6. Succesful compilation report in Arduino IDE

10

Note that the size of the executable code is given as well - as there is quite a limited ammount of memory available for storing programs on the Arduino itself (more precisely, on its Atmel chips) - as we can see, for the Arduino NG there is a size limit of less than 14 KB.

Once we have verified that the program compiles without errors, we can then upload it

to the Arduino board (the process of uploading a program to a microcontroller is also

commonly known as 'burning'). Note that if we have forgotten to press the reset button

as instructed in the guide, before uploading the program, the IDE will fail the operation:

uploading the program, the IDE will fail the operation: Figure 7. IDE error message in ca

Figure 7. IDE error message in case the reset button on the Arduino is not pressed before programming.

If this happens, simply press the reset button and then repeat the upload (see the guide for more).

Please note that during a proper upload operation, you should notice the TX and RX yellow diodes flashing on the Arduino:

Figure 8. TX and RX yellow Arduino diodes flashing, while communication occurs through the USB port

flashing, while communication occurs through the USB port If the operation is succesful, then you should

If the operation is succesful, then you should receive:

port If the operation is succesful, then you should receive: Figure 9. Arduino IDE message up

Figure 9. Arduino IDE message upon succeful 'burning' operation.

A this point, just note that as soon as you have succesfully uploaded code to the

microcontroller, it starts running on the Arduino.

Sensors Technology – Software utilization of a sensor signal

11

As we expect that the Arduino program will start running as soon as it is succesfully uploaded, it is at this point where the following entry in the guide:

"7 | Look for the blinking LED

A few seconds after the upload finishes, you should see the amber (yellow) LED on the

board start to blink. If it does, congratulations! You've gotten Arduino up-and-running.

[5]"

may be a little confusing in regards to the Arduino NG. Namely, no yellow diodes will blink!

Actually, the program assumes that we would have connected a diode ourselves on pin 13 (this is discussed in [8]) - in that case, we should see the diode periodically turn on and off every 2 sec:

see the diode periodically turn on and off every 2 sec: Figure 10. Blinking diode attached

Figure 10. Blinking diode attached to pin 13, in response to LED blink program

Pin 13 is special, as it allows that a LED diode is attached directly: " Willing to provide newcomers with some help while debugging programs, we propose the use of one of the board's pins plugging a LED that we will make blink indicating the right functionallity of the program.

We have added a 1K resistor to pin 13, what allows the immediate connection of a LED between that pin and ground. [8]"

However, be careful that the other pins do not have this feature - so if connecting LED's

to them, make sure you use an additional resistor in series as well.

Sensors Technology – Software utilization of a sensor signal

12

One should always be careful about the polarity of the LED too: "LEDs have polarity,

One should always be careful about the polarity of the LED too: "LEDs have polarity, which means they will only light up if you orient the legs properly. The long leg is typically positive, and should connect to pin 13. The short leg connects to GND; the bulb of the LED will also typically have a flat edge on this side. If the LED doesn't light up, trying reversing the legs (you won't hurt the LED if you plug it in backwards for a short period of time). [8]"

Figure 11. Connecting a LED on pin 13 (Ref. [8])

If this example program works, then we have secured a proper connection with the Arduino. Note also that for our purpose, it is enough that the Arduino reports succeful upload to the board (we do not necesarilly have to check with a LED).

Yet, our primary goal is to use Arduino as a data acquisition device, and thus we have to program it correspondingly. This program is discussed in the next section.

Sensors Technology – Software utilization of a sensor signal

13

2.2 Programming the Arduino as data acquisition device

All of the methods for interfacing Arduino with some software IDE on a PC, provided as part of the tutorials on the Arduino website, provide both a .pde program for the Arduino microcontroller itself, as well as example programs from the respective software environments, which can interface to the Arduino microcontroller code. The following conceptual digram (having the Arduino NG in mind) may help:

Arduino Microcontroller Program USB code values
Arduino
Microcontroller
Program
USB
code
values
PC Software IDE (Max/MSP, Flash) Program USB code USB - serial port values driver
PC
Software IDE
(Max/MSP,
Flash)
Program
USB
code
USB - serial port
values
driver
Program USB code USB - serial port values driver Figure 12.A simplified block diagram of data

Figure 12.A simplified block diagram of data transfer from Arduino to a PC software IDE

In general, each interfacing solution uses its own microcontroller program and communication protocol, and its own corresponding way to read the data in the chosen PC Software IDE. However, here we will use a single microcontroller code for reading and sending the digitized values, for both Max/MSP and Flash. Actually, for the microcontroller code and Max part of the solution, we use the Arduino2Max solution - available for download on the Arduino Max/MSP tutorial page here:

Download the latest version (at time of writing, Arduino2Max, Version .20 Feb 10th,

2007

)

Once you've downloaded the zip, expand it and look for a folder Arduino2Max_FEB_2007/Arduino2Max_Arduinocode. This folder contains the source code file Arduino2Max_Arduinocode2.pde, which implements a data acquisition hardware functionality - it simply waits for a command from the host PC, and thens reads all analog and digital inputs, and sends the values via USB. By continually sending commands to the Arduino, we obtain continual reading of the Arduino inputs.

Sensors Technology – Software utilization of a sensor signal

14

So, we simply need to load the file Arduino2Max_Arduinocode2.pde in the Arduino IDE, verify it and upload it to the board. However, in order to make it a single solution that will work with both Max/MSP and Flash, we need to make a single change: we simply need to add the line

printByte(0);

right after line 41 [ Serial.println(); ].

This is needed because Flash classes used for network communication always expect a null character to terminate communication (otherwise they keep on waiting for connection to terminate): "Flashes XML Socket (don't ask me why they call it an XML socket you don't have to send XML) wants you to put a 0 character at the end of all your bytes to mark the end of transmission. This means that you cannot send a byte worth zero, only bytes 1-255 [9]"

The complete code Arduino2Max code, along with the added line, is provided below:

/*

*

Arduino2Max

*

Send pin values from Arduino to MAX/MSP

 

*

*

Arduino2Max.pde

 

*

------------

*

Latest update: February 10 2007

 

*

------------

 

*

Copyleft: use as you like

 

*

by djmatic

*

Based

on

a

sketch

and

patch

by

Thomas

Ouellet

Fredericks

tof.danslchamp.org

*

*/

int x = 0;

// a place to hold pin values

void setup()

{ Serial.begin(115200); Bluetooth speed

}

void loop()

{

if (Serial.available() != -1){

if (Serial.read() == 'r') {

pins

for (int pin= 0; pin<=5; pin++){ x = analogRead(pin); sendValue (x);

Sensors Technology – Software utilization of a sensor signal

// 115200 is the default Arduino

// Check serial buffer for characters

// If an 'r' is received then read the

// Read and send analog pins 0-5

15

}

for (int pin= 2; pin<=13; pin++){ x = digitalRead(pin); sendValue (x);

}

Serial.println(); of pin data. printByte(0); // ***added line ***

// Read and send digital pins 2-13

// Send a carriage returnt to mark end

delay (5); crashing/overloading of the serial port

}

}

}

void sendValue (int x){ followed by a "space". Serial.print(x); Serial.print(32, BYTE);

}

// add a delay to prevent

// function to send the pin value

So, once this code is loaded in the Arduino IDE, then we can first compile it (Verify), then (after pressing the reset button on the board) upload it to the microcontroller. Once it is succesfully uploaded (the transfer can be controlled through the yellow TX and RX diodes) it automatically starts running on the Arduino.

There are severall ways to test whether the program is running fine now. Take note that the serial communication speed is fixed at 115200 bps in the Arduino code, and remember that the program waits for a command - actually, it is the character 'r'; upon reception of this command, all the analog inputs are read and sent via USB.

So, one way to test will be to try this functionality out through the Arduino IDE - once the program is uploaded, just click on the Serial Monitor button:

is uploaded, just click on the Serial Monitor button: Figure 13. Location of Ar duino Serial

Figure 13. Location of Arduino Serial Monitor key

and once it is actived, make sure you have 115200 baud as communication speed, and then enter 'r' in the send field, and send - you should receive a packet, as shown below:

and send - you should receive a packet, as shown below: Figure 14. Packet reported with

Figure 14. Packet reported with analog and digital input values, after reception of 'r' command

Sensors Technology – Software utilization of a sensor signal

16

Another way to test in Windows is through HyperTerminal - simply open a serial connection to the COM port allocated to the Arduino, set the communication speed to 115200 baud (8 data bits, 1 stop bit, parity none, no flow control), and once a connection is established, type 'r' - again, you should receive a packet back.

The first six values in the packet are the analog input values - and as mentioned, the analog inputs are not internally shunted to ground, so when left floating, random values in the range of 0-1023 are read (this is also one way to make sure all is fine).

Take note that a packet is on average around 50 bytes (*8 bits = 400 bits) in size, and being transferred at 115200 bits per second; the time it takes to transfer the packet on the wire is 3.472 ms (at least), which then means that for all practical applications we are concerned with, the sampling speed with this solution is limited to about 288 Hz (regardless of the fact that the microcontroller is electrically able to perform these much quicker).

Having made sure that our data acquisition software is running on the Arduino board, we can now proceed to discuss how to interface from Max/MSP and Flash. As we read random values from the inputs, we do not necesarilly have to prepare the Arduino board to connect any kind of sensor, in order to make sure we receive the values in Max/MSP or Flash - we simply have to make sure that we receive random values in the expected range for the analog input readings. Additionally, one can use simple wire to connect an analog input to either the+5V or the ground pin on the Arduino, and check if the value correspondingly hops to 1023 or 0.

Sensors Technology – Software utilization of a sensor signal

17

3 Example program Flash

3.1 Files needed

When working with Flash, we are going to work based on a Flash class file for Arduino, which is listed in the Arduino website here:

The particular script we are going to use is listed as "Arduino > Flash tools from beltran berrocal". These tools are located on this page:

and we will work with the Arduino.as actionscript class, provided on the page for download as a base. The Berrocal page also provides its own Arduino code as well, but as we specified previously the adc conversion program stored in the Arduino.

Thus, the Berrocal Arduino.as class needs to be modified to interface with our chosen Arduino program - the modified code listing is provided below:

/*

*

ARDUINO CLASS - version 1.0 - 30-12-2005 *** modified ***

*

this Actionscript class makes it easier to connect Flash to the Arduino Board

(www.arduino.cc)

*

# copyleft beltran berrocal, 2005 - b@progetto25zero1.com - www.progetto25zero1.com

*

# updates and examples: www.progetto25zero1.com/b/tools/Arduino

*

*

*-----------------------------------------------------------------------------

*

LICENCE

*

Copyright (C) 2005 beltran berrocal | b@progetto25zero1.com |

*

*

This library is free software; you can redistribute it and/or modify it

*

under the terms of the GNU Lesser General Public License

*

as published by the Free Software Foundation; either version 2.1 of the License

*

* You should have received a copy of the GNU Lesser General Public License along with this library;

*

Alternatively you can find it here http://www.gnu.org/licenses/lgpl.html

*

*

Brief Explanation of the Licence:

*

- you can you use, redistribute, modify this software for free,

*

- you can put it into commercial projects

* - but if you modify/enhance this Library you should release it under the same licence or alternatively under the GPL licence

*

- in all cases you should also credit the original author and all contributors

*

*

*-----------------------------------------------------------------------------

*/

Sensors Technology – Software utilization of a sensor signal

18

import mx.events.EventDispatcher;

class Arduino extends XMLSocket {

private var _connected

connected?

:Boolean = false;

//

is

public function get connected():Boolean { return this connected;} public function set connected(inx:Boolean):Void { this connected

= inx;}

private var _host or IP address private var _port

the config file of the socket server for this one

:String

= "127.0.0.1"; // Host name

//read

:Number = 5331

this

ain0;

// *** mod: added members private var _ain0:Number; public function get ain0():Number { if (_connected) return else return -1;}

this

ain1;

private var _ain1:Number; public function get ain1():Number { if (_connected) return else return -1;}

this

ain2;

private var _ain2:Number; public function get ain2():Number { if (_connected) return else return -1;}

this

ain3;

private var _ain3:Number; public function get ain3():Number { if (_connected) return else return -1;}

this

ain4;

private var _ain4:Number; public function get ain4():Number { if (_connected) return else return -1;}

this

ain5;

private var _ain5:Number; public function get ain5():Number { if (_connected) return else return -1;}

 

private var _isAsking:Boolean = false;

public function get isAsking():Boolean { return this isAsking;}

 

public function set isAsking(inx:Boolean):Void { this

isAsking

=

inx;}

//EVENT DISPATCH MIXIN function addEventListener(){} function removeEventListener(){} function dispatchEvent(){} function dispatchQueue(){}

//constructor - provide a port number and a host ip adress //read the documentation of the SerialProxy to better understandwhat this means

function Arduino(port, host) { //initialize super();

Sensors Technology – Software utilization of a sensor signal

19

mx.events.EventDispatcher.initialize(this); //trace("** Arduino ** initilizing constructor");

//check if the selected port is correct or set default if(port == undefined) {

trace("**

initialized! to change it use new Arduino(onPortNumber)")

Arduino

**

default

port:"+_port+"

read

understand")

the Flash

} else if ((_port < 1024) || (_port > 65535)) { trace("** Arduino ** Port must be from 1024 to 65535 ! Documentation and the serProxy config file to better

}

}

else { _port = port;

//check for host or set default if(host != undefined) { _host = host;

}

//register and override responder functions this.onConnect = onConnectToSocket;

this.onClose

this.onData

= onDisconnectSocket; = onDataReceived;

//autoconnect

connect();

}

//---------------------------------------

CONNECT and DISCONNECT + responders

//---------------------------------------

//

//connect to the XMLsocket public function connect () { trace("** Arduino ** Connecting to "+_host+":"+_port+"

.");

super.connect(_host,_port);

}

//disconnects from the xmlsocket (not Arduino itself) public function disconnect () {

if (_connected)

{

trace("** Arduino ** disconnecting");

this.close() _connected = false;

}

}

//XMLsocket responders private function onConnectToSocket (success) { trace("** Arduino ** onConnectToSocket"); if (success) { _connected = true; //launch event trace ("** Arduino ** Connection established."); //start running this.startRefresh(); e_connectToSocket();

} else {

Sensors Technology – Software utilization of a sensor signal

20

trace launch the serialProxy first");

("** Arduino ** Connection failed! you must

e_connectToSocketError();

}

}

//XMLsocket responders private function onDisconnectSocket (success) { _connected = false; //trace ("** Arduino ** onDisconnectSocket ** Connection closed by remote host."); //launch event e_disconnectSocket()

}

public function startRefresh () {

this.send("r");

}

//---------------------------------------

//

//---------------------------------------

SEND and receive data from server

//sends data to arduino

public function send(dataStr:String) { //trace("** Arduino ** send:" + dataStr + _connected)

\""+dataStr+"\"");

}

if ( (_connected)

)

{

if (dataStr.length) {

//trace("**

Arduino

super.send(dataStr);

}

}

**

Sending

//overrides XMLSocket.onData in order to have pure string and not the full XML object private function onDataReceived (str:String) { //trace("** Arduino ** onDataReceived str:"+str+str.length); //launch event // *** mod: parse received input data first if (str.length > 1)

{

var my_array:Array = str.split(" "); if (my_array.length >= 6)

{

for (var i = 0; i<=5; i++)

{

//refresj property values this["_ain"+i] = Number(my_array[i]);

}

}

}

// done parsing, initiate reading again this.send("r"); // dispatch event

Sensors Technology – Software utilization of a sensor signal

21

e_onReceiveData(str);

}

//---------------------------------------

//

//---------------------------------------

EVENTS

private function e_connectToSocket(){ var evt = {target:this, type:"onConnect"}; dispatchEvent(evt);

}

private function e_connectToSocketError(){ var evt = {target:this, type:"onConnectError"}; dispatchEvent(evt);

}

private function e_disconnectSocket(){ var evt = {target:this, type:"onDisconnect"}; dispatchEvent(evt);

}

private function e_onReceiveData (str:String){ var evt = {target:this, type:"onReceiveData"}; evt.data = str;

dispatchEvent(evt);

}

}

So, provided the above code is avalable as Arduino.as, we also need a socket server for interfacing with this class. We can use the one provided with on the Arduino IDE download page, listed as Serial Proxy and located here:

The zip file for Serial Proxy has only two files, called serproxy - an executable, and an initialization file. The initialization file should be modified, so the Arduino serial port number matches the one on the computer. For instance, if the Arduino has COM port 10, then the corresponding file contents would look like this:

# Config file for serproxy

# See serproxy's README file for documentation

# Transform newlines coming from the serial port into nils

# true (e.g. if using Flash) or false newlines_to_nils=true

# Comm ports used - comma separated for more than one: 10,1,2 etc

comm_ports=10

# Default settings

comm_baud=115200

comm_databits=8

Sensors Technology – Software utilization of a sensor signal

22

comm_stopbits=1

comm_parity=none

# Idle time out in seconds

timeout=300

# Port 10 settings (ttyS0)

net_port10=5331

Note: If it so happens that you indeed use have port 10 or more used for Arduino, remember the COM port number issue for Windows described previously. In that case you would need to modify the source code for the serproxy.exe and recompile (as the version provided at the Arduino website, at the time of writing of the document, provides a serproxy.exe version that does not handle com port numbers greater than 9) - consider the topic [10] discussing this issue on the Arduino Internet forum.

3.2 Programming procedure - example

So, given all the files involved - make a new folder for the Flash file somewhere (say FlashArduino). Create a new Flash file (say FlashArduino.fla), and make it #include an external actionscript file in the first frame, which will also be saved in the same folder (say FlashArduino.as). Finally, place the Arduino.as class file in there as well. Although it is not necessary, you may want to copy the serproxy socket server (both the exe and the cfg file) there as well, for easier start up. The situation would look like this:

for easier start up. The situation would look like this: The example file provided relies on

The example file provided relies on a red square defined as a movie clip in the Flash IDE, called TheRedSquare:

Sensors Technology – Software utilization of a sensor signal

a movie clip in the Flash IDE, called TheRedSquare: Sensors Technology – Software utilization of a

23

We start coding for Flash by instantiating a new object of the Arduino class (given above):

var ArdObj:Arduino = new Arduino();

By creating a new object, it also starts connecting to the serproxy automatically (follow the Flash debug window for messages concerning connection status). Once it is connected, it automatically polls for values input values, and makes them available as its

own properties, like ArdObj.ain0, ArdObj.ain1 … ArdObj.ain5.

Unlike the Teleo, sampling rate and resolution can not be specified from Flash - as here we are bound to the microcontroller code which does not support such functionality.

We do any initialization necessary the standard way in Flash – in the _root.onLoad function. Our ‘endless’ loop is in the _root.onEnterFrame Flash function – which repeats each time before a frame is rendered – at the Flash movie defined frame rate. Then, in Flash, the sensor utilization is easy – in our ‘endless’ loop, we simply read the sensor value through reading of the corresponding property of the Arduino object variable and storing the result in a numeric variable (here NumberFromAnalogInput_Zero) – we expect numeric integer values, determined by the sampling resolution (i.e. 10 bits resolution – integer values from 0 to 1023). Then, we simply apply it to a graphic property of TheRedSquare movie clip object – here for

x property, which defines the x position – and thereby each

instance, we map it to the

frame the square is rendered at a new position – so we experience displacement animation according to the sensor signal. The code of this ‘endless’ loop is simply made

of two commands:

_root.onEnterFrame = function ()

{

 

//read sensor value var NumberFromAnalogInput_Zero = ArdObj.ain0;

//aply sensor value trace(NumberFromAnalogInput_Zero);

_root.TheRedSquare

x

= TheRedSquare_SavedX +

0.1*NumberFromAnalogInput_Zero;

}

Again, the serproxy socket server must run together with the Flash file, to make the sensor values available.

When the Flash program is running properly, one should notice the yellow TX and RX diodes on the Arduino blink as on Figure 8, as data is exchaged through the USB port - correspondingly, one should receive random values in the application, with no sensors connected.

Sensors Technology – Software utilization of a sensor signal

24

4 Example program Max/MSP

As mentioned previously, the Arduino microcontroller code is taken from the Arduino2Max resource, so it is natively meant to interface with Max/MSP. As such, Max/MSP patch files are provided in the Arduino2Max zip distribution:

However, as we made a slight change in the microcontroller code to facilitate the communication with Flash, we would need to make the correspondingly small change in the Arduino2Max interface patch as well. Other than that, the reading of values should proceed using the Max patch only, without the need to run a socket server at the same time, as in the Flash case - as Max/MSP has its own direct access to serial ports through the object serial, all issued regarding reading of Arduino values can be adressed directly in Max/MSP.

Note: If it so happens that you indeed use have port 10 or more used for Arduino, remember the COM port number issue for Windows described previously. In that case you would need to make sure the latest version of the serial object for Max/MSP is downloaded from here:

and it replaces the old one Max/MSP had previously. Consider this forum entry: "The serial object that came with Max 4.5.7 exhibits some problems when specifying COM ports, and definitely had problems with COM ports > 9. You might try the version of the object on the Incremental Donwloads page:

http://cycling74.com/twiki/bin/view/IncrementalDownloads

and see if you have better luck connecting. [6]"

Sensors Technology – Software utilization of a sensor signal

25

Assuming installation of drivers is completed, we can now proceed and open the Arduino2Max_MaxPatch file from the Arduiono2Max2.zip in Max/MSP (in Windows XP, one may have to rename the file and add the extension .mxb to the patch file before doing so, as this is a Macontosh archive). Here we find our chief interface with the Arduino device – which looks like this:

with the Arduino device – which looks like this: Figure 15. Screenshot of the Ar duino2Max

Figure 15. Screenshot of the Arduino2Max patch front interface

Again, as we are bound to the microcontroller program, we cannot change neither sampling rate nor resolution through it. All that there is to the usage of this patch is provided as help in the comments.

The latest sample values are provided as an integer number and that value is refreshed according to the polling repetition rate (which is set in the arduinoSerialreader subpatcher:

Sensors Technology – Software utilization of a sensor signal

26

Figure 16. Screenshot of the arduinoSerialreader subpatcher So, from here we can set differe nt

Figure 16. Screenshot of the arduinoSerialreader subpatcher

So, from here we can set different sample rates - however this setting is the same for all channels, and the sample rates must be greater than the 3 ms minimum calculated previously.

And it is here, where we need to modify the patch and adapt it to the changes in the microcontroller code. The only changes that needs to be done is in the convertback subpatcher, visible in arduinoSerialreader subpatcher, as shown. The only change is adding 0 as argument to the sel box, and reconnecting the first and third input of the new four outputs on the sel box as input to the zl object.

Figure

convertback subpatcher

17.

Original

(left)

and

modified

(right)

Sensors Technology – Software utilization of a sensor signal

subpatcher 17. Original (left) and modified (right) Sensors Technology – Software utilization of a sensor signal
subpatcher 17. Original (left) and modified (right) Sensors Technology – Software utilization of a sensor signal

27

Once we have made these changes, we can check and see whether we receive some values - by clicking on the start button on the front patch interface. We should receive some random values for the analog input readings, in the expected range.

Figure 18. Screenshot of the Max patch receiving values from Arduino

Screenshot of the Max patch receiving values from Arduino Again, note that when the Flash program

Again, note that when the Flash program is running properly, one should notice the yellow TX and RX diodes on the Arduino blink as on Figure 8, as data is exchaged through the USB port

Once we have the sensor variable available, we can apply it – here for instance, as a scaling parameter of a red square:

Sensors Technology – Software utilization of a sensor signal

28

In this program, simply speaking we define a center point of (x, y) = (100,

In this program, simply speaking we define a center point of (x, y) = (100, 100) and we use the sensor parameter, as a floating number from 0 to 1. Using this parameter, we calculate left, top, right and bottom coordinates of the square, and we display it in the graphic anim window.

Here there is no direct ‘endless’ loop but it is implied, since the graphics program is started each time the sensor values is refreshed – according to the example above it happens each 100 ms, or with 10 Hz refresh rate.

Sensors Technology – Software utilization of a sensor signal

29

In Max, it is also easy to apply a sensor value to sound:

In Max, it is also easy to apply a sensor value to sound: Here for instance,

Here for instance, we simply use the sensor value to multiply an MSP audio signal – as it is from 0 to 1, it acts as a volume regulator. Here we realize that rect~ as other MSP signals, imply an internal loop that runs at 44.1 KHz. If the sensor refresh rate is as previously 100 ms, as a slower one, it will win as previously discussed – at such a slow refresh rate, clicks and / or delays when the sound is processed may be noticed.

Sensors Technology – Software utilization of a sensor signal

30

5 Arduino BT (Bluetooth) specifics

We now proceed with discussing the Arduino BT. We wil be able to use the very same data acquisition microcontroller program, given in section 2.2, and the corresponding Max/MSP and Flash programs on the PC, with only minimal changes - actually, the only change is regarding the serial port being used for communication with the board; so far, we worked with the USB example, having the hypothetical port number 10 (COM10 - so we could illustrate the enumeration problem in Windows) - and in the bluetooth version, we will install a Bluetooth serial port, which will also have a port number, for instance 6 (COM6). So, for the Max/MSP or Flash side of the connection, all we have to change is the corresponding port number.

On Windows (XP and earlier) there may be issues related to the type of Bluetooth driver (Microsoft or Widcomm/Broadcom) installed on the system, which are adressed briefly in this document as well.

To begin with, let us list the Arduino website resources dealing with the Arduino BT (at the time of writing of this document):

http://www.arduino.cc/en/Main/ArduinoBoardBluetooth (Arduino BT hardware page - "Arduino - ArduinoBoardBluetooth.")

http://www.arduino.cc/en/Guide/ArduinoBT (Arduino BT guide - “Arduino - ArduinoBT.”)

Note also that the following page, linked from tutorials section of the Arduino site, may cause some confusion: http://www.arduino.cc/playground/Learning/Tutorial01, as it talks about using a wired Arduino (like the Arduino NG) with an additional Bluetooth module - but is not related to the Arduino BT.

There are also instructions on the Arduino website for setup of Arduino BT on an XP PC, with the Microsoft Bluetooth drivers:

Setup Arduino BT on an XP PC with Bluetooth Adapter, "Arduino playground : Bt PC

Setup")

(Arduino

playground

-

(note: this page seems to be linked improperly from other sections of the Arduino site)

Arduino BT is also sometimes discussed on the Arduino users forum.

Sensors Technology – Software utilization of a sensor signal

31

5.1 Powering the Arduino BT

As mentioned previously, one has to be careful when powering the Arduino - let's include the relevant quotes again:

"

The use of a DC-DC convertor, allowing the board to be powered with a minimum of 1.2 V, but with a maximum of 5.5 V. Higher voltages or reversed polarity in the power supply will kill the board. […]

Only use serial communication at 115200 baud; this is the speed that the module has been configured to use. [2]"

"The Arduino BT is more fragile and easy to break than a regular Arduino board.

Don't power the board with more than 5.5 volts to the or reverse the polarity (power and ground pins) of your power supply, or you might kill the ATmega168 on the Arduino BT. The Arduino BT can, however, run with a minimum of 1.2 volts, making it easier to power with batteries.

You can't remove the ATmega168, so if you kill it, you need a new Arduino BT.

[3]"

Because of these warnings, here is a small practical illustration on how to connect an adapter to the Arduino BT. Although the Arduin BT can be powered with batteries, for development it might be preferable to work with an adapter. We can work with regular switchable adapters:

an adapter. We can work with regular switchable adapters: Sensors Technology – Software utilization of a

Sensors Technology – Software utilization of a sensor signal

Note that the adapter in the figure is set to 3V, as a precaution, although 4.5V should be safe as well - 6V however, is not.

The polarity switch should be set accordingly to our wiring - see further on.

Figure 19. A switchable adapter power supply

32

An adapter like this usually comes with pre-set connectors - we can make an interface through using the 9V battery connector of the adapter. Such connector have wires colored according to polarity (red for plus, black for minus). Then we should turn the adapter on, and measure our output wires - the voltage we measure should be positive:

Figure 20. Measuring the adapter voltage - correct polarity

20. Measuring the adapter voltage - correct polarity In case the polarity is negative, as shown
20. Measuring the adapter voltage - correct polarity In case the polarity is negative, as shown

In case the polarity is negative, as shown on the image on the left, then simply switch the polarity on the adapter, so we obtain a positive voltage reading.

Figure 21. Measuring the adapter voltage - incorrect (inverse) polarity

Sensors Technology – Software utilization of a sensor signal

33

Once we are certain that our power supply wires are correctly connected, we can connect them to the Arduino BT (keep the adapter turned off while attaching).

Arduino BT (keep th e adapter turned off while attaching). Figure 22. Adapter connected to the

Figure 22. Adapter connected to the Arduino BT (not powered)

Arduino BT has only two screw clamp type of sockets (green connector), and it is here where we attach the power supply wires - either batteries or adapter. If the adapter instuctions above are correctly implemented, black wire goes in the GND connector, and the red wire in the V+ connector, as shown on Figure 22. Then we can proceed with turning the adapter on.

If all is well, we should get a visual indication that the Arduino BT is powered, through either the 3v3 LED diode, or the BATT-LOW LED diode (both of them yellow). Note that although the minimum power supply voltage requirement for the Arduino is 1.2 V, any voltage smaller than 3.3V would cause the BATT-LOW diode to shine (as the name says, this diode is meant to be an indicator for low battery)

this diode is meant to be an indicator for low battery) Figure 23. BATT-LOW LED-diode (left)
this diode is meant to be an indicator for low battery) Figure 23. BATT-LOW LED-diode (left)

Figure 23. BATT-LOW LED-diode (left) and 3V3 LED-diode (right), depending on whether the power supply voltage is less than 3.3 V

Sensors Technology – Software utilization of a sensor signal

34

Once the Arduino is powered, the Bluetooth radio transmition should be active, and the Arduino should be visible as a Bluetooth device.

At this point, we can proceed on seeing if this is indeed the case in our operating system - here we discuss Windows XP. Unfortunately, the yellow power diodes are the only visual feedback we will get from the Arduino BT (unlike the Arduino NG, which had diodes to indicate communication occuring through the USB - both when programming the microcontroller, or communicating to it), which makes the process of troubleshooting a bit more difficult.

As mentioned previously, Windows XP may have some issues with the Bluetooth drivers, so a brief discussion follows.

5.2 Arduino and Bluetooth drivers - Microsoft vs. Widcomm on Windows XP

In general, at this point we should check whether the Arduino is visible to the OS (in this case, Windows XP) as a Bluetooth device (this is a part of the device discovery part of the Bluetooth connection process, see [15]), and whether we can make a serial connection to it. That is why we should be aware of the Bluetooth driver issue on Win XP.

" What Is a Bluetooth Stack?

A Bluetooth stack is an application installed on your computer that interacts with your Bluetooth devices. Two Bluetooth stacks are widely in use today:

* The Microsoft Bluetooth stack, which comes with Windows XP Service Pack 2

* The Widcomm Bluetooth stack

Most Bluetooth adapters use the Widcomm Bluetooth stack driver. Widcomm (acquired by Broadcom, http://www.broadcom.com) licenses its software to most Bluetooth manufacturers. Consequently, the installation, configuration, and use of different Bluetooth devices on Windows have a nearly identical look and feel.

The problem with the Bluetooth stack built into Windows XP SP 2 is that it has limited support for profiles. In particular, it does not support the Headset profile required to connect with Bluetooth headsets, and hence your Bluetooth headsets will not be able to work with your Windows XP PC.

To overcome the limitations in the Windows Bluetooth stack, you can install the Widcomm Bluetooth stack drivers from the manufacturer of your Bluetooth device. You can download the latest drivers and support software from the adapter vendor's web site. Because each vendor customizes the Widcomm software slightly, you should not

Sensors Technology – Software utilization of a sensor signal

35

use drivers from a vendor other than the one that manufactured your Bluetooth adapters. [12]"

"Bluetooth on Windows comes in two basic flavors: the Microsoft Bluetooth stack (used by Apple's Boot Camp) and the Widcomm stack (used by most external USB Blutooth dongles). The Widcomm stack has the 'My Bluetooth Places' on the Desktop. The Microsoft stack does not. … Unfortunately the Microsoft stack does not support many of the Blutooth profiles … It may be possible to install the Widcomm stack to replace the Apple/Microsoft driver/stack but I doubt it. Widcomm is VERY protective of its stack/stash. (I haven'h had much luck in the past) [11]"

One way to distinguish between the two (besides the one noted above - see also [14]), although it may be hard to see, is by looking at the taskbar - they have slightly different taskbar icons.

at the taskbar - they have slightly different taskbar icons. Figure 24. A Microsoft (left) and

Figure 24. A Microsoft (left) and Widcomm (right) Bluetooth taskbar icon

As previously mentioned, the Arduino site has a complete guide for Windows XP with Microsoft drivers:

http://www.arduino.cc/playground/Learning/BtPCSetup (Arduino playground - Setup Arduino BT on an XP PC with Bluetooth Adapter, "Arduino playground : Bt PC Setup")

When working with the Microsoft drivers, programs like the free Medieval Bluetooth Diagnostic Tool homepage [16] or BlueAuditor [13] might be useful for troubleshooting.

When working with Widcomm drivers, note that those are usually licensed by Widcom/Broadcom to hardware producers. For instance, they are provided with some HP laptops and licensed as "bluetooth by hp" as a smaller package, or with say Belkin USB Bluetooth adapter with a more complete package. Note that the "bluetooth by hp" version will not work with Arduino IDE - and therefore one must either: remove Widcomm and use the Microsoft drivers (see [17] for more); or install the latest Widcomm drivers. A problem with installing the Widcomm drivers is that they are not available for download - instead one must find installation media from Bluetooth hardware which has these drivers packaged (WIDCOMM Bluetooth Software 5.0.1.2500 can be confirmed to work with Arduino IDE).

Sensors Technology – Software utilization of a sensor signal

36

As the procedure of device setup with Microsoft drivers is described on the Arduino website, here we provide a quick overview of the procedure on Windows XP with Widcomm drivers:

- Make sure Bluetooth on the PC is turned on (the logo in the icon in the taskbar is white)

- Make sure Arduino BT is turned on

- Make sure a client Bluetooth serial port is installed - right click on the Bluetooth icon, Advanced Configuration, Client Applications tab - if no Bluetooth serial port is present, add one using the button on the form

port is present, add one using the button on the form Notice the serial port is
port is present, add one using the button on the form Notice the serial port is

Notice the serial port is COM6 - this is the port through which we will connect to the Arduino BT.

- Right-click on Quick Connect, Bluetooth Serial Port, and Find Devices…

on Quick Connect, Bluetooth Serial Port, and Find Devices… Sensors Technology – Software utilization of a

Sensors Technology – Software utilization of a sensor signal

37

- The Bluetooth Serial Port service window should be appear, and Arduino BT should be visible. If it isn't, then try refreshing.

BT should be visible. If it isn't, then try refreshing. Select the Arduino BT entry and

Select the Arduino BT entry and click Connect.

- The following screens will appear while connecting:

- The following screens will appear while connecting: Note that if this is the first time

Note that if this is the first time the device is used, and it hasn't been paired yet, the following dialog will show up during the Connecting… phase:

dialog will show up during the Connecting… phase: Sensors Technology – Software utilization of a sensor

Sensors Technology – Software utilization of a sensor signal

38

Click on the baloon and then you obtain the Bluetooth Passkey window:

the baloon and then you obtain the Bluetooth Passkey window: In this window, enter 12345 as

In this window, enter 12345 as the Bluetooth Passkey (this is default for Arduino BT, see the documentation).

- Once the Bluetooth serial port connection is made, notice that the Bluetooth icon in the taskbar turns from white to green:

Bluetooth icon in the taskbar turns from white to green: This is an indication that we

This is an indication that we have a proper serial port connection. This same connection will be used by Arduino IDE to program the Arduino BT, and the one we will use to exchange data in our programs. We notice that COM6 is allocated for this Bluetooth connection.

Sensors Technology – Software utilization of a sensor signal

39

For now, we cannot use this connection for nothing - to disconnect, just access the newly appeared ArduinoBT entry under Bluetooth Serial Port (Quick Connect), and click again to uncheck it.

al Port (Quick Connect), and click again to uncheck it. We can now proceed to Arduino

We can now proceed to Arduino IDE so we can program the microcontroller.

5.3 Arduino IDE - data acquisition software

As mentioned previously, in the Arduino IDE we enter the exact same code, as outlined in section 2.2, and perform the exact same procedure for programming as for the Arduino NG, as outlined in section 2.1 - except for one difference: here we enter the Bluetooth serial port number we found previously - COM6 - as the Serial Port to use:

we found previously - COM6 - as the Serial Port to use: You may notice that

You may notice that Arduino IDE may begin to behave slowly when clicking the Tools menu - you may notice at the same time the Bluetooth icon turns green (meaning that the reason for slowing down may be related to the enumeration of Bluetooth serial ports).

After this, the procedure for programming the microcontroller is exactly the same as for the NG - first Verify the program in the IDE, and then click the reset button on the Arduino BT, and then Upload to I/O Board in the IDE. Notice that after you click Upload to I/O Board, some of the time at start, is used in making the serial connection (the Bluetooth icon in the taskbar should turn green) . Therefore it is more likely that the burning operation could fail - that is why try to click the board reset button and hold, and then click Upload to I/O Board, and then a moment later, release the reset button.

Sensors Technology – Software utilization of a sensor signal

40

As mentioned previously, there is no indication if actual data is being transferred through bluetooth on the Arduino BT itself, so the only confirmation of a succesfully programmed microcontroller occurs as a message in the IDE (the success message in Figure 9).

Once a confirmation of succeful board programming is received, the program should start running on the Arduino BT. At this point, we should be able to connect to the Arduino BT through the Serial Monitor in the IDE, send a message and receive a packet back (the same as in Figure 13 and Figure 14). If that is succesful, then there should be no problem in using the Arduino BT in conjunction with the previously outlined Max/MSP and Flash methods.

5.4 Example program Flash

The procedure in running the example program in Flash is exactly the same as in chapter 3. The only difference is that serproxy needs to be set to operate through COM6 (The Bluetooth serial port paired with the Arduino BT) as the serial port. That means that we only would need to change the serproxy config file:

# Config file for serproxy

# See serproxy's README file for documentation

# Transform newlines coming from the serial port into nils

# true (e.g. if using Flash) or false newlines_to_nils=true

# Comm ports used - comma separated for more than one: 10,1,2 etc

comm_ports=6

# Default settings

comm_baud=115200

comm_databits=8

comm_stopbits=1

comm_parity=none

# Idle time out in seconds

timeout=300

# Port 6 settings (ttyS0)

net_port6=5331

Note that it is possible that sometimes the Flash application may end up not rceiving sensor values, even if serproxy gives a report that a client is connected to it. In that case, close the Flash application while leaving the serproxy open, and try opening the Flash application again.

Sensors Technology – Software utilization of a sensor signal

41

5.5 Example program Max/MSP

The procedure for Max/MSP is also quite straightforward - there are no changes in relation to chapter 4, except for the change of the serial port for the serial object. So, if the serial port enumeration for the serial object in Max/MSP is shown like:

port a: COM1 port d: COM4 port e: COM5 port f: COM6 port k: COM11 port l: COM12 port m: COM13 port n: COM14

Then the only thing we need to do is to instruct the serial object to use COM6, that is, port f:

inst ruct the serial object to use COM6, that is, port f: From then on, the

From then on, the patch works as already discussed. However, notice that although there are no changes in the serial port communication speed (115200 baud), there is still a noticeable lag in data refresh when using the Arduino BT, compared to the Arduino NG.

Sensors Technology – Software utilization of a sensor signal

42

Resources and references

[1].

“Arduino - Buy.” http://www.arduino.cc/en/Main/Buy

[2].

“Arduino - ArduinoBoardBluetooth.”

[3].

“Arduino - ArduinoBT.” http://www.arduino.cc/en/Guide/ArduinoBT (Arduino

BT guide)

[4].

“Arduino - Tutorials.” http://www.arduino.cc/en/Tutorial/HomePage

[5].

“Arduino - Windows.” http://www.arduino.cc/en/Guide/Windows

[6].

“Cycling '74: MaxMSP => bluetooth and serial object.”

[7].

“Arduino Booklet.”

[8].

“Arduino - BlinkingLED.” http://www.arduino.cc/en/Tutorial/BlinkingLED

[9].

Dan O'Sullivan. “Serial Server.”

[10].

“Arduino Forum - How to config serproxy at "com10".”

[11].

“bluetooth? [Archive] - OnMac.net Forums.”

[12].

Wei-Meng Lee. “WindowsDevCenter.com -- Getting Your Bluetooth Headset to

Work in XP.” July 5, 2005.

[13].

“Wireless Network Security Audit and Monitoring Tools.”

[14].

“Bluecasing: War Nibbling, Bluetooth and Petty Theft.”

[15].

“Bluetooth Real World - Bluetooth Real World, Part I: Bluetooth Connection

[16].

Davide Ciuchini. “Medieval Software.” Medieval Bluetooth Diagnostic Tool

[17].

“How to use HP laptop's built-in Bluetooth - PlanetAMD64.”

[18].

Sensors Technology – Software utilization of a sensor signal

43