Interfacing the Wiring hardware and Isadora
This tutorial introduces the basic interfacing between the Wiring hardware and Isadora http://www.troikatronix.com. The brief for the tutorial will be to read values from a photoresistor (light sensor) connected to Wiring analog input pin 0 and send them to Isadora. It assumes the Wiring software and Isadora are installed and the proper Wiring setup has been previously completed. For more Information on Wiring install check out the tutorials about Wiring installation and software setup.
Step 1
First let's prepare a small circuit for connecting the photoresistor to the Wiring board:
Step 2
Copy and paste the following code on the Wiring editor: Verify your program is free of compiling errors by pressing the Compile/Verify button in the menu bar. Press the Upload button in the menu bar. In case of syntax errors the Wiring environment will print the error messages otherwise it will print the Upload was completed successfully, the uploading process triggers activity in the Rx/Tx LEDs on the Wiring hardware. The new program will start automatically after uploading. Use the Serial Monitor button to watch the data coming from the Wiring board, then close the Serial Monitor again.
/**
* Photoresistor / Isadora
*
* Reads values from a photoresistor connected to the
* analog input pin 0. The value read from the sensor is proportional
* to the amount of light that hits the sensor surface.
* The value read is printed through the serial to be monitored
* in the console or received on Isadora
*/
int val;
void setup()
{
Serial.begin(9600); // sets the serial port to 9600
}
void loop()
{
val = analogRead(0); // read analog input pin 0
Serial.print(1, DEC); // print a '1', this character will be
// used as a parsing character
Serial.println(val, DEC); // prints the value read from the
// sensor in analog pin 0
delay(200); // wait 200ms for next reading
}
Step 3
Next step is to setup things in Isadora. Start Isadora. In the "Search" box type Serial and find "Serial In Watcher - Text", select it and drop the object on the main Isadora work area:
Step 4
Double click the Serial In watcher and a popup window will open, inside type the following small program:
"1"
value : integer = 4 digits
"1" is used to identify the Serial In Watcher parsing character we are printing in the Wiring code.
"value" is a variable name, any name will be fine. Given "integer = 4 digits" the value will be appear like: 1XXX, where XXX is the actual value read from the sensor. If sending a value from a digital input, just change "integer = digits", since the digital signal will be 1 (HIGH) or 0 (LOW).
Note that a new output named "value" is added to the Serial In Watcher object.
Step 5
Go to the "Output" menu and select "Serial Port Setup":
The Serial Port Setup popup Window opens, click on the Select menu and select the Wiring board serial port, on Windows it will appear as COMx, where x must be the number assigned to the Wiring board, on macosx it will appear as usbserial-xxxxxxxx. The other settings can be left as the default, the Speed parameter will be left to 9600 since this is the speed used previously in the Wiring program on step 1 (Serial.begin(9600);). Click OK to close the dialog box to continue.
Step 6
Change the field "eom char" in the Serial In Watcher object from 13 to 10:
Step 7
Go to the "Output" menu and select "Enable Serial Ports" this will activate the serial connection:
Note the "msg rcv" field in the Serial In Watcher object is blinking and printing "X" and "-" alternating:
Interact with the sensor to change the input value. Note how the sensor can be changed for any other analog sensor, such as a potentiometer, distance etc. For more information about Isadora, check their forum at http://forum.troikatronix.com/.