About the EZIO Board
The EZIO Board is a microcontroller experimentation board created by Michael Rodemer and Ed Bennett. It can be used to interface a computer with external electronics, sensors, motors, lights, etc. The EZIO Board is used around the world by electronic artists and designers for installations, robotics, and experiments in physical computing. It has digital inputs for attaching switches, buttons, or any other kind of on/off signal. It also has analog to digital converters for attaching sensors which can respond to varying amounts of light, heat, pressure, etc.
The EZIO attaches to the computer through the serial port. Many newer computers have USB ports instead of serial ports, but the EZIO can also be used with USB to Serial converters.
The EZIO Board can be used with any programming language that can access the serial port, and with programs like MAX/MSP and Director through plugins. The EZIOXtra adds scripting commands to Director to control the board.
About the EZIOXtra
The EZIOXtra is a Director plugin for Director 7 and higher. It is available for Mac OS 9, for Mac OSX, and for Windows.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
Installing the EZIOXtra
|new ()||findPorts ()||initSerial ()||closeSerial ()|
|readLine()||a2d ()||readLineAll ()||a2dAll ()|
|writeLine ()||pwm ()||readPort ()||writePort ()|
Initializing the Xtra
XtraObject new xtra ("EZIOXtra")
Creates a new script Xtra object.
ezio = new xtra ("ezioxtra")
Usually, you'll want to make the xtra object a global variable so you can use it throughout the movie.
ezio = new xtra ("EZIOXtra")
_global.ezio = new xtra ("EZIOXtra")
ezio = new xtra ("EZIOXtra")
portlist findPorts ()Return a list of available serial ports.
portlist = ezio.findPorts ()
You can also use these specific names in the initSerial() function.
error initSerial (port)open a serial port to initialize communication with the EZIO board. You must call initSerial before using any other EZIO functions!
There are three ways to choose the port: by number, by name, or by generic name. The function returns 0 if there were no errors, and an error code if there was an error.
Initializing by NumberThis is the simplest form of the command. The ports are counted in the order that you see them in the list returned by findPorts (). For example, on a Mac that has serial ports, findPorts () will return:
["Printer Port","Modem Port"]
So, if you have the EZIO plugged into the printer port, you'd say:
err = ezio.initSerial (1)And for the modem port,
However, you might have other serial devices, like an internal modem or Bluetooth device. So if findPorts () returns this:
Initializing by NameThe problem is basically that the USB->Serial adapter ports will have different numbers depending on what other devices are on your computer. Instead of initializing by number, you can also initialize by name:
Initializing by generic nameFinally, you can use the generic names "modem" and "printer" to open the serial port:
error closeSerial ()closes the serial port. You MUST call this function at the end of your movie! Forgetting to call closeSerial () can leave the serial port stranded and unaccessible the next time you run your movie. With USB adapters, you can fix this by just unplugging it and plugging it back in, though on older computers you might have to reboot the whole machine. Usually you want to put this in your stopMovie function.
value readLine (lineNumber)reads one of the digital input lines, and returns either 0 or 1. lineNumber is a number from 1 to 10, as labeled on the EZIO board.
This is kind of counterintuitive, but has to do with how the electronics on the board work. When you don't have any circuitry attached to the digital inputs, they're "pulled high," or attached to +5V. When you close the switch between the input and Ground, it pulls the input low.
Why is this? If the inputs were built the other way (left floating low, and turned on by pulling high), they would be more susceptible to circuit noise and static electricity.
value a2d (lineNumber)Reads one of the Analog to Digital inputs on the board, and returns a value from 0 to 255.
lineNumber ranges from 1 to 8.
-- read line 1 a1 = ezio.a2d (1) -- read line 2 a2 = ezio.a2d (2)
valuelist readLineAll ()Reads all 10 digital input lines and returns them in a list.
-- Lingo global ezio inputs = ezio.readLineAll () put inputs -- [1, 1, 0, 1, 0, 0, 1, 1, 1, 0] lines 3,5,6, and 10 are on.
valuelist a2dAll ()Read all the analog to digital converters and return a list of 8 values.
value readPort ()Read the first 8 digital input lines as a single byte (0-255).
writeLine (line,value)Turn one of the digital output lines on or off. line is from 1 to 10. value is 1 to turn the line on, and 0 to turn it off. The example below would be used in a behavior to turn line 1 on when you click on a sprite, and turn it off when you release the mouse.
pwm (line, duty cycle)Pulse-width modulation, or PWM, is used to approximate a varying output. To change the brightness of a light, you would want to change the amount of current flowing through it. PWM simulates this effect by rapidly turning the light on and off, faster than the eye can see. The ratio between the amount of time the light is on and the amount of time it's off determines how bright the light appears to be.
writePort (value)Write a single byte (0-255) out on the first 8 digital output lines.