<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.phidgets.com/docs21/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=192.168.3.159</id>
	<title>Phidgets Legacy Support - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://www.phidgets.com/docs21/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=192.168.3.159"/>
	<link rel="alternate" type="text/html" href="https://www.phidgets.com/docs21/Special:Contributions/192.168.3.159"/>
	<updated>2026-09-20T21:35:43Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.8</generator>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=Language_-_Flex_AS3&amp;diff=9370</id>
		<title>Language - Flex AS3</title>
		<link rel="alternate" type="text/html" href="https://www.phidgets.com/docs21/index.php?title=Language_-_Flex_AS3&amp;diff=9370"/>
		<updated>2011-11-14T15:45:19Z</updated>

		<summary type="html">&lt;p&gt;192.168.3.159: /* Drivers, Libraries and Resources */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Preamble about the language and its general strengths and weaknesses.&lt;br /&gt;
&lt;br /&gt;
==Assessment for use with Phidgets==&lt;br /&gt;
Our honest opinion on how well this language is suited to controlling Phidgets. If it is a poor choice, suggest and link similar (better) languages.&lt;br /&gt;
&lt;br /&gt;
==Support==&lt;br /&gt;
Flex AS3 has a complete API and code samples for all Phidgets devices.&lt;br /&gt;
&lt;br /&gt;
For a complete list of our supported languages and their support status, [[Levels of Support|click here]].&lt;br /&gt;
&lt;br /&gt;
==Restrictions==&lt;br /&gt;
In this section, list any restrictions or limitations that this particular language may impose. For example, incompatibility with certain operating systems.&lt;br /&gt;
&lt;br /&gt;
==Development Environments and Compilers==&lt;br /&gt;
&lt;br /&gt;
Describe each major compiler and notable differences or important information. (eg. framework versions) If there are known issues/workarounds mention them and link to the corresponding issue at the bottom of the page. &lt;br /&gt;
&lt;br /&gt;
==Quick Downloads==&lt;br /&gt;
Before you can run your program, you need to set up the proper environment and get the necessary files off the Phidgets website. &lt;br /&gt;
Visit the drivers section at www.phidgets.com and get the latest:&lt;br /&gt;
* [http://www.phidgets.com/drivers.php Phidget Framework]&lt;br /&gt;
You will need the Phidget Framework to use and to program with Phidgets. We also recommend that you download the following reference materials:&lt;br /&gt;
* [http://www.phidgets.com/documentation/Phidget21Flash_doc.zip API Manual]&lt;br /&gt;
* [http://www.phidgets.com/documentation/web/flashdoc/index.html API Reference]&lt;br /&gt;
* [http://www.phidgets.com/downloads/examples/Flex_2.1.8.20110615.zip Flex AS3 Sample Code]&lt;br /&gt;
* You can find a high level discussion about programming with Phidgets in general on the [[General API]] page. &lt;br /&gt;
* The [[Device Functionality]] page explains the general operational information for your device. &lt;br /&gt;
&lt;br /&gt;
You may want to have these pages open while working through these instructions.&lt;br /&gt;
&lt;br /&gt;
==Getting Started==&lt;br /&gt;
&lt;br /&gt;
The Phidget examples were written using Actionscript 3.0 under Adobe Flex Builder 3 and this tutorial assumes its use. &lt;br /&gt;
Other development environments should work provided they support Actionscript 3.0, and each would be set up in a similar manner. &lt;br /&gt;
First launch Flex and generate a new project with a descriptive name such as PhidgetTest. &lt;br /&gt;
You will then need to add the Phidget Library to your project library path. &lt;br /&gt;
This can be done under Project | Properties | Flex Build Path on the Library tab, by clicking the “Add SWC” button and selecting the Phidget21Library.swc from the Flex examples. &lt;br /&gt;
As an alternative, you can copy the “com” folder that is located in the Flash AS3 examples into your project source directory and it should work as well. &lt;br /&gt;
&lt;br /&gt;
===Coding For Your Phidget===&lt;br /&gt;
&lt;br /&gt;
Before you can use the Phidget, you must import references from the library to the device in the main body of code. In MXML and Actionscript 3.0:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=actionscript&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;&lt;br /&gt;
  &amp;lt;mx:Application xmlns:mx=&amp;quot;http://www.adobe.com/2006/mxml&amp;quot; layout=&amp;quot;absolute&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;mx:Script&amp;gt;&lt;br /&gt;
     &amp;lt;![CDATA[&lt;br /&gt;
        import com.phidgets.PhidgetInterfaceKit;&lt;br /&gt;
        import com.phidgets.events.*;&lt;br /&gt;
        //More code goes here&lt;br /&gt;
     ]]&amp;gt;&lt;br /&gt;
  &amp;lt;/mx:Script&amp;gt;&lt;br /&gt;
  &amp;lt;/mx:Application&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Afterwards, the Phidget object will need to be declared and then initialized. &lt;br /&gt;
For example, a start function is set to execute on initialization, and then an instance of a PhidgetInterfaceKit is declared and then set inside with: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=actionscript&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  public var phid:com.phidgets.PhidgetInterfaceKit;&lt;br /&gt;
  public function start():void{ &lt;br /&gt;
     phid = new PhidgetInterfaceKit();&lt;br /&gt;
     //More code goes here&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The object name for any type of Phidget is listed in the API manual. Every type of Phidget also inherits functionality from the Phidget base class.&lt;br /&gt;
&lt;br /&gt;
===Connecting to the Phidget===&lt;br /&gt;
&lt;br /&gt;
Next, the program needs to try and connect to the Phidget through an open call. &lt;br /&gt;
Open will continuously try to connect to a Phidget, based on the parameters given, even trying to reconnect if it gets disconnected. &lt;br /&gt;
This means that simply calling open does not guarantee you can use the Phidget immediately. &lt;br /&gt;
We can handle this by using event driven programming and tracking the AttachEvents and DetachEvents, or checking the isAttached property.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=actionscript&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  phid.open(&amp;quot;localhost&amp;quot;, 5001);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The API manual lists all of the available modes that open provides. &lt;br /&gt;
In Flash, the parameters can be used to open the first Phidget of a type it can find or based on its serial number. &lt;br /&gt;
One important thing to remember is that when working with Phidgets, a local connection will reserve the device until closed. &lt;br /&gt;
This means other programs that open the Phidget may end up preventing other instances from retrieving data. &lt;br /&gt;
The one connection per device limit does not apply when exclusively using the Phidget WebService, and the Actionscript libraries by extension.&lt;br /&gt;
&lt;br /&gt;
===Event Driven Programming===&lt;br /&gt;
&lt;br /&gt;
We recommend the use of event driven programming when working with Phidgets. &lt;br /&gt;
In Actionscript 3.0, we hook an event handler with the following code: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=actionscript&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
  phid.addEventListener(PhidgetDataEvent.SENSOR_CHANGE, onSensorChange);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The onSensorChange method will get executed every time the PhidgetInterfaceKit reports a change on one of its analog inputs. &lt;br /&gt;
The values from the report can be accessed from the PhidgetDataEvent object.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=actionscript&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  private function onSensorChange(evt:PhidgetDataEvent):void{&lt;br /&gt;
     //Insert your code here&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some events such as Attach and Detach belong to the base Phidget object and thus are common to all types of Phidgets. &lt;br /&gt;
Please refer to the API manual for a full list of events and their usage. &lt;br /&gt;
&lt;br /&gt;
===Working directly with the Phidget===&lt;br /&gt;
&lt;br /&gt;
Some values can be directly read and set on the Phidget and used as an alternative to event driven programming. &lt;br /&gt;
Simply use the instance properties or call member functions such as getSensorValue(index: int) or setOutputState(index: int, val: Boolean) for PhidgetInterfaceKits.&lt;br /&gt;
&lt;br /&gt;
===Working with multiple Phidgets===&lt;br /&gt;
&lt;br /&gt;
Multiple Phidgets of the same type can easily be run inside the same program. &lt;br /&gt;
In our case, it requires another PhidgetInterfaceKit instance to be defined and initialized. &lt;br /&gt;
The new instance can then be set up, opened and used in the same process as the previous one. &lt;br /&gt;
If the application needs to distinguish between the devices, open can be called with the serial number of a specific Phidget.&lt;br /&gt;
&lt;br /&gt;
===Flash Security Settings===&lt;br /&gt;
&lt;br /&gt;
During debugging or after publishing the project, you may encounter some difficulties with Flash network security settings either inside or outside of the development environment with Phidgets. &lt;br /&gt;
Permissions for your project folder can be added through the settings manager at [http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04a.html here], under “Always trust files in these locations” | “Edit locations...” | “Add location...”.&lt;br /&gt;
&lt;br /&gt;
===Other Phidgets===&lt;br /&gt;
&lt;br /&gt;
The design given in this document can also be followed for almost all Phidgets. &lt;br /&gt;
For example, if you were using a PhidgetRFID instead of an PhidgetInterfacekit, you would declare a RFID object instead of a InterfaceKit object. &lt;br /&gt;
The methods and events available would change but they can be accessed in a similar manner.&lt;br /&gt;
&lt;br /&gt;
==Building your Project==&lt;br /&gt;
Describe the different ways a project could be built using this language.&lt;br /&gt;
&lt;br /&gt;
==Common Problems and Solutions/Workarounds==&lt;br /&gt;
Here you can put various frequent problems and our recommended solutions.&lt;/div&gt;</summary>
		<author><name>192.168.3.159</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=Language_-_Flash_AS3&amp;diff=9369</id>
		<title>Language - Flash AS3</title>
		<link rel="alternate" type="text/html" href="https://www.phidgets.com/docs21/index.php?title=Language_-_Flash_AS3&amp;diff=9369"/>
		<updated>2011-11-14T15:44:58Z</updated>

		<summary type="html">&lt;p&gt;192.168.3.159: /* Drivers, Libraries and Resources */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Preamble about the language and its general strengths and weaknesses.&lt;br /&gt;
&lt;br /&gt;
==Assessment for use with Phidgets==&lt;br /&gt;
Our honest opinion on how well this language is suited to controlling Phidgets. If it is a poor choice, suggest and link similar (better) languages.&lt;br /&gt;
&lt;br /&gt;
==Support==&lt;br /&gt;
Flash AS3 has a complete API and code samples for all Phidgets devices.&lt;br /&gt;
&lt;br /&gt;
For a complete list of our supported languages and their support status, [[Levels of Support|click here]].&lt;br /&gt;
&lt;br /&gt;
==Restrictions==&lt;br /&gt;
In this section, list any restrictions or limitations that this particular language may impose. For example, incompatibility with certain operating systems.&lt;br /&gt;
&lt;br /&gt;
==Development Environments and Compilers==&lt;br /&gt;
&lt;br /&gt;
Describe each major compiler and notable differences or important information. (eg. framework versions) If there are known issues/workarounds mention them and link to the corresponding issue at the bottom of the page. &lt;br /&gt;
&lt;br /&gt;
==Quick Downloads==&lt;br /&gt;
Before you can run your program, you need to set up the proper environment and get the necessary files off the Phidgets website. &lt;br /&gt;
Visit the drivers section at www.phidgets.com and get the latest:&lt;br /&gt;
* [http://www.phidgets.com/drivers.php Phidget Framework]&lt;br /&gt;
You will need the Phidget Framework to use and to program with Phidgets. We also recommend that you download the following reference materials:&lt;br /&gt;
* [http://www.phidgets.com/documentation/Phidget21Flash_doc.zip API Manual]&lt;br /&gt;
* [http://www.phidgets.com/documentation/web/flashdoc/index.html API Reference]&lt;br /&gt;
* [http://www.phidgets.com/downloads/examples/Flash_2.1.8.20110615.zip Flash AS3 Sample Code]&lt;br /&gt;
* You can find a high level discussion about programming with Phidgets in general on the [[General API]] page. &lt;br /&gt;
* The [[Device Functionality]] page explains the general operational information for your device. &lt;br /&gt;
&lt;br /&gt;
You may want to have these pages open while working through these instructions.&lt;br /&gt;
&lt;br /&gt;
==Getting Started==&lt;br /&gt;
&lt;br /&gt;
The Phidget examples were written using ActionScript 3.0 under Flash CS3 and this tutorial assumes its use. &lt;br /&gt;
Other development environments should work provided they support ActionScript 3.0, and each would be set up in a similar manner. &lt;br /&gt;
First launch Flash and generate a new Flash File with a descriptive name such as PhidgetTest. &lt;br /&gt;
You will also need to copy the “com” folder that is located in the Flash AS3 examples into your project root to use the Phidget Library. &lt;br /&gt;
&lt;br /&gt;
Coding For Your Phidget&lt;br /&gt;
&lt;br /&gt;
Before you can use the Phidget, you must include a reference to the library in the action frame (Window | Actions). In Actionscript 3.0:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=actionscript&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  import com.phidgets.PhidgetInterfaceKit;&lt;br /&gt;
  import com.phidgets.events.*;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Afterwards, the Phidget object will need to be declared and then initialized. &lt;br /&gt;
For example, we can declare a PhidgetInterfaceKit with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=actionscript&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  public var phid:com.phidgets.PhidgetInterfaceKit;&lt;br /&gt;
  phid = new PhidgetInterfaceKit();&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The object name for any type of Phidget is listed in the API manual. &lt;br /&gt;
Every type of Phidget also inherits functionality from the Phidget base class.&lt;br /&gt;
&lt;br /&gt;
===Connecting to the Phidget===&lt;br /&gt;
&lt;br /&gt;
The program can try to connect to the Phidget through an open call. &lt;br /&gt;
Open will continuously try to connect to a Phidget, based on the parameters given, even trying to reconnect if it gets disconnected. &lt;br /&gt;
This means that simply calling open does not guarantee you can use the Phidget immediately. &lt;br /&gt;
We can handle this by using event driven programming and tracking the AttachEvents and DetachEvents, or checking the isAttached property.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=actionscript&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  phid.open(&amp;quot;localhost&amp;quot;, 5001);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The API manual lists all of the available modes that open provides. &lt;br /&gt;
In Flash, the parameters can be used to open the first Phidget of a type it can find or based on its serial number. &lt;br /&gt;
One important thing to remember is that when working with Phidgets, a local connection will reserve the device until closed. &lt;br /&gt;
This means other programs that open the Phidget may end up preventing other instances from retrieving data. &lt;br /&gt;
The one connection per device limit does not apply when exclusively using the Phidget WebService, and the Actionscript libraries by extension.&lt;br /&gt;
&lt;br /&gt;
===Event Driven Programming===&lt;br /&gt;
&lt;br /&gt;
We recommend the use of event driven programming when working with Phidgets. &lt;br /&gt;
In Actionscript 3.0, we hook an event handler with the following code:  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=actionscript&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  phid.addEventListener(PhidgetDataEvent.SENSOR_CHANGE, onSensorChange);&lt;br /&gt;
  function onSensorChange(evt:PhidgetDataEvent):void{&lt;br /&gt;
      trace (evt.Data); //Echo&lt;br /&gt;
  //Insert your code here&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this method, the code inside onSensorChange will get executed every time the PhidgetInterfaceKit reports a change on one of its analog inputs. &lt;br /&gt;
The values from the report can be accessed from the PhidgetDataEvent object properties.&lt;br /&gt;
Some events such as Attach and Detach belong to the base Phidget object and thus are common to all types of Phidgets. &lt;br /&gt;
Please refer to the API manual for a full list of events and their usage.&lt;br /&gt;
&lt;br /&gt;
===Working directly with the Phidget===&lt;br /&gt;
&lt;br /&gt;
Some values can be directly read and set on the Phidget and used as an alternative to event driven programming. &lt;br /&gt;
Simply use the instance properties or call member functions such as getSensorValue(index: int) or setOutputState(index: int, val: Boolean) for PhidgetInterfaceKits.&lt;br /&gt;
&lt;br /&gt;
===Working with multiple Phidgets===&lt;br /&gt;
&lt;br /&gt;
Multiple Phidgets of the same type can easily be run inside the same program. &lt;br /&gt;
In our case, it requires another PhidgetInterfaceKit instance to be defined and initialized. &lt;br /&gt;
The new instance can then be set up, opened and used in the same process as the previous one. &lt;br /&gt;
If the application needs to distinguish between the devices, open can be called with the serial number of a specific Phidget.&lt;br /&gt;
&lt;br /&gt;
===Flash Security Settings===&lt;br /&gt;
&lt;br /&gt;
During debugging or after publishing the project, you may encounter some difficulties with Flash network security settings either inside or outside of the development environment with Phidgets. &lt;br /&gt;
Permissions for your project folder can be added through the settings manager [http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04a.html here], &lt;br /&gt;
under “Always trust files in these locations” | “Edit locations...” | “Add location...”.&lt;br /&gt;
&lt;br /&gt;
===Other Phidgets===&lt;br /&gt;
&lt;br /&gt;
The design given in this document can also be followed for almost all Phidgets. &lt;br /&gt;
For example, if you were using a PhidgetRFID instead of an PhidgetInterfacekit, you would declare a RFID object instead of a InterfaceKit object. &lt;br /&gt;
The methods and events available would change but they can be accessed in a similar manner. &lt;br /&gt;
&lt;br /&gt;
==Building your Project==&lt;br /&gt;
Describe the different ways a project could be built using this language.&lt;br /&gt;
&lt;br /&gt;
==Common Problems and Solutions/Workarounds==&lt;br /&gt;
Here you can put various frequent problems and our recommended solutions.&lt;/div&gt;</summary>
		<author><name>192.168.3.159</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=Language_-_Delphi&amp;diff=9368</id>
		<title>Language - Delphi</title>
		<link rel="alternate" type="text/html" href="https://www.phidgets.com/docs21/index.php?title=Language_-_Delphi&amp;diff=9368"/>
		<updated>2011-11-14T15:42:56Z</updated>

		<summary type="html">&lt;p&gt;192.168.3.159: /* Drivers, Libraries and Resources */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Preamble about the language and its general strengths and weaknesses.&lt;br /&gt;
&lt;br /&gt;
==Assessment for use with Phidgets==&lt;br /&gt;
Our honest opinion on how well this language is suited to controlling Phidgets. If it is a poor choice, suggest and link similar (better) languages.&lt;br /&gt;
&lt;br /&gt;
==Support==&lt;br /&gt;
Delphi has a complete API for all Phidgets devices, and code samples for some devices.&lt;br /&gt;
&lt;br /&gt;
For a complete list of our supported languages and their support status, [[Levels of Support|click here]].&lt;br /&gt;
&lt;br /&gt;
==Restrictions==&lt;br /&gt;
In this section, list any restrictions or limitations that this particular language may impose. For example, incompatibility with certain operating systems.&lt;br /&gt;
&lt;br /&gt;
==Development Environments and Compilers==&lt;br /&gt;
&lt;br /&gt;
Describe each major compiler and notable differences or important information. (eg. framework versions) If there are known issues/workarounds mention them and link to the corresponding issue at the bottom of the page. &lt;br /&gt;
&lt;br /&gt;
==Quick Downloads==&lt;br /&gt;
Before you can run your program, you need to set up the proper environment and get the necessary files off the Phidgets website. &lt;br /&gt;
Visit the drivers section at www.phidgets.com and get the latest:&lt;br /&gt;
* [http://www.phidgets.com/drivers.php Phidget Framework]&lt;br /&gt;
You will need the Phidget Framework to use and to program with Phidgets. We also recommend that you download the following reference materials:&lt;br /&gt;
* [http://www.phidgets.com/documentation/COM_API_Manual.pdf API Manual]&lt;br /&gt;
* [http://www.phidgets.com/downloads/examples/Delphi_2.1.8.20110615.zip Delphi Sample Code]&lt;br /&gt;
* You can find a high level discussion about programming with Phidgets in general on the [[General API]] page. &lt;br /&gt;
* The [[Device Functionality]] page explains the general operational information for your device. &lt;br /&gt;
&lt;br /&gt;
You may want to have these pages open while working through these instructions.&lt;br /&gt;
&lt;br /&gt;
==Getting Started==&lt;br /&gt;
&lt;br /&gt;
The Phidget examples were written using Borland Delphi 2005 and 7, and this tutorial assumes its use. &lt;br /&gt;
The ActiveX objects installed with the Phidget libraries are not automatically imported into Delphi, so to begin you will need to manually import them:&lt;br /&gt;
&lt;br /&gt;
#Go to Component &amp;gt;&amp;gt; Import ActiveX Control...&lt;br /&gt;
#Select the Phidget Library 2.1 and click install&lt;br /&gt;
#In the next popup select the “install into new package” tab&lt;br /&gt;
#Give the package a suitable name and description such as “Phidgets”, and then click OK &lt;br /&gt;
#Compile and Install the newly created package if not done so automatically.&lt;br /&gt;
&lt;br /&gt;
In Delphi 2005/2006:&lt;br /&gt;
&lt;br /&gt;
#Go to File &amp;gt;&amp;gt; New &amp;gt;&amp;gt; Package - Delphi for Win32. Rename and save the package using File &amp;gt;&amp;gt; Save Project As...&lt;br /&gt;
#Import the ActiveX component, go to Component &amp;gt;&amp;gt; Import Component.&lt;br /&gt;
#Choose Inport ActiveX Control and click Next&lt;br /&gt;
#Select Phidget Library 2.1 and click Next&lt;br /&gt;
#Click Next&lt;br /&gt;
#Select ‘Add unit to [Package Name] project’ and click Finish.&lt;br /&gt;
#Install the ActiveX package you have created by right-mouse-clicking the package name in the Project Manager pane and selecting ‘Install’.&lt;br /&gt;
#Delphi should now display a confirmation that the package was installed.  Click ok and save the package.&lt;br /&gt;
#When you open a new or existing application, you should now see all the Phidget device control objects listed under the ActiveX category.&lt;br /&gt;
&lt;br /&gt;
In newer versions of Delphi:&lt;br /&gt;
&lt;br /&gt;
#Go to Component &amp;gt;&amp;gt; Import Component...&lt;br /&gt;
#Choose “Import ActiveX Control” and click Next&lt;br /&gt;
#Pick Phidget Library 2.1 from the list and click Next&lt;br /&gt;
#Set the palette Page to ActiveX and check the Generate Component Wrappers option&lt;br /&gt;
#Choose Install into a new package and click next&lt;br /&gt;
#Give the package a name and description such as “Phidgets”, and then click Finish&lt;br /&gt;
&lt;br /&gt;
Once installed, all future projects will be able to use the Phidget ActiveX objects.&lt;br /&gt;
&lt;br /&gt;
===Coding For Your Phidget===&lt;br /&gt;
&lt;br /&gt;
Before you can use the Phidget, you must declare and initialize its ActiveX object. &lt;br /&gt;
The simplest method is to place the control from the ActiveX component tab on to your form. &lt;br /&gt;
For this tutorial, create a PhidgetInterfaceKit control (PhidgetInterfaceKit1) and then add a text edit field to the form for the purpose of capturing simple output. &lt;br /&gt;
The object name for any type of Phidget is listed in the API manual. &lt;br /&gt;
Every type of Phidget also inherits functionality from the Phidget base class.&lt;br /&gt;
&lt;br /&gt;
===Connecting to the Phidget===&lt;br /&gt;
&lt;br /&gt;
Next, we need to tell the program to try and connect to the Phidget through a call to open(). &lt;br /&gt;
The open will tell the program to continuously try to connect to a Phidget, based on the parameters given, even trying to reconnect if it gets disconnected. &lt;br /&gt;
This means that calling open does not guarantee you can use the Phidget immediately. &lt;br /&gt;
We can handle it by either using event driven programming and tracking the AttachEvents and DetachEvents, or by calling waitForAttachment. &lt;br /&gt;
WaitForAttachment will block indefinitely until a connection is made to the Phidget, or an optional timeout is exceeded.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=delphi&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  procedure TForm1.FormCreate(Sender: TObject);&lt;br /&gt;
  begin&lt;br /&gt;
     PhidgetInterfaceKit1.Open(-1);&lt;br /&gt;
  PhidgetInterfaceKit1.WaitForAttachment(3000);&lt;br /&gt;
  end;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The parameters can also be used to open the first Phidget of a type it can find, open based on its serial number, or even open across the network. &lt;br /&gt;
The API manual lists all of the available modes that open provides. &lt;br /&gt;
One important thing to remember is that when working with Phidgets, a local connection will reserve the device until closed. &lt;br /&gt;
This prevents any other instances from retrieving data from the Phidget, including other programs. &lt;br /&gt;
The one connection per device limit does not apply when exclusively using the Phidget Webservice.&lt;br /&gt;
You can call Close any time outside of the Phidget’s own event handlers to end the connection.&lt;br /&gt;
&lt;br /&gt;
===Event Driven Programming===&lt;br /&gt;
&lt;br /&gt;
We recommend the use of event driven programming when working with Phidgets. &lt;br /&gt;
This allows the program to execute other tasks until the Phidget fires a new event. &lt;br /&gt;
&lt;br /&gt;
In Delphi, when the event library was installed it added Phidget ActiveX components for each type of Phidget. &lt;br /&gt;
These ActiveX components will show up in the toolbox under the ActiveX tab. &lt;br /&gt;
The ActiveX object for your Phidget can be added to the form and then hooked to the event handlers you wish to use like any other control. &lt;br /&gt;
For a Phidget21COMIPhidgetInterfaceKitEvents control, the event handler looks like the following:  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=delphi&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  procedure TForm1.PhidgetInterfaceKit1SensorChange(ASender: TObject; Index,&lt;br /&gt;
      SensorValue: Integer);&lt;br /&gt;
  begin&lt;br /&gt;
       Edit1.Text := IntToStr(Index) + &#039;: &#039; + IntToStr(SensorValue);&lt;br /&gt;
  end;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this method, the code inside PhidgetInterfaceKit1SensorChange will get executed every time the PhidgetInterfaceKit reports a change on one of its analog inputs. &lt;br /&gt;
Some events such as Attach and Detach belong to the base Phidget object and thus are common to all types of Phidgets. &lt;br /&gt;
Please refer to the COM API manual for a full list of events and their general usage.&lt;br /&gt;
&lt;br /&gt;
===Working directly with the Phidget===&lt;br /&gt;
&lt;br /&gt;
Some values can be directly read and set on the Phidget, and inside polling loops used as an alternative to event driven programming. &lt;br /&gt;
Simply use the CallString such as SensorValue[Index] or OutputState[Index] for PhidgetInterfaceKits.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=delphi&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  PhidgetInterfaceKit1.OutputState[0] := true;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Working with multiple Phidgets===&lt;br /&gt;
&lt;br /&gt;
Multiple Phidgets of the same type can easily be run inside the same program. &lt;br /&gt;
In our case, it requires another PhidgetInterfaceKit ActiveX object to be added to the project. &lt;br /&gt;
The new instance can then be set up, opened and used in the same fashion as the previous one. &lt;br /&gt;
If the application needs to distinguish between the devices, open can be called with the serial number of a specific Phidget.&lt;br /&gt;
&lt;br /&gt;
===Other Phidgets===&lt;br /&gt;
&lt;br /&gt;
The design given in this document can also be followed for almost all Phidgets. &lt;br /&gt;
For example, if you were using a PhidgetRFID instead of an PhidgetInterfacekit, you would place a PhidgetRFID ActiveX object instead of a PhidgetInterfaceKit. &lt;br /&gt;
The methods and events available would change but they can be accessed in a similar manner. &lt;br /&gt;
&lt;br /&gt;
===Enabling Logging===&lt;br /&gt;
&lt;br /&gt;
Often it’s a good idea to enable logging during development for debugging purposes. &lt;br /&gt;
This log, depending on the level set, will record certain events and errors from Phidgets. &lt;br /&gt;
In Delphi, this is accomplished by calling EnableLogging(logLevel, filename) on the Phidget object. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=delphi&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  PhidgetInterfaceKit1.EnableLogging(6, &#039;testlog.txt&#039;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Similarly, you can call DisableLogging() at the end of your program to shut it off. &lt;br /&gt;
Should you need to contact Phidgets for support, including this log is very helpful for revealing the cause of the problem. &lt;br /&gt;
Please see the Programming Manual for a general discussion on Phidget logging and the levels provided.&lt;br /&gt;
&lt;br /&gt;
==Building your Project==&lt;br /&gt;
Describe the different ways a project could be built using this language.&lt;br /&gt;
&lt;br /&gt;
==Common Problems and Solutions/Workarounds==&lt;br /&gt;
Here you can put various frequent problems and our recommended solutions.&lt;/div&gt;</summary>
		<author><name>192.168.3.159</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=Language_-_iOS&amp;diff=9367</id>
		<title>Language - iOS</title>
		<link rel="alternate" type="text/html" href="https://www.phidgets.com/docs21/index.php?title=Language_-_iOS&amp;diff=9367"/>
		<updated>2011-11-14T15:42:16Z</updated>

		<summary type="html">&lt;p&gt;192.168.3.159: /* Drivers, Libraries and Resources */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Preamble about the language and its general strengths and weaknesses.&lt;br /&gt;
&lt;br /&gt;
==Assessment for use with Phidgets==&lt;br /&gt;
Our honest opinion on how well this language is suited to controlling Phidgets. If it is a poor choice, suggest and link similar (better) languages.&lt;br /&gt;
&lt;br /&gt;
==Support==&lt;br /&gt;
iOS has a complete API for all Phidgets devices, and code samples for PhidgetInterfaceKit devices.&lt;br /&gt;
&lt;br /&gt;
For a complete list of our supported languages and their support status, [[Levels of Support|click here]].&lt;br /&gt;
&lt;br /&gt;
==Restrictions==&lt;br /&gt;
In this section, list any restrictions or limitations that this particular language may impose. For example, incompatibility with certain operating systems.&lt;br /&gt;
&lt;br /&gt;
==Development Environments and Compilers==&lt;br /&gt;
&lt;br /&gt;
Describe each major compiler and notable differences or important information. (eg. framework versions) If there are known issues/workarounds mention them and link to the corresponding issue at the bottom of the page. &lt;br /&gt;
&lt;br /&gt;
==Quick Downloads==&lt;br /&gt;
Before you can run your program, you need to set up the proper environment and get the necessary files off the Phidgets website. &lt;br /&gt;
Visit the drivers section at www.phidgets.com and get the latest:&lt;br /&gt;
* [http://www.phidgets.com/drivers.php Phidget Framework]&lt;br /&gt;
* [http://www.phidgets.com/drivers.php iOS Library]&lt;br /&gt;
You will need the Phidget Framework to use and to program with Phidgets. We also recommend that you download the following reference materials:&lt;br /&gt;
* [http://www.phidgets.com/documentation/Phidget21_C_Doc.zip API Manual]&lt;br /&gt;
* [http://www.phidgets.com/documentation/web/cdoc/index.html API Reference]&lt;br /&gt;
* [http://www.phidgets.com/downloads/examples/iOS_2.1.8.20110712.zip iOS Sample Code]&lt;br /&gt;
* You can find a high level discussion about programming with Phidgets in general on the [[General API]] page. &lt;br /&gt;
* The [[Device Functionality]] page explains the general operational information for your device. &lt;br /&gt;
&lt;br /&gt;
You may want to have these pages open while working through these instructions.&lt;br /&gt;
&lt;br /&gt;
==Getting Started==&lt;br /&gt;
&lt;br /&gt;
You will need the Phidget21 library and the iOS library to use and program with Phidgets. &lt;br /&gt;
As iOS devices do not have USB ports, support for Phidgets is made available through the WebService. &lt;br /&gt;
The system that is hosting the Phidgets will need to have the Phidget21 library installed. &lt;br /&gt;
After the framework is installed, the WebService must be started. &lt;br /&gt;
For more information on the WebService, please see the [[Phidgets Webservice|Webservice Page]].&lt;br /&gt;
&lt;br /&gt;
===Setting up a Phidgets Project===&lt;br /&gt;
&lt;br /&gt;
The Phidget examples were written in Objective-C and Xcode 4.0, and this tutorial assumes their use. &lt;br /&gt;
Other versions of Xcode should work as well and would be set up in a similar manner. In Xcode:&lt;br /&gt;
* Generate a new iOS Windows-based Application project with a descriptive name such as PhidgetTest. &lt;br /&gt;
* Set up the Provisioning Profiles and Code Signing settings, if necessary.&lt;br /&gt;
* Download the Phidget21 iOS library, extract the file, and move the iphoneos and the iphonesimulator folders, as well as the phidget21.h into the same directory as the the .xcodeproj file. &lt;br /&gt;
* In xCode, open up the Project Settings &amp;gt; Build Settings.&lt;br /&gt;
* In Linking &amp;gt; Other Linker Flags, follow these steps for both Debug, and Release:&lt;br /&gt;
** Select &amp;quot;Any iOS Simulator SDK&amp;quot; and enter:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 $(SRCROOT)/iphonesimulator/libPhidget21.a&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:* Select &amp;quot;Any iOS SDK&amp;quot; and enter:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 $(SRCROOT)/iphoneos/libPhidget21.a &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* In Search Path &amp;gt; Header Search Path, enter: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 $(SRCROOT)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* In the header file, add a reference to phidget21.h: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=objc&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 #import &amp;quot;phidget21.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* A text field will be used for the purpose of capturing output. Open MainMenu.nib to bring up the Interface Builder. Drag a text field from the Library to the Window.  &lt;br /&gt;
* Add a text field outlet in the header file. For example, &lt;br /&gt;
   &lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=objc&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    @interface PhidgetTestAppDelegate : NSObject &amp;lt;UIApplicationDelegate&amp;gt;{&lt;br /&gt;
        IBOutlet UITextField *sensorValueTxt;&lt;br /&gt;
    }&lt;br /&gt;
    @property (nonatomic, retain) IBOutlet UIWindow *window;&lt;br /&gt;
    @property (nonatomic, retain) IBOutlet UITextField *sensorValueTxt;&lt;br /&gt;
    @end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* In the implementation file, add the following line to the implementation section:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=objc&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   @synthesize sensorValueTxt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Also, be sure release the object in the dealloc method [sensorValueTxt release];&lt;br /&gt;
* Connect the PhidgetTestAppDelegate class instance to sensorValueTxt. &lt;br /&gt;
&lt;br /&gt;
The project now has access to Phidgets and we are ready to begin coding.&lt;br /&gt;
Please note that the iPhone library also contains a sample skeleton xCode project for iOS. &lt;br /&gt;
This project contains the neccessary project settings for Phidgets development. &lt;br /&gt;
Alternatively, you can use it to start developing with Phidgets. &lt;br /&gt;
&lt;br /&gt;
===Coding For Your Phidget===&lt;br /&gt;
&lt;br /&gt;
A Phidget object will need to be declared. For example, we can declare a PhidgetInterfaceKit in the .h header file with:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=objc&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  CPhidgetInterfaceKitHandle ifkit&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
The object name for any type of Phidget is listed in the API manual. &lt;br /&gt;
Every type of Phidget also inherits functionality from the Phidget base class.&lt;br /&gt;
&lt;br /&gt;
===Connecting to the Phidget===&lt;br /&gt;
&lt;br /&gt;
Next, the Phidget object needs to be initialized and the program needs to try and connect to the Phidget over the WebService through a call to openRemoteIP() or openRemote(). &lt;br /&gt;
These calls will tell the program to continuously try to connect to a Phidget, based on the parameters given, even trying to reconnect if it gets disconnected. &lt;br /&gt;
This means that simply calling open does not guarantee you can use the Phidget immediately. &lt;br /&gt;
We can handle this by using event driven programming and tracking the AttachEvents and DetachEvents, or by calling waitForAttachment. &lt;br /&gt;
WaitForAttachment will block indefinitely until a connection is made to the Phidget, or an optional timeout is exceeded. &lt;br /&gt;
For example, we can connect to a PhidgetInterfaceKit in the .m implementation file with:&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=objc&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    @implementation PhidgetTest&lt;br /&gt;
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions&lt;br /&gt;
    {&lt;br /&gt;
        CPhidgetInterfaceKit_create(&amp;amp;ifkit);   &lt;br /&gt;
        CPhidget_openRemoteIP((CPhidgetHandle)ifkit, -1, &amp;quot;192.168.2.163&amp;quot;, 5001, NULL);&lt;br /&gt;
    }&lt;br /&gt;
    @end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The openRemoteIP() and openRemote() calls can be used with parameters to try and get the first device it can find over the network, and open it based on a serial number. &lt;br /&gt;
The API manual provides more information on openRemoteIP() and openRemote(). &lt;br /&gt;
One important thing to remember is that when working with Phidgets, a local connection will reserve the device until closed. &lt;br /&gt;
This prevents any other instances from retrieving data from the Phidget, including other programs. &lt;br /&gt;
The one connection per device limit does not apply when exclusively using the Phidget Webservice.&lt;br /&gt;
At the end of your program, don’t forget to call close to free any locks on the Phidget.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=objc&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  - (void)applicationWillTerminate:(UIApplication *)application&lt;br /&gt;
  {&lt;br /&gt;
      CPhidget_close((CPhidgetHandle)ifkit);&lt;br /&gt;
      CPhidget_delete((CPhidgetHandle)ifkit);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Event Driven Programming===&lt;br /&gt;
&lt;br /&gt;
We recommend the use of event driven programming when working with Phidgets.&lt;br /&gt;
We can hook an event handler at loading with the following code:  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=objc&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    CPhidgetInterfaceKit_set_OnSensorChange_Handler(ifkit, gotSensorChange, self);&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, the callback method needs to be set up before it can be used. For example,&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=objc&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
    int gotSensorChange(CPhidgetInterfaceKitHandle phid, void *context, int ind, int val)&lt;br /&gt;
    {&lt;br /&gt;
        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];&lt;br /&gt;
        [(id)context performSelectorOnMainThread:@selector(SensorChange:)&lt;br /&gt;
        withObject:[NSArray arrayWithObjects:[NSNumber numberWithInt:ind], [NSNumberGetting_Started_iOS created: 06/16/11 Page 4&lt;br /&gt;
        numberWithInt:val], nil] waitUntilDone:NO];&lt;br /&gt;
        [pool release];&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Above, the SensorChange method is invoked on the main thread. Event data is stored in a NSArray, which in turn is sent as a single argument to the SensorChange method. &lt;br /&gt;
The NSAutoreleasePool object is created to clean up released objects on the event thread, and is released at the end of the method. &lt;br /&gt;
The SensorChange method is defined as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=objc&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
    - (void)SensorChange:(NSArray *)sensorChangeData&lt;br /&gt;
    {&lt;br /&gt;
        int sensorIndex, sensorValue;&lt;br /&gt;
        sensorIndex = [[sensorChangeData objectAtIndex:0] intValue];&lt;br /&gt;
        sensorValue = [[sensorChangeData objectAtIndex:1] intValue];&lt;br /&gt;
        _sensorValueTxt.text = [NSString stringWithFormat:@&amp;quot;Sensor: %d, Value: %d&amp;quot;, &lt;br /&gt;
        sensorIndex, sensorValue]];&lt;br /&gt;
    } &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this function, the code inside SensorChange will get executed every time the PhidgetInterfaceKit reports a change on one of its analog inputs. &lt;br /&gt;
Some events such as Attach and Detach belong to the base Phidget object and thus are common to all types of Phidgets. Please refer to the API manual and the iOS examples for a list of events and their usage. &lt;br /&gt;
&lt;br /&gt;
===Working directly with the Phidget===&lt;br /&gt;
&lt;br /&gt;
Some values can be read and sent directly to the Phidget, simply use the C API functions such as CPhidgetInterfaceKit_getSensorValue for PhidgetInterfaceKits.&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=objc&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   int sensorIndex = 0;&lt;br /&gt;
   int sensorValue;&lt;br /&gt;
   CPhidgetInterfaceKit_getSensorValue(ifkit, sensorIndex, &amp;amp;sensorValue);&lt;br /&gt;
   _sensorValueTxt.text = [NSString stringWithFormat:@&amp;quot;Sensor: %d, Value: %d&amp;quot;, &lt;br /&gt;
   sensorIndex, sensorValue]];&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
     &lt;br /&gt;
These functions can be used inside a polling loop as an alternative to event driven programming.&lt;br /&gt;
&lt;br /&gt;
===Working with multiple Phidgets===&lt;br /&gt;
&lt;br /&gt;
Multiple Phidgets of the same type can easily be run inside the same program. &lt;br /&gt;
In our case, it  requires another InterfaceKit instance to be defined and initialized. &lt;br /&gt;
The new instance can then be set up, opened and used in the same process as the previous one. &lt;br /&gt;
If the application needs to distinguish between the devices, open can be called with the serial number of a specific Phidget.&lt;br /&gt;
&lt;br /&gt;
===Other Phidgets===&lt;br /&gt;
&lt;br /&gt;
The design given in this document can also be followed for almost all Phidgets. &lt;br /&gt;
For example, if you were using a PhidgetRFID instead of an PhidgetInterfacekit, you would declare an RFID object instead of an InterfaceKit. The methods and events available would change but they can be accessed in a similar manner. &lt;br /&gt;
&lt;br /&gt;
==Building your Project==&lt;br /&gt;
Describe the different ways a project could be built using this language.&lt;br /&gt;
&lt;br /&gt;
==Common Problems and Solutions/Workarounds==&lt;br /&gt;
Here you can put various frequent problems and our recommended solutions.&lt;/div&gt;</summary>
		<author><name>192.168.3.159</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=Language_-_Objective_C&amp;diff=9366</id>
		<title>Language - Objective C</title>
		<link rel="alternate" type="text/html" href="https://www.phidgets.com/docs21/index.php?title=Language_-_Objective_C&amp;diff=9366"/>
		<updated>2011-11-14T15:41:59Z</updated>

		<summary type="html">&lt;p&gt;192.168.3.159: /* Drivers, Libraries and Resources */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Preamble about the language and its general strengths and weaknesses.&lt;br /&gt;
&lt;br /&gt;
==Assessment for use with Phidgets==&lt;br /&gt;
Our honest opinion on how well this language is suited to controlling Phidgets. If it is a poor choice, suggest and link similar (better) languages.&lt;br /&gt;
&lt;br /&gt;
==Support==&lt;br /&gt;
Cocoa has a complete API and code samples for all Phidgets devices.&lt;br /&gt;
&lt;br /&gt;
For a complete list of our supported languages and their support status, [[Levels of Support|click here]].&lt;br /&gt;
&lt;br /&gt;
==Restrictions==&lt;br /&gt;
In this section, list any restrictions or limitations that this particular language may impose. For example, incompatibility with certain operating systems.&lt;br /&gt;
&lt;br /&gt;
==Development Environments and Compilers==&lt;br /&gt;
&lt;br /&gt;
Describe each major compiler and notable differences or important information. (eg. framework versions) If there are known issues/workarounds mention them and link to the corresponding issue at the bottom of the page. &lt;br /&gt;
&lt;br /&gt;
==Quick Downloads==&lt;br /&gt;
Before you can run your program, you need to set up the proper environment and get the necessary files off the Phidgets website. &lt;br /&gt;
Visit the drivers section at www.phidgets.com and get the latest:&lt;br /&gt;
* [http://www.phidgets.com/drivers.php Phidget Framework]&lt;br /&gt;
You will need the Phidget Framework to use and to program with Phidgets. We also recommend that you download the following reference materials:&lt;br /&gt;
* [http://www.phidgets.com/documentation/Phidget21_C_Doc.zip API Manual]&lt;br /&gt;
* [http://www.phidgets.com/documentation/web/NETDoc/Index.html API Reference]&lt;br /&gt;
* [http://www.phidgets.com/downloads/examples/Cocoa_2.1.8.20110630.zip Cocoa Sample Code]&lt;br /&gt;
* You can find a high level discussion about programming with Phidgets in general on the [[General API]] page. &lt;br /&gt;
* The [[Device Functionality]] page explains the general operational information for your device. &lt;br /&gt;
&lt;br /&gt;
You may want to have these pages open while working through these instructions.&lt;br /&gt;
&lt;br /&gt;
==Getting Started==&lt;br /&gt;
&lt;br /&gt;
The Phidget examples were written in Objective-C and Xcode 3.2.4, and this tutorial assumes their use. &lt;br /&gt;
Other versions of Xcode should work as well and would be set up in a similar manner. &lt;br /&gt;
In Xcode:&lt;br /&gt;
* Generate a new Cocoa project with a descriptive name such as PhidgetTest. &lt;br /&gt;
* Add the Phidget21 Framework(Groups &amp;amp; Files -&amp;gt; Frameworks -&amp;gt; Other Frameworks).&lt;br /&gt;
* Create a new Objective-C class with a descriptive name. For the purpose of this guide, the class name will be PhidgetInterfaceKit. &lt;br /&gt;
A header file(.h) as well as an implementation file(.m) will automatically be created.&lt;br /&gt;
* Open the header file for editing&lt;br /&gt;
* Add a reference to phidget21.h: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=objc&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  #import &amp;lt;Phidget21/phidget21.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* A text field will be used for the purpose of capturing output. Add a text field outlet in the header file. For example, &lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=objc&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  @interface PhidgetInterfaceKit : NSObject{&lt;br /&gt;
    IBOutlet NSTextField *sensorValueTxt;&lt;br /&gt;
  }&lt;br /&gt;
  @end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* In Groups &amp;amp; Files -&amp;gt; Resources, open up MainMenu.nib to bring up the Interface Builder. Drag a text field from the Library to the Window.  &lt;br /&gt;
* Now, an instance of the PhidgetInterfaceKit class will need to be created. In the Library, drag an object to the MainMenu.nib Window. &lt;br /&gt;
Open up the Identity tab of the Inspector for this object and add the PhidgetInterfaceKit class. &lt;br /&gt;
* Connect the PhidgetInterfaceKit class instance to the text field. &lt;br /&gt;
The project now has access to Phidgets and we are ready to begin coding.&lt;br /&gt;
&lt;br /&gt;
===Coding For Your Phidget===&lt;br /&gt;
&lt;br /&gt;
A Phidget object will need to be declared. For example, we can declare a PhidgetInterfaceKit in the .m implementation file with:&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=objc&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
  CPhidgetInterfaceKitHandle ifkit&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The object name for any type of Phidget is listed in the API manual. Every type of Phidget also inherits functionality from the Phidget base class.&lt;br /&gt;
&lt;br /&gt;
===Connecting to the Phidget===&lt;br /&gt;
&lt;br /&gt;
Next, the Phidget object needs to be initialized and the program needs to try and connect to the Phidget through a call to open(). &lt;br /&gt;
Open will tell the program to continuously try to connect to a Phidget, based on the parameters given, even trying to reconnect if it gets disconnected. &lt;br /&gt;
This means that simply calling open does not guarantee you can use the Phidget immediately. &lt;br /&gt;
We can handle this by using event driven programming and tracking the AttachEvents and DetachEvents, or by calling waitForAttachment. &lt;br /&gt;
WaitForAttachment will block indefinitely until a connection is made to the Phidget, or an optional timeout is exceeded. &lt;br /&gt;
For example, we can connect to a PhidgetInterfaceKit in the .m implementation file with:&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=objc&amp;gt;&lt;br /&gt;
      &lt;br /&gt;
  @implementation PhidgetInterfaceKit&lt;br /&gt;
  - (void)awakeFromNib&lt;br /&gt;
  {&lt;br /&gt;
    CPhidgetInterfaceKit_create(&amp;amp;ifkit);   &lt;br /&gt;
    CPhidget_open((CPhidgetHandle)ifkit, -1);&lt;br /&gt;
  }&lt;br /&gt;
  @end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The different types of open can be used with parameters to try and get the first device it can find, open based on its serial number, or even open across the network. &lt;br /&gt;
The API manual lists all of the available modes that open provides. &lt;br /&gt;
One important thing to remember is that when working with Phidgets, a local connection will reserve the device until closed. &lt;br /&gt;
This prevents any other instances from retrieving data from the Phidget, including other programs. &lt;br /&gt;
The one connection per device limit does not apply when exclusively using the Phidget Webservice.&lt;br /&gt;
At the end of your program, don’t forget to call close to free any locks on the Phidget.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=objc&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  CPhidget_close((CPhidgetHandle)ifkit);&lt;br /&gt;
  CPhidget_delete((CPhidgetHandle)ifkit);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Event Driven Programming===&lt;br /&gt;
&lt;br /&gt;
We recommend the use of event driven programming when working with Phidgets. &lt;br /&gt;
We can hook an event handler at loading with the following code:  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=objc&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  CPhidgetInterfaceKit_set_OnSensorChange_Handler(ifkit, gotSensorChange, self);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
Next, the callback method needs to be set up before it can be used. For example,&lt;br /&gt;
     &lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=objc&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int gotSensorChange(CPhidgetInterfaceKitHandle phid, void *context, int ind, int val)&lt;br /&gt;
  {&lt;br /&gt;
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];&lt;br /&gt;
    [(id)context performSelectorOnMainThread:@selector(SensorChange:)&lt;br /&gt;
    withObject:[NSArray arrayWithObjects:[NSNumber numberWithInt:ind], [NSNumber&lt;br /&gt;
    numberWithInt:val], nil] waitUntilDone:NO];&lt;br /&gt;
    [pool release];&lt;br /&gt;
    return 0;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Above, the SensorChange method is invoked on the main thread. &lt;br /&gt;
Event data is stored in a NSArray, which in turn is sent as a single argument to the SensorChange method. &lt;br /&gt;
The NSAutoreleasePool object is created to clean up released objects on the event thread, and is released at the end of the method. &lt;br /&gt;
&lt;br /&gt;
The SensorChange method is defined as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=objc&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  - (void)SensorChange:(NSArray *)sensorChangeData&lt;br /&gt;
  {&lt;br /&gt;
    int sensorIndex, sensorValue;&lt;br /&gt;
    sensorIndex = [[sensorChangeData objectAtIndex:0] intValue];&lt;br /&gt;
    sensorValue = [[sensorChangeData objectAtIndex:1] intValue];&lt;br /&gt;
    [sensorValueTxt setStringValue:[NSString stringWithFormat:@&amp;quot;Sensor: %d, Value: &lt;br /&gt;
    %d&amp;quot;, sensorIndex, sensorValue]];&lt;br /&gt;
  } &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this function, the code inside SensorChange will get executed every time the PhidgetInterfaceKit reports a change on one of its analog inputs. &lt;br /&gt;
Some events such as Attach and Detach belong to the base Phidget object and thus are common to all types of Phidgets. &lt;br /&gt;
Please refer to the API manual and the Cocoa examples for a list of events and their usage. &lt;br /&gt;
&lt;br /&gt;
===Working directly with the Phidget===&lt;br /&gt;
&lt;br /&gt;
Some values can be read and sent directly to the Phidget, simply use the C API functions such as CPhidgetInterfaceKit_getSensorValue() for PhidgetInterfaceKits.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=objc&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  int sensorValue;&lt;br /&gt;
  CPhidgetInterfaceKit_getSensorValue(ifkit, 0, &amp;amp;sensorValue);&lt;br /&gt;
  [sensorValueTxt setintValue: sensorValue];&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
These functions can be used inside a polling loop as an alternative to event driven programming.&lt;br /&gt;
&lt;br /&gt;
===Working with multiple Phidgets===&lt;br /&gt;
&lt;br /&gt;
Multiple Phidgets of the same type can easily be run inside the same program. &lt;br /&gt;
In our case, it requires another PhidgetInterfaceKit instance to be defined and initialized. &lt;br /&gt;
The new instance can then be set up, opened and used in the same process as the previous one. &lt;br /&gt;
If the application needs to distinguish between the devices, open can be called with the serial number of a specific Phidget.&lt;br /&gt;
&lt;br /&gt;
===Other Phidgets===&lt;br /&gt;
&lt;br /&gt;
The design given in this document can also be followed for almost all Phidgets. &lt;br /&gt;
For example, if you were using a PhidgetRFID instead of an PhidgetInterfacekit, you would declare an RFID object instead of an InterfaceKit. &lt;br /&gt;
The methods and events available would change but they can be accessed in a similar manner.&lt;br /&gt;
&lt;br /&gt;
==Building your Project==&lt;br /&gt;
Describe the different ways a project could be built using this language.&lt;br /&gt;
&lt;br /&gt;
==Common Problems and Solutions/Workarounds==&lt;br /&gt;
Here you can put various frequent problems and our recommended solutions.&lt;/div&gt;</summary>
		<author><name>192.168.3.159</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=Language_-_C_Sharp_(.NET_Compact_Framework)&amp;diff=9365</id>
		<title>Language - C Sharp (.NET Compact Framework)</title>
		<link rel="alternate" type="text/html" href="https://www.phidgets.com/docs21/index.php?title=Language_-_C_Sharp_(.NET_Compact_Framework)&amp;diff=9365"/>
		<updated>2011-11-14T15:41:46Z</updated>

		<summary type="html">&lt;p&gt;192.168.3.159: /* Drivers, Libraries and Resources */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Preamble about the language and its general strengths and weaknesses.&lt;br /&gt;
&lt;br /&gt;
==Assessment for use with Phidgets==&lt;br /&gt;
Our honest opinion on how well this language is suited to controlling Phidgets. If it is a poor choice, suggest and link similar (better) languages.&lt;br /&gt;
&lt;br /&gt;
==Support==&lt;br /&gt;
Describe the [[Levels of Support|level of support]] given to this language and why.&lt;br /&gt;
&lt;br /&gt;
==Restrictions==&lt;br /&gt;
In this section, list any restrictions or limitations that this particular language may impose. For example, incompatibility with certain operating systems.&lt;br /&gt;
&lt;br /&gt;
==Development Environments and Compilers==&lt;br /&gt;
&lt;br /&gt;
Describe each major compiler and notable differences or important information. (eg. framework versions) If there are known issues/workarounds mention them and link to the corresponding issue at the bottom of the page. &lt;br /&gt;
&lt;br /&gt;
==Quick Downloads==&lt;br /&gt;
Before you can run your program, you need to set up the proper environment and get the necessary files off the Phidgets website. &lt;br /&gt;
Visit the drivers section at www.phidgets.com and get the latest:&lt;br /&gt;
* [http://www.phidgets.com/drivers.php Phidget Framework]&lt;br /&gt;
You will need the Phidget Framework to use and to program with Phidgets. We also recommend that you download the following reference materials:&lt;br /&gt;
* API Manual (Link to API download)&lt;br /&gt;
* API Reference (Link to online API reference (if applicable))&lt;br /&gt;
* Example Programs written in this language&lt;br /&gt;
* You can find a high level discussion about programming with Phidgets in general on the [[General API]] page. &lt;br /&gt;
* The [[Device Functionality]] page explains the general operational information for your device. &lt;br /&gt;
&lt;br /&gt;
You may want to have these pages open while working through these instructions.&lt;br /&gt;
&lt;br /&gt;
==Getting Started==&lt;br /&gt;
Here we provide a basic setup guide and code samples to start a project from scratch.&lt;br /&gt;
&lt;br /&gt;
==Building your Project==&lt;br /&gt;
Describe the different ways a project could be built using this language.&lt;br /&gt;
&lt;br /&gt;
==Common Problems and Solutions/Workarounds==&lt;br /&gt;
Here you can put various frequent problems and our recommended solutions.&lt;/div&gt;</summary>
		<author><name>192.168.3.159</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=Language_-_C_Sharp&amp;diff=9364</id>
		<title>Language - C Sharp</title>
		<link rel="alternate" type="text/html" href="https://www.phidgets.com/docs21/index.php?title=Language_-_C_Sharp&amp;diff=9364"/>
		<updated>2011-11-14T15:41:15Z</updated>

		<summary type="html">&lt;p&gt;192.168.3.159: /* Drivers, Libraries and Resources */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;C# is a modern, object-oriented programming language developed by Microsoft.&lt;br /&gt;
&lt;br /&gt;
==Assessment for use with Phidgets==&lt;br /&gt;
Since C# supports event-driven programming and is object-oriented, it is capable of using all of the functionality Phidgets has to offer.&lt;br /&gt;
&lt;br /&gt;
Due to the popularity of C#, you can also find plenty of other programmers on the C# section of [http://www.phidgets.com/phorum/viewforum.php?f=22 our forums].&lt;br /&gt;
==Support==&lt;br /&gt;
C# has a complete API and sample code for all Phidgets devices.&lt;br /&gt;
&lt;br /&gt;
For a complete list of our supported languages and their support status, [[Levels of Support|click here]].&lt;br /&gt;
&lt;br /&gt;
==Restrictions==&lt;br /&gt;
C# as a language has no relevant restrictions in regards to using Phidgets.&lt;br /&gt;
&lt;br /&gt;
==Development Environments and Compilers==&lt;br /&gt;
&lt;br /&gt;
===Mono===&lt;br /&gt;
Mono is a free, open-source C# compiler. If you want to program with Phidgets using C# on Linux, Mono is your best option. &lt;br /&gt;
&lt;br /&gt;
You can visit Mono&#039;s website [http://www.mono-project.com/Main_Page here].&lt;br /&gt;
&lt;br /&gt;
===Visual Studio 2003===&lt;br /&gt;
Visual Studio 2003 requires our .NET 1.1 libraries. Make sure you download the latest version of our [http://www.phidgets.com/drivers.php drivers] and add a reference in your project to Phidget21.NET version 1.1.&lt;br /&gt;
&lt;br /&gt;
Our code samples were designed for use with Visual Studio 2005 or 2008. You can try to build a new project in Visual Studio 2003 using the source code we provide, but we cannot guarantee that it will work. &lt;br /&gt;
&lt;br /&gt;
===Visual Studio 2005===&lt;br /&gt;
Visual Studio 2005 requires our .NET 2.0 libraries. Make sure you download the latest version of our [http://www.phidgets.com/drivers.php drivers] and add a reference in your project to Phidget21.NET version 2.0.&lt;br /&gt;
&lt;br /&gt;
When running our sample code, if you&#039;re using Visual Studio 2005, open the project file that does &#039;&#039;&#039;not&#039;&#039;&#039; have &amp;quot;2008&amp;quot; after the project name.&lt;br /&gt;
&lt;br /&gt;
===Visual Studio 2008 and 2010===&lt;br /&gt;
Visual Studio 2008 and 2010 require our .NET 2.0 libraries. Make sure you download the latest version of our [http://www.phidgets.com/drivers.php drivers] and add a reference in your project to Phidget21.NET version 2.0. We do not currently provide support for new features in newer versions of the .NET framework.&lt;br /&gt;
&lt;br /&gt;
When running our sample code, if you&#039;re using Visual Studio 2008 or 2010, open the project file that has &amp;quot;2008&amp;quot; after the project name.&lt;br /&gt;
&lt;br /&gt;
===Visual Studio Express Editions===&lt;br /&gt;
&lt;br /&gt;
Visual Studio Express is the free version of Visual Studio.&lt;br /&gt;
As long as you use the correct version of the .NET framework as mentioned above, Visual Studio Express should work just fine.&lt;br /&gt;
&lt;br /&gt;
==Quick Downloads==&lt;br /&gt;
Before you can run your program, you need to set up the proper environment and get the necessary files off the Phidgets website. &lt;br /&gt;
Visit the drivers section at www.phidgets.com and get the latest:&lt;br /&gt;
* [http://www.phidgets.com/drivers.php Phidget Framework]&lt;br /&gt;
You will need the Phidget Framework to use and to program with Phidgets. We also recommend that you download the following reference materials:&lt;br /&gt;
* [http://www.phidgets.com/documentation/Phidget21.NET.zip .NET API Manual]&lt;br /&gt;
* [http://www.phidgets.com/documentation/web/NETDoc/Index.html .NET API Reference].&lt;br /&gt;
The .NET API manual lists calls and events for every type of Phidget and can be used as a reference. &lt;br /&gt;
* Example Programs written in C# [[http://www.phidgets.com/downloads/examples/CSharp_2.1.8.20110615.zip Windows]] [[http://www.phidgets.com/downloads/examples/CE_2.1.8.20110615.zip .NET Compact Framework]]&lt;br /&gt;
* You can find a high level discussion about programming with Phidgets in general on the [[General API]] page. &lt;br /&gt;
* The [[Device Functionality]] page explains the general operational information for your device. &lt;br /&gt;
&lt;br /&gt;
You may want to have these pages open while working through these instructions.&lt;br /&gt;
&lt;br /&gt;
==Getting Started==&lt;br /&gt;
&lt;br /&gt;
===Setting up a Phidgets Project===&lt;br /&gt;
The Phidget examples were written using Visual C# 2005 and this tutorial assumes its use. Newer &lt;br /&gt;
versions of Visual Studio Express are freely available for download from Microsoft. Older versions of &lt;br /&gt;
Visual Studio work as well and would be set up in a similar manner (Note: you would have to recreate &lt;br /&gt;
the user interface in the examples for Visual Studio versions earlier than 2005). In Visual Studio:&lt;br /&gt;
* Generate a new C# Windows Application with a descriptive name such as PhidgetTest. &lt;br /&gt;
* Launch the Add Reference window (Project | Add Reference).&lt;br /&gt;
* Under the .NET tab, select the most recent Phidget21.NET library. If it does not appear in this list, then you can Browse to the Phidget Framework installation directory and add the Phidget21.NET. dll. For earlier versions of Visual Studio, you will want to use the Phidget21.NET1.1.dll instead. &lt;br /&gt;
* Place a TextBox on your main form for the purpose of capturing output.&lt;br /&gt;
* Hook the form&#039;s Load and FormClosing events. Phidget initialization and shutdown will take place &lt;br /&gt;
there. &lt;br /&gt;
The project now has access to Phidgets and we are ready to begin coding.&lt;br /&gt;
&lt;br /&gt;
===Coding For Your Phidget===&lt;br /&gt;
Before you can use the Phidget, you must include a reference in the code to the libraries. Launch the &lt;br /&gt;
code editor for your form and add this to your using statements:Getting_Started_CSharp created: 11/10/10 Page 2&lt;br /&gt;
using Phidgets;&lt;br /&gt;
using Phidgets.Events;&lt;br /&gt;
Afterwards, a Phidget object will need to be declared and then initialized. For example, we can &lt;br /&gt;
declare a PhidgetInterfaceKit inside our form with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=CSharp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    namespace PhidgetTest&lt;br /&gt;
    {&lt;br /&gt;
        public partial class Form1 : Form&lt;br /&gt;
        {&lt;br /&gt;
            //The Phidget object declaration&lt;br /&gt;
            private InterfaceKit ifKit;&lt;br /&gt;
            public Form1()&lt;br /&gt;
            {&lt;br /&gt;
                InitializeComponent();&lt;br /&gt;
            }&lt;br /&gt;
            //... Form1_Load and Form1_OnClosing here&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The object name for any type of Phidget is listed in the API manual. Every type of Phidget also &lt;br /&gt;
inherits functionality from the Phidget base class.&lt;br /&gt;
&lt;br /&gt;
===Connecting to the Phidget===&lt;br /&gt;
&lt;br /&gt;
Next, the program needs to try and connect to the Phidget through a call to open(). Open will tell the &lt;br /&gt;
program to continuously try to connect to a Phidget, based on the parameters given, even trying to &lt;br /&gt;
reconnect if it gets disconnected. This means that simply calling open does not guarantee you can &lt;br /&gt;
use the Phidget immediately. We can handle this by using event driven programming and tracking &lt;br /&gt;
the AttachEvents and DetachEvents, or by calling waitForAttachment. WaitForAttachment will block &lt;br /&gt;
indefinitely until a connection is made to the Phidget, or an optional timeout is exceeded.&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=CSharp&amp;gt; &lt;br /&gt;
     &lt;br /&gt;
private void Form1_Load(object sender, EventArgs e)&lt;br /&gt;
{&lt;br /&gt;
     ifKit = new InterfaceKit();&lt;br /&gt;
     ifKit.open();&lt;br /&gt;
     ifKit.waitForAttachment(3000);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
The different types of open can be used with parameters to try and get the first device it can find, &lt;br /&gt;
open based on its serial number, or even open across the network. The API manual lists all of the &lt;br /&gt;
available modes that open provides. One important thing to remember is that when working with &lt;br /&gt;
Phidgets, a local connection will reserve the device until closed. This prevents any other instances &lt;br /&gt;
from retrieving data from the Phidget, including other programs. The one connection per device limit &lt;br /&gt;
does not apply when exclusively using the Phidget Webservice.&lt;br /&gt;
&lt;br /&gt;
===Event Driven Programming===&lt;br /&gt;
&lt;br /&gt;
We recommend the use of event driven programming when working with Phidgets. In C# we can &lt;br /&gt;
hook an event handler at loading with the following code: &lt;br /&gt;
 &lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=CSharp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ifKit.SensorChange += new SensorChangeEventHandler(ifKit_SensorChange);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The ifKit_SensorChange method is defined as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=CSharp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        void ifKit_SensorChange(object sender, SensorChangeEventArgs e)&lt;br /&gt;
        {&lt;br /&gt;
            textBox1.Text = &amp;quot;Index &amp;quot; + e.Index + &amp;quot; Value: &amp;quot; + e.Value;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this function, the code inside ifKit_SensorChange will get executed every time the &lt;br /&gt;
PhidgetInterfaceKit reports a change on one of its analog inputs. Some events such as Attach and &lt;br /&gt;
Detach belong to the base Phidget object and thus are common to all types of Phidgets. Please refer &lt;br /&gt;
to the API manual for a full list of events and their usage. &lt;br /&gt;
At the end of your program, unhook any events and call Application.DoEvents(). This will make sure &lt;br /&gt;
there are no outstanding events being processed before calling close. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=CSharp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        private void Form1_FormClosing(object sender, FormClosingEventArgs e)&lt;br /&gt;
        {&lt;br /&gt;
            ifKit.SensorChange -= new SensorChangeEventHandler(ifKit_SensorChange);&lt;br /&gt;
            //run any events in the message queue &lt;br /&gt;
            Application.DoEvents();&lt;br /&gt;
            ifKit.close();&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
Working directly with the Phidget&lt;br /&gt;
Some values can be read and sent directly to the Phidget, simply use the instance members and &lt;br /&gt;
properties. This is also how you would set properties on the Phidget such as the output state or &lt;br /&gt;
sensor sensitivity. These functions can be used inside a polling loop as an alternative to event driven &lt;br /&gt;
programming. &lt;br /&gt;
int val = ifKit.sensors[0].Value;&lt;br /&gt;
&lt;br /&gt;
===Working with multiple Phidgets===&lt;br /&gt;
&lt;br /&gt;
Multiple Phidgets of the same type can easily be run inside the same program. In our case, it  &lt;br /&gt;
requires another PhidgetInterfaceKit instance to be defined and initialized. The new instance can then &lt;br /&gt;
be set up, opened and used in the same process as the previous one. &lt;br /&gt;
If the application needs to distinguish between the devices, open can be called with the serial &lt;br /&gt;
number of a specific Phidget.&lt;br /&gt;
&lt;br /&gt;
===Other Phidgets===&lt;br /&gt;
&lt;br /&gt;
The design given in this document can also be followed for almost all Phidgets. For example, if &lt;br /&gt;
you were using a PhidgetRFID instead of an PhidgetInterfacekit, you would declare an RFID object &lt;br /&gt;
instead of an InterfaceKit. The methods and events available would change but they can be accessed &lt;br /&gt;
in a similar manner. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Not sure if this section is even necessary&lt;br /&gt;
==Building your Project==&lt;br /&gt;
Describe the different ways a project could be built using this language.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
==Common Problems and Solutions/Workarounds==&lt;br /&gt;
&lt;br /&gt;
There are no known issues specific to C# at this time.&lt;/div&gt;</summary>
		<author><name>192.168.3.159</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=Language_-_AutoIt&amp;diff=9363</id>
		<title>Language - AutoIt</title>
		<link rel="alternate" type="text/html" href="https://www.phidgets.com/docs21/index.php?title=Language_-_AutoIt&amp;diff=9363"/>
		<updated>2011-11-14T15:40:56Z</updated>

		<summary type="html">&lt;p&gt;192.168.3.159: /* Quick Links */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Preamble about the language and its general strengths and weaknesses.&lt;br /&gt;
&lt;br /&gt;
==Assessment for use with Phidgets==&lt;br /&gt;
Our honest opinion on how well this language is suited to controlling Phidgets. If it is a poor choice, suggest and link similar (better) languages.&lt;br /&gt;
&lt;br /&gt;
==Support==&lt;br /&gt;
AutoIt has a complete API for all Phidgets devices, but no sample code at this time.&lt;br /&gt;
&lt;br /&gt;
For a complete list of our supported languages and their support status, [[Levels of Support|click here]]&lt;br /&gt;
&lt;br /&gt;
==Restrictions==&lt;br /&gt;
In this section, list any restrictions or limitations that this particular language may impose. For example, incompatibility with certain operating systems.&lt;br /&gt;
&lt;br /&gt;
==Development Environments and Compilers==&lt;br /&gt;
&lt;br /&gt;
Describe each major compiler and notable differences or important information. (eg. framework versions) If there are known issues/workarounds mention them and link to the corresponding issue at the bottom of the page. &lt;br /&gt;
&lt;br /&gt;
==Quick Downloads==&lt;br /&gt;
Before you can run your program, you need to set up the proper environment and get the necessary files off the Phidgets website. &lt;br /&gt;
Visit the drivers section at www.phidgets.com and get the latest:&lt;br /&gt;
* [http://www.phidgets.com/drivers.php Phidget Framework]&lt;br /&gt;
You will need the Phidget Framework to use and to program with Phidgets. We also recommend that you download the following reference materials:&lt;br /&gt;
* [http://www.phidgets.com/documentation/COM_API_Manual.pdf API Manual]&lt;br /&gt;
* At this time, we do not have sample code available for AutoIt.&lt;br /&gt;
* You can find a high level discussion about programming with Phidgets in general on the [[General API]] page. &lt;br /&gt;
* The [[Device Functionality]] page explains the general operational information for your device. &lt;br /&gt;
&lt;br /&gt;
You may want to have these pages open while working through these instructions.&lt;br /&gt;
&lt;br /&gt;
==Getting Started==&lt;br /&gt;
&lt;br /&gt;
Applications using Phidgets can be developed in AutoIt v3 through the COM API and this tutorial assumes its use. &lt;br /&gt;
The Phidget framework will register the necessary .dlls for you. To begin, create a new AutoIt script file and open it with your preferred editor. &lt;br /&gt;
Then, create a simple user interface to work with and then place an input control for the purpose of capturing some simple output.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=autoit&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  #include &amp;lt;GUIConstantsEx.au3&amp;gt;&lt;br /&gt;
  GUICreate(&amp;quot;Phidget Test&amp;quot;)&lt;br /&gt;
  $InputControl = GUICtrlCreateInput(&amp;quot;&amp;quot;, 20, 40, 160)&lt;br /&gt;
  GUISetState(@SW_SHOW)&lt;br /&gt;
  ;Phidget initialization code goes here&lt;br /&gt;
  Do&lt;br /&gt;
     $msg = GUIGetMsg()&lt;br /&gt;
  Until $msg = $GUI_EVENT_CLOSE&lt;br /&gt;
  ;Phidget Event Handlers go here&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Coding For Your Phidget===&lt;br /&gt;
&lt;br /&gt;
Before you can use the Phidget, you must create the object from the Phidget21COM library at initialization. &lt;br /&gt;
This can be accomplished through a call to ObjCreate. For example, we can declare and create a PhidgetInterfaceKit with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=autoit&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $oPhid1 = ObjCreate(&amp;quot;Phidget21COM.PhidgetInterfacekit&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The object name for any type of Phidget is listed in the API manual. &lt;br /&gt;
Every type of Phidget also shares some functionality from the base Phidget class.&lt;br /&gt;
&lt;br /&gt;
===Connecting to the Phidget===&lt;br /&gt;
&lt;br /&gt;
The program can try to connect to the Phidget through a call to open. &lt;br /&gt;
Open will continuously try to connect to a Phidget, based on the parameters given, even trying to reconnect if it gets disconnected. &lt;br /&gt;
This means that simply calling open does not guarantee you can use the Phidget immediately. &lt;br /&gt;
We can account for a connection by using event driven programming and tracking the AttachEvents and DetachEvents, or by calling WaitForAttachment. &lt;br /&gt;
WaitForAttachment will block indefinitely until a connection is made to the Phidget, or an optional timeout is exceeded.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=autoit&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $oPhid1.Open()&lt;br /&gt;
  $oPhid1.WaitForAttachment(3000)&lt;br /&gt;
  If NOT $oPhid1.IsAttached Then&lt;br /&gt;
     MsgBox(0, &amp;quot;Error&amp;quot;, &amp;quot;Phidget Device not attached&amp;quot;)&lt;br /&gt;
  Exit&lt;br /&gt;
  EndIf&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The different parameters and open calls can be used to open the first Phidget of a type it can find, open based on a serial number, or even open across the network. &lt;br /&gt;
The API manual lists all of the available modes that open provides. &lt;br /&gt;
One important thing to remember is that when working with Phidgets, a local connection will reserve the device until closed. &lt;br /&gt;
This prevents any other instances from retrieving data from the Phidget, including other programs. &lt;br /&gt;
The one connection per device limit does not apply when exclusively using the Phidget Webservice.&lt;br /&gt;
&lt;br /&gt;
===Event Driven Programming===&lt;br /&gt;
&lt;br /&gt;
We recommend the use of event driven programming when working with Phidgets. &lt;br /&gt;
This allows the program to execute other tasks until the Phidget generates a new event. &lt;br /&gt;
In AutoIt, you enable event handlers for a Phidget at initialization with the following line:  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=autoit&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $oPhidEvents = ObjEvent($oPhid1, &amp;quot;phid1_&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
AutoIt will use the phidl1_ prefix we declared when looking for the handler to execute. &lt;br /&gt;
You can define the handler functions for events such as OnSensorChange or Attached elsewhere in your code:&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=autoit&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
  Func phid1_OnSensorChange($Index, $SensorValue)&lt;br /&gt;
     GUICtrlSetData($InputControl, $SensorValue)&lt;br /&gt;
  EndFunc &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this method, the code inside phid1_OnSensorChange will get executed every time the PhidgetInterfaceKit reports a change on one of its analog inputs. &lt;br /&gt;
Some events such as Attach and Detach belong to the base Phidget object and thus are common to all types of Phidgets. &lt;br /&gt;
Please refer to the API manual for a full list of events and their usage.&lt;br /&gt;
&lt;br /&gt;
===Working directly with the Phidget===&lt;br /&gt;
&lt;br /&gt;
Some values can be directly read and set on the Phidget, and inside polling loops used as an alternative to event driven programming. &lt;br /&gt;
Simply use the instance properties such as SensorValue(Index as Long) or OutputState(Index as Long) for PhidgetInterfaceKits.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=autoit&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $oPhid1.OutputState(0) = &amp;quot;true&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that when setting booleans on the Phidget, it must be encapsulated in quotes. &lt;br /&gt;
Alternatively, you can usually use the integer value 0 for false and 1 for true. &lt;br /&gt;
&lt;br /&gt;
===Working with multiple Phidgets===&lt;br /&gt;
&lt;br /&gt;
Multiple Phidgets of the same type can easily be run inside the same program. &lt;br /&gt;
In our case, it requires another PhidgetInterfaceKit object to be defined and initialized. &lt;br /&gt;
The new object can then be set up, opened and used in the same process as the previous one. &lt;br /&gt;
If the application needs to distinguish between the devices, open can be called with the serial number of a specific Phidget.&lt;br /&gt;
&lt;br /&gt;
===Other Phidgets===&lt;br /&gt;
&lt;br /&gt;
The design given in this document can also be followed for almost all Phidgets. For example, if you &lt;br /&gt;
were using a PhidgetRFID instead of an PhidgetInterfacekit, you would declare a PhidgetRFID object &lt;br /&gt;
instead of a PhidgetInterfaceKit. The methods and events available would change but they can be &lt;br /&gt;
accessed in a similar manner.&lt;br /&gt;
&lt;br /&gt;
==Building your Project==&lt;br /&gt;
Describe the different ways a project could be built using this language.&lt;br /&gt;
&lt;br /&gt;
==Common Problems and Solutions/Workarounds==&lt;br /&gt;
Here you can put various frequent problems and our recommended solutions.&lt;/div&gt;</summary>
		<author><name>192.168.3.159</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=Language_-_Applescript&amp;diff=9362</id>
		<title>Language - Applescript</title>
		<link rel="alternate" type="text/html" href="https://www.phidgets.com/docs21/index.php?title=Language_-_Applescript&amp;diff=9362"/>
		<updated>2011-11-14T15:40:43Z</updated>

		<summary type="html">&lt;p&gt;192.168.3.159: /* Quick Links */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Applescript is a scripting language for Mac OSX designed primarily for interfacing between applications. &lt;br /&gt;
&lt;br /&gt;
==Assessment for use with Phidgets==&lt;br /&gt;
Our honest opinion on how well this language is suited to controlling Phidgets. If it is a poor choice, suggest and link similar (better) languages.&lt;br /&gt;
&lt;br /&gt;
==Support==&lt;br /&gt;
Applescript has a complete API and sample code for all Phidgets devices.&lt;br /&gt;
&lt;br /&gt;
For a complete list of our supported languages and their support status, [[Levels of Support|click here]].&lt;br /&gt;
&lt;br /&gt;
==Restrictions==&lt;br /&gt;
In this section, list any restrictions or limitations that this particular language may impose. For example, incompatibility with certain operating systems.&lt;br /&gt;
&lt;br /&gt;
==Development Environments and Compilers==&lt;br /&gt;
&lt;br /&gt;
Describe each major compiler and notable differences or important information. (eg. framework versions) If there are known issues/workarounds mention them and link to the corresponding issue at the bottom of the page. &lt;br /&gt;
&lt;br /&gt;
==Quick Downloads==&lt;br /&gt;
Before you can run your program, you need to set up the proper environment and get the necessary files off the Phidgets website. &lt;br /&gt;
Visit the drivers section at www.phidgets.com and get the latest:&lt;br /&gt;
* [http://www.phidgets.com/drivers.php Phidget Framework]&lt;br /&gt;
You will need the Phidget Framework to use and to program with Phidgets. We also recommend that you download the following reference materials:&lt;br /&gt;
* API Manual (Link to API download)&lt;br /&gt;
* API Reference (Link to online API reference (if applicable))&lt;br /&gt;
* Example Programs written in this language&lt;br /&gt;
* You can find a high level discussion about programming with Phidgets in general on the [[General API]] page. &lt;br /&gt;
* The [[Device Functionality]] page explains the general operational information for your device. &lt;br /&gt;
&lt;br /&gt;
You may want to have these pages open while working through these instructions.&lt;br /&gt;
&lt;br /&gt;
==Getting Started==&lt;br /&gt;
The Phidget examples were written using AppleScript 2.1.2 under AppleScript Editor 2.3, and this tutorial assumes their use. Other versions and development environments should work as well and would be set up in a similar manner.&lt;br /&gt;
&lt;br /&gt;
*First, open the AppleScript editor to create a new script.&lt;br /&gt;
*Coding with Phidgets is made possible by the interaction of Apple Events between AppleScript and • the PhidgetsOSA application. Type the following to interact with PhidgetsOSA:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=applescript&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  tell application &amp;quot;PhidgetsOSA&amp;quot;&lt;br /&gt;
  end tell&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The project now has access to Phidgets and we are ready to begin coding. For the rest of this document, unless otherwise stated, it will be assumed that all code will be typed inside this tell block.&lt;br /&gt;
&lt;br /&gt;
===Coding For Your Phidget===&lt;br /&gt;
A Phidget object will need to be declared. For example, we can declare a PhidgetInterfaceKit:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=applescript&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  set ifkit to make new phidget interfacekit&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
The object name for any type of Phidget is listed in the PhidgetsOSA dictionary. Every type of Phidget also inherits functionality from the Phidget base class.&lt;br /&gt;
&lt;br /&gt;
===Connecting to the Phidget===&lt;br /&gt;
&lt;br /&gt;
Next, the Phidget object needs to be initialized and the program needs to try and connect to the Phidget through a call to open. &lt;br /&gt;
Open will tell the program to continuously try to connect to a Phidget, based on the parameters given, even trying to reconnect if it gets disconnected. &lt;br /&gt;
This means that simply calling open does not guarantee you can use the Phidget immediately. &lt;br /&gt;
We can handle this by using event driven programming and tracking the Attach Events and Detach Events, or by specifying the wait parameter. &lt;br /&gt;
The wait parameter will block for a certain amount of time until a connection is made to the Phidget. For example, we can connect to a PhidgetInterfaceKit with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=applescript&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  tell ifkit to open&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The different types of open can be used with parameters to try and get the first device it can find, open based on its serial number, or even open across the network. &lt;br /&gt;
For more information on connecting across a network, please see the &amp;quot;Working with Phidget WebService&amp;quot; guide on the programming section at www.phidgets.com. &lt;br /&gt;
The PhidgetsOSA dictionary lists all of the available modes that open provides. &lt;br /&gt;
Examples of the usage of different types of open are listed below:&lt;br /&gt;
&lt;br /&gt;
We can tell the ifkit to block for 5000ms until a connection has been made to the PhidgetInterfaceKit with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=applescript&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  tell ifkit to open wait 1000 --wait for 5000ms&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can also connect to a PhidgetInterfaceKit over the WebService with a serial number of 99999 on a server with an IP Address of 192.168.3.180 and a port that is opened on 5001 with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=applescript&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  tell ifkit to open serial number 99999 server address &amp;quot;192.168.3.180&amp;quot; server port 5001&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is also possible to connect using the server id. For example, we can connect to a PhidgetInterfaceKit on a password protected server with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=applescript&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  tell ifkit to open server id &amp;quot;TestMac&amp;quot; password &amp;quot;pw&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At the end of your script, don’t forget to call close to free any locks on the Phidget.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=applescript&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  tell ifkit to close&lt;br /&gt;
  delete ifkit&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Phidgets can also be freed from the [[#PhidgetsOSA Menu Bar|PhidgetsOSA Menu Bar]].&lt;br /&gt;
&lt;br /&gt;
===Event Driven Programming===&lt;br /&gt;
We recommend the use of event driven programming when working with Phidgets. &lt;br /&gt;
We can hook an event handler at loading with the following code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=applescript&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  tell ifkit to make new interfacekit sensor change handler with properties {script file:thisScript}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And after the tell block at end of the script, the callback method is defined as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=applescript&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  using terms from application &amp;quot;PhidgetsOSA&amp;quot;&lt;br /&gt;
    on interfacekit sensor changed ind to val on ifkit&lt;br /&gt;
      log &amp;quot;Sensor Index: &amp;quot; &amp;amp; ind &amp;amp; &amp;quot;, Sensor Value: &amp;quot; &amp;amp; val&lt;br /&gt;
    end interfacekit sensor changed&lt;br /&gt;
  end using terms from&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this function, the code inside the interfacekit sensor changed handler will get executed every time the PhidgetInterfaceKit reports a change on one of its analog inputs. &lt;br /&gt;
Some events such as Attach and Detach belong to the base Phidget object and thus are common to all types of Phidgets. &lt;br /&gt;
Please refer to the PhidgetsOSA dictionary and the AppleScript examples for a list of events and their usage.&lt;br /&gt;
&lt;br /&gt;
===Working directly with the Phidget===&lt;br /&gt;
Some values can be read and sent directly to the Phidget. &lt;br /&gt;
For example, sensor values from the PhidgetInterfaceKit can be read with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=applescript&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  log &amp;quot;The first sensor has a value of: &amp;quot; &amp;amp; first interfacekit sensor&#039;s value&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These functions can be used inside a polling loop as an alternative to event driven programming.&lt;br /&gt;
&lt;br /&gt;
===Using the same Phidget in more than one Application===&lt;br /&gt;
One important thing to remember is that when working with Phidgets, a call to open will reserve the device until closed. This prevents any other instances from retrieving data from the Phidget, including other programs. &lt;br /&gt;
If your goal is to use the same Phidget among multiple AppleScripts and/or other applications, there are two approaches.&lt;br /&gt;
:1. Implement logic in the script that will use the same Phidget object if the script detects that a Phidget of the same type has already been initialized. &lt;br /&gt;
For example,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=applescript&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  if first phidget interfacekit exists then&lt;br /&gt;
    set ifkit to the first phidget interfacekit&lt;br /&gt;
  else&lt;br /&gt;
    set ifkit to make the phidget interfacekit&lt;br /&gt;
    open ifkit&lt;br /&gt;
  end if&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:2. The one connection per device limit does not apply when exclusively using the open Phidget Webservice. For more information, please see the &amp;quot;Connecting to the Phidgets&amp;quot; section of this document.&lt;br /&gt;
&lt;br /&gt;
===Working with multiple Phidgets===&lt;br /&gt;
Multiple Phidgets of the same type can easily be run inside the same program. &lt;br /&gt;
In our case, it requires another InterfaceKit instance to be defined and initialized. &lt;br /&gt;
The new instance can then be set up, opened and used in the same process as the previous one.&lt;br /&gt;
If the application needs to distinguish between the devices, open can be called with the serial number of a specific Phidget.&lt;br /&gt;
&lt;br /&gt;
===Other Phidgets===&lt;br /&gt;
The design given in this document can also be followed for almost all Phidgets. &lt;br /&gt;
For example, if you were using a PhidgetRFID instead of an PhidgetInterfacekit, you would declare an RFID object instead of an InterfaceKit. &lt;br /&gt;
The methods and events available would change but they can be accessed in a similar manner.&lt;br /&gt;
&lt;br /&gt;
===PhidgetsOSA Menu Bar===&lt;br /&gt;
[[Image:applescript_bar.jpg]]&lt;br /&gt;
&lt;br /&gt;
The PhidgetsOSA menu bar appears whenever AppleScript accesses the PhidgetsOSA application. &lt;br /&gt;
The menu bar is used to monitor the status of any accessed Phidgets. &lt;br /&gt;
&lt;br /&gt;
Additionally, it can be used to free the lock on a Phidget or quit the PhidgetsOSA application.&lt;br /&gt;
&lt;br /&gt;
==Building your Project==&lt;br /&gt;
Describe the different ways a project could be built using this language.&lt;br /&gt;
&lt;br /&gt;
==Common Problems and Solutions/Workarounds==&lt;br /&gt;
Here you can put various frequent problems and our recommended solutions.&lt;/div&gt;</summary>
		<author><name>192.168.3.159</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=Language_-_Adobe_Director&amp;diff=9361</id>
		<title>Language - Adobe Director</title>
		<link rel="alternate" type="text/html" href="https://www.phidgets.com/docs21/index.php?title=Language_-_Adobe_Director&amp;diff=9361"/>
		<updated>2011-11-14T15:40:21Z</updated>

		<summary type="html">&lt;p&gt;192.168.3.159: /* Quick Links */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Preamble about the language and its general strengths and weaknesses.&lt;br /&gt;
&lt;br /&gt;
==Assessment for use with Phidgets==&lt;br /&gt;
Our honest opinion on how well this language is suited to controlling Phidgets. If it is a poor choice, suggest and link similar (better) languages.&lt;br /&gt;
&lt;br /&gt;
==Support==&lt;br /&gt;
Adobe Director has a complete API for all Phidgets devices, and code samples for PhidgetInterfaceKit devices.&lt;br /&gt;
&lt;br /&gt;
For a complete list of our supported languages and their support status, [[Levels of Support|click here]].&lt;br /&gt;
&lt;br /&gt;
==Restrictions==&lt;br /&gt;
In this section, list any restrictions or limitations that this particular language may impose. For example, incompatibility with certain operating systems.&lt;br /&gt;
&lt;br /&gt;
==Development Environments and Compilers==&lt;br /&gt;
&lt;br /&gt;
Describe each major compiler and notable differences or important information. (eg. framework versions) If there are known issues/workarounds mention them and link to the corresponding issue at the bottom of the page. &lt;br /&gt;
&lt;br /&gt;
==Quick Downloads==&lt;br /&gt;
Before you can run your program, you need to set up the proper environment and get the necessary files off the Phidgets website. &lt;br /&gt;
Visit the drivers section at www.phidgets.com and get the latest:&lt;br /&gt;
* [http://www.phidgets.com/drivers.php Phidget Framework]&lt;br /&gt;
You will need the Phidget Framework to use and to program with Phidgets. We also recommend that you download the following reference materials:&lt;br /&gt;
* [http://www.phidgets.com/documentation/COM_API_Manual.pdf API Manual]&lt;br /&gt;
* [http://www.phidgets.com/downloads/examples/AdobeDirector_2.1.8.20110615.zip Adobe Director sample code]&lt;br /&gt;
* You can find a high level discussion about programming with Phidgets in general on the [[General API]] page. &lt;br /&gt;
* The [[Device Functionality]] page explains the general operational information for your device. &lt;br /&gt;
&lt;br /&gt;
You may want to have these pages open while working through these instructions.&lt;br /&gt;
&lt;br /&gt;
==Getting Started==&lt;br /&gt;
&lt;br /&gt;
This tutorial was written for Adobe Director 11.5 in Lingo and assumes its use. Other versions of director should work as well, and each would be set up in a similar manner. &lt;br /&gt;
First launch Director and generate a new movie file with a descriptive name such as PhidgetTest. &lt;br /&gt;
Next, insert an ActiveX control (Insert | Control | ActiveX...) and add the “PhidgetInterfaceKit Class”. &lt;br /&gt;
&lt;br /&gt;
The Phidget object will be added to your cast, and you can then drag and drop it into the stage to create a sprite for it.&lt;br /&gt;
Add a field control to your movie (Insert | Control | Field) for the purpose of capturing some simple output, as well as a button (Insert | Control | Button) labelled “Open” to get things started.&lt;br /&gt;
&lt;br /&gt;
[[Image:Getting_Started_Director.gif‎|border]]&lt;br /&gt;
&lt;br /&gt;
===Coding For Your Phidget===&lt;br /&gt;
&lt;br /&gt;
In this tutorial, the Phidget ActiveX object is assumed to be sprite 1 and the text field was given the member name “OutputField” to help distinguish it from the other objects. &lt;br /&gt;
By double clicking an ActiveX object, Director will fully list its functionality. &lt;br /&gt;
In Lingo, you can apply the functionality for an object’s sprite through CallStrings. &lt;br /&gt;
The object name for any type of Phidget is also listed in the API manual. &lt;br /&gt;
Every type of Phidget also shares some functionality from the base Phidget class.&lt;br /&gt;
&lt;br /&gt;
===Connecting to the Phidget===&lt;br /&gt;
&lt;br /&gt;
The program can try to connect to the Phidget through a call to open. Open will continuously try to connect to a Phidget, based on the parameters given, even trying to reconnect if it gets disconnected. &lt;br /&gt;
This means that simply calling open does not guarantee you can use the Phidget immediately. &lt;br /&gt;
We can account for a connection by using event driven programming and tracking the AttachEvents and DetachEvents, or by calling WaitForAttachment. &lt;br /&gt;
WaitForAttachment will block indefinitely until a connection is made to the Phidget, or an optional timeout is exceeded. &lt;br /&gt;
Here, the Phidget is opened on clicking the Open button inside the mouseUp event.&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=actionscript&amp;gt;&lt;br /&gt;
 on mouseUp me&lt;br /&gt;
     sprite(1).CallString(&amp;quot;Open()&amp;quot;)&lt;br /&gt;
     sprite(1).CallString(&amp;quot;WaitForAttachment(3000)&amp;quot;)&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The different parameters and open calls can be used to open the first Phidget of a type it can find, open based on a serial number, or even open across the network. &lt;br /&gt;
The API manual lists all of the available modes that open provides. &lt;br /&gt;
One important thing to remember is that when working with Phidgets, a local connection will reserve the device until closed. &lt;br /&gt;
This prevents any other instances from retrieving data from the Phidget, including other programs. &lt;br /&gt;
The one connection per device limit does not apply when exclusively using the Phidget Webservice.&lt;br /&gt;
You can use CallString(“Close”) at any time outside of the Phidget’s own event handlers to close the connection. &lt;br /&gt;
&lt;br /&gt;
===Event Driven Programming===&lt;br /&gt;
&lt;br /&gt;
We recommend the use of event driven programming when working with Phidgets. &lt;br /&gt;
This allows the program to execute other tasks until the Phidget fires a new event. &lt;br /&gt;
In Adobe director, you can hook an event handler inside a script for the Phidget object with the following code:  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=actionscript&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 on OnSensorChange(Index, SensorValue) me&lt;br /&gt;
      member(&amp;quot;OutputField&amp;quot;).text = string(Index) &amp;amp; &amp;quot;: &amp;quot; &amp;amp; string(SensorValue)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this method, the code inside OnSensorChange will get executed every time the InterfaceKit reports a change on one of its analog inputs. &lt;br /&gt;
Some events such as OnAttach and OnDetach belong to a base Phidget object and are common to all types of Phidgets. &lt;br /&gt;
Please refer to the API manual for a full list of events and their usage. &lt;br /&gt;
&lt;br /&gt;
===Working directly with the Phidget===&lt;br /&gt;
&lt;br /&gt;
Some values can be directly read and set on the Phidget, and inside polling loops used as an alternative to event driven programming. &lt;br /&gt;
Simply use the CallString such as SensorValue(Index) or OutputState(Index, OutputState) for InterfaceKits.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=actionscript&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 sprite(1).CallString(&amp;quot;OutputState(0,1)&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Working with multiple Phidgets===&lt;br /&gt;
&lt;br /&gt;
Multiple Phidgets of the same type can easily be run inside the same program. &lt;br /&gt;
In our case, it requires another PhidgetInterfaceKit ActiveX object to be created and placed. &lt;br /&gt;
The new object can then be set up, opened and used in the same process as the previous one. &lt;br /&gt;
If the application needs to distinguish between the devices, open can be called with the serial number of a specific Phidget.&lt;br /&gt;
&lt;br /&gt;
===Other Phidgets===&lt;br /&gt;
&lt;br /&gt;
The design given in this document can also be followed for almost all Phidgets. &lt;br /&gt;
For example, if you were using a PhidgetRFID instead of an Interfacekit, you would place a PhidgetRFID ActiveX object instead of a PhidgetInterfaceKit. &lt;br /&gt;
The methods and events available would change but they can be accessed in a similar manner.&lt;br /&gt;
&lt;br /&gt;
==Building your Project==&lt;br /&gt;
Describe the different ways a project could be built using this language.&lt;br /&gt;
&lt;br /&gt;
==Common Problems and Solutions/Workarounds==&lt;br /&gt;
Here you can put various frequent problems and our recommended solutions.&lt;/div&gt;</summary>
		<author><name>192.168.3.159</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=Language_-_AutoIt&amp;diff=9360</id>
		<title>Language - AutoIt</title>
		<link rel="alternate" type="text/html" href="https://www.phidgets.com/docs21/index.php?title=Language_-_AutoIt&amp;diff=9360"/>
		<updated>2011-11-14T15:39:50Z</updated>

		<summary type="html">&lt;p&gt;192.168.3.159: /* Drivers, Libraries and Resources */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Preamble about the language and its general strengths and weaknesses.&lt;br /&gt;
&lt;br /&gt;
==Assessment for use with Phidgets==&lt;br /&gt;
Our honest opinion on how well this language is suited to controlling Phidgets. If it is a poor choice, suggest and link similar (better) languages.&lt;br /&gt;
&lt;br /&gt;
==Support==&lt;br /&gt;
AutoIt has a complete API for all Phidgets devices, but no sample code at this time.&lt;br /&gt;
&lt;br /&gt;
For a complete list of our supported languages and their support status, [[Levels of Support|click here]]&lt;br /&gt;
&lt;br /&gt;
==Restrictions==&lt;br /&gt;
In this section, list any restrictions or limitations that this particular language may impose. For example, incompatibility with certain operating systems.&lt;br /&gt;
&lt;br /&gt;
==Development Environments and Compilers==&lt;br /&gt;
&lt;br /&gt;
Describe each major compiler and notable differences or important information. (eg. framework versions) If there are known issues/workarounds mention them and link to the corresponding issue at the bottom of the page. &lt;br /&gt;
&lt;br /&gt;
==Quick Links==&lt;br /&gt;
Before you can run your program, you need to set up the proper environment and get the necessary files off the Phidgets website. &lt;br /&gt;
Visit the drivers section at www.phidgets.com and get the latest:&lt;br /&gt;
* [http://www.phidgets.com/drivers.php Phidget Framework]&lt;br /&gt;
You will need the Phidget Framework to use and to program with Phidgets. We also recommend that you download the following reference materials:&lt;br /&gt;
* [http://www.phidgets.com/documentation/COM_API_Manual.pdf API Manual]&lt;br /&gt;
* At this time, we do not have sample code available for AutoIt.&lt;br /&gt;
* You can find a high level discussion about programming with Phidgets in general on the [[General API]] page. &lt;br /&gt;
* The [[Device Functionality]] page explains the general operational information for your device. &lt;br /&gt;
&lt;br /&gt;
You may want to have these pages open while working through these instructions.&lt;br /&gt;
&lt;br /&gt;
==Getting Started==&lt;br /&gt;
&lt;br /&gt;
Applications using Phidgets can be developed in AutoIt v3 through the COM API and this tutorial assumes its use. &lt;br /&gt;
The Phidget framework will register the necessary .dlls for you. To begin, create a new AutoIt script file and open it with your preferred editor. &lt;br /&gt;
Then, create a simple user interface to work with and then place an input control for the purpose of capturing some simple output.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=autoit&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  #include &amp;lt;GUIConstantsEx.au3&amp;gt;&lt;br /&gt;
  GUICreate(&amp;quot;Phidget Test&amp;quot;)&lt;br /&gt;
  $InputControl = GUICtrlCreateInput(&amp;quot;&amp;quot;, 20, 40, 160)&lt;br /&gt;
  GUISetState(@SW_SHOW)&lt;br /&gt;
  ;Phidget initialization code goes here&lt;br /&gt;
  Do&lt;br /&gt;
     $msg = GUIGetMsg()&lt;br /&gt;
  Until $msg = $GUI_EVENT_CLOSE&lt;br /&gt;
  ;Phidget Event Handlers go here&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Coding For Your Phidget===&lt;br /&gt;
&lt;br /&gt;
Before you can use the Phidget, you must create the object from the Phidget21COM library at initialization. &lt;br /&gt;
This can be accomplished through a call to ObjCreate. For example, we can declare and create a PhidgetInterfaceKit with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=autoit&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $oPhid1 = ObjCreate(&amp;quot;Phidget21COM.PhidgetInterfacekit&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The object name for any type of Phidget is listed in the API manual. &lt;br /&gt;
Every type of Phidget also shares some functionality from the base Phidget class.&lt;br /&gt;
&lt;br /&gt;
===Connecting to the Phidget===&lt;br /&gt;
&lt;br /&gt;
The program can try to connect to the Phidget through a call to open. &lt;br /&gt;
Open will continuously try to connect to a Phidget, based on the parameters given, even trying to reconnect if it gets disconnected. &lt;br /&gt;
This means that simply calling open does not guarantee you can use the Phidget immediately. &lt;br /&gt;
We can account for a connection by using event driven programming and tracking the AttachEvents and DetachEvents, or by calling WaitForAttachment. &lt;br /&gt;
WaitForAttachment will block indefinitely until a connection is made to the Phidget, or an optional timeout is exceeded.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=autoit&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $oPhid1.Open()&lt;br /&gt;
  $oPhid1.WaitForAttachment(3000)&lt;br /&gt;
  If NOT $oPhid1.IsAttached Then&lt;br /&gt;
     MsgBox(0, &amp;quot;Error&amp;quot;, &amp;quot;Phidget Device not attached&amp;quot;)&lt;br /&gt;
  Exit&lt;br /&gt;
  EndIf&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The different parameters and open calls can be used to open the first Phidget of a type it can find, open based on a serial number, or even open across the network. &lt;br /&gt;
The API manual lists all of the available modes that open provides. &lt;br /&gt;
One important thing to remember is that when working with Phidgets, a local connection will reserve the device until closed. &lt;br /&gt;
This prevents any other instances from retrieving data from the Phidget, including other programs. &lt;br /&gt;
The one connection per device limit does not apply when exclusively using the Phidget Webservice.&lt;br /&gt;
&lt;br /&gt;
===Event Driven Programming===&lt;br /&gt;
&lt;br /&gt;
We recommend the use of event driven programming when working with Phidgets. &lt;br /&gt;
This allows the program to execute other tasks until the Phidget generates a new event. &lt;br /&gt;
In AutoIt, you enable event handlers for a Phidget at initialization with the following line:  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=autoit&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $oPhidEvents = ObjEvent($oPhid1, &amp;quot;phid1_&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
AutoIt will use the phidl1_ prefix we declared when looking for the handler to execute. &lt;br /&gt;
You can define the handler functions for events such as OnSensorChange or Attached elsewhere in your code:&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=autoit&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
  Func phid1_OnSensorChange($Index, $SensorValue)&lt;br /&gt;
     GUICtrlSetData($InputControl, $SensorValue)&lt;br /&gt;
  EndFunc &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this method, the code inside phid1_OnSensorChange will get executed every time the PhidgetInterfaceKit reports a change on one of its analog inputs. &lt;br /&gt;
Some events such as Attach and Detach belong to the base Phidget object and thus are common to all types of Phidgets. &lt;br /&gt;
Please refer to the API manual for a full list of events and their usage.&lt;br /&gt;
&lt;br /&gt;
===Working directly with the Phidget===&lt;br /&gt;
&lt;br /&gt;
Some values can be directly read and set on the Phidget, and inside polling loops used as an alternative to event driven programming. &lt;br /&gt;
Simply use the instance properties such as SensorValue(Index as Long) or OutputState(Index as Long) for PhidgetInterfaceKits.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=autoit&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $oPhid1.OutputState(0) = &amp;quot;true&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that when setting booleans on the Phidget, it must be encapsulated in quotes. &lt;br /&gt;
Alternatively, you can usually use the integer value 0 for false and 1 for true. &lt;br /&gt;
&lt;br /&gt;
===Working with multiple Phidgets===&lt;br /&gt;
&lt;br /&gt;
Multiple Phidgets of the same type can easily be run inside the same program. &lt;br /&gt;
In our case, it requires another PhidgetInterfaceKit object to be defined and initialized. &lt;br /&gt;
The new object can then be set up, opened and used in the same process as the previous one. &lt;br /&gt;
If the application needs to distinguish between the devices, open can be called with the serial number of a specific Phidget.&lt;br /&gt;
&lt;br /&gt;
===Other Phidgets===&lt;br /&gt;
&lt;br /&gt;
The design given in this document can also be followed for almost all Phidgets. For example, if you &lt;br /&gt;
were using a PhidgetRFID instead of an PhidgetInterfacekit, you would declare a PhidgetRFID object &lt;br /&gt;
instead of a PhidgetInterfaceKit. The methods and events available would change but they can be &lt;br /&gt;
accessed in a similar manner.&lt;br /&gt;
&lt;br /&gt;
==Building your Project==&lt;br /&gt;
Describe the different ways a project could be built using this language.&lt;br /&gt;
&lt;br /&gt;
==Common Problems and Solutions/Workarounds==&lt;br /&gt;
Here you can put various frequent problems and our recommended solutions.&lt;/div&gt;</summary>
		<author><name>192.168.3.159</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=Language_-_Applescript&amp;diff=9359</id>
		<title>Language - Applescript</title>
		<link rel="alternate" type="text/html" href="https://www.phidgets.com/docs21/index.php?title=Language_-_Applescript&amp;diff=9359"/>
		<updated>2011-11-14T15:36:34Z</updated>

		<summary type="html">&lt;p&gt;192.168.3.159: /* Drivers, Libraries and Resources */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Applescript is a scripting language for Mac OSX designed primarily for interfacing between applications. &lt;br /&gt;
&lt;br /&gt;
==Assessment for use with Phidgets==&lt;br /&gt;
Our honest opinion on how well this language is suited to controlling Phidgets. If it is a poor choice, suggest and link similar (better) languages.&lt;br /&gt;
&lt;br /&gt;
==Support==&lt;br /&gt;
Applescript has a complete API and sample code for all Phidgets devices.&lt;br /&gt;
&lt;br /&gt;
For a complete list of our supported languages and their support status, [[Levels of Support|click here]].&lt;br /&gt;
&lt;br /&gt;
==Restrictions==&lt;br /&gt;
In this section, list any restrictions or limitations that this particular language may impose. For example, incompatibility with certain operating systems.&lt;br /&gt;
&lt;br /&gt;
==Development Environments and Compilers==&lt;br /&gt;
&lt;br /&gt;
Describe each major compiler and notable differences or important information. (eg. framework versions) If there are known issues/workarounds mention them and link to the corresponding issue at the bottom of the page. &lt;br /&gt;
&lt;br /&gt;
==Quick Links==&lt;br /&gt;
Before you can run your program, you need to set up the proper environment and get the necessary files off the Phidgets website. &lt;br /&gt;
Visit the drivers section at www.phidgets.com and get the latest:&lt;br /&gt;
* [http://www.phidgets.com/drivers.php Phidget Framework]&lt;br /&gt;
You will need the Phidget Framework to use and to program with Phidgets. We also recommend that you download the following reference materials:&lt;br /&gt;
* API Manual (Link to API download)&lt;br /&gt;
* API Reference (Link to online API reference (if applicable))&lt;br /&gt;
* Example Programs written in this language&lt;br /&gt;
* You can find a high level discussion about programming with Phidgets in general on the [[General API]] page. &lt;br /&gt;
* The [[Device Functionality]] page explains the general operational information for your device. &lt;br /&gt;
&lt;br /&gt;
You may want to have these pages open while working through these instructions.&lt;br /&gt;
&lt;br /&gt;
==Getting Started==&lt;br /&gt;
The Phidget examples were written using AppleScript 2.1.2 under AppleScript Editor 2.3, and this tutorial assumes their use. Other versions and development environments should work as well and would be set up in a similar manner.&lt;br /&gt;
&lt;br /&gt;
*First, open the AppleScript editor to create a new script.&lt;br /&gt;
*Coding with Phidgets is made possible by the interaction of Apple Events between AppleScript and • the PhidgetsOSA application. Type the following to interact with PhidgetsOSA:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=applescript&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  tell application &amp;quot;PhidgetsOSA&amp;quot;&lt;br /&gt;
  end tell&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The project now has access to Phidgets and we are ready to begin coding. For the rest of this document, unless otherwise stated, it will be assumed that all code will be typed inside this tell block.&lt;br /&gt;
&lt;br /&gt;
===Coding For Your Phidget===&lt;br /&gt;
A Phidget object will need to be declared. For example, we can declare a PhidgetInterfaceKit:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=applescript&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  set ifkit to make new phidget interfacekit&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
The object name for any type of Phidget is listed in the PhidgetsOSA dictionary. Every type of Phidget also inherits functionality from the Phidget base class.&lt;br /&gt;
&lt;br /&gt;
===Connecting to the Phidget===&lt;br /&gt;
&lt;br /&gt;
Next, the Phidget object needs to be initialized and the program needs to try and connect to the Phidget through a call to open. &lt;br /&gt;
Open will tell the program to continuously try to connect to a Phidget, based on the parameters given, even trying to reconnect if it gets disconnected. &lt;br /&gt;
This means that simply calling open does not guarantee you can use the Phidget immediately. &lt;br /&gt;
We can handle this by using event driven programming and tracking the Attach Events and Detach Events, or by specifying the wait parameter. &lt;br /&gt;
The wait parameter will block for a certain amount of time until a connection is made to the Phidget. For example, we can connect to a PhidgetInterfaceKit with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=applescript&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  tell ifkit to open&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The different types of open can be used with parameters to try and get the first device it can find, open based on its serial number, or even open across the network. &lt;br /&gt;
For more information on connecting across a network, please see the &amp;quot;Working with Phidget WebService&amp;quot; guide on the programming section at www.phidgets.com. &lt;br /&gt;
The PhidgetsOSA dictionary lists all of the available modes that open provides. &lt;br /&gt;
Examples of the usage of different types of open are listed below:&lt;br /&gt;
&lt;br /&gt;
We can tell the ifkit to block for 5000ms until a connection has been made to the PhidgetInterfaceKit with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=applescript&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  tell ifkit to open wait 1000 --wait for 5000ms&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can also connect to a PhidgetInterfaceKit over the WebService with a serial number of 99999 on a server with an IP Address of 192.168.3.180 and a port that is opened on 5001 with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=applescript&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  tell ifkit to open serial number 99999 server address &amp;quot;192.168.3.180&amp;quot; server port 5001&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is also possible to connect using the server id. For example, we can connect to a PhidgetInterfaceKit on a password protected server with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=applescript&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  tell ifkit to open server id &amp;quot;TestMac&amp;quot; password &amp;quot;pw&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At the end of your script, don’t forget to call close to free any locks on the Phidget.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=applescript&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  tell ifkit to close&lt;br /&gt;
  delete ifkit&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Phidgets can also be freed from the [[#PhidgetsOSA Menu Bar|PhidgetsOSA Menu Bar]].&lt;br /&gt;
&lt;br /&gt;
===Event Driven Programming===&lt;br /&gt;
We recommend the use of event driven programming when working with Phidgets. &lt;br /&gt;
We can hook an event handler at loading with the following code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=applescript&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  tell ifkit to make new interfacekit sensor change handler with properties {script file:thisScript}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And after the tell block at end of the script, the callback method is defined as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=applescript&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  using terms from application &amp;quot;PhidgetsOSA&amp;quot;&lt;br /&gt;
    on interfacekit sensor changed ind to val on ifkit&lt;br /&gt;
      log &amp;quot;Sensor Index: &amp;quot; &amp;amp; ind &amp;amp; &amp;quot;, Sensor Value: &amp;quot; &amp;amp; val&lt;br /&gt;
    end interfacekit sensor changed&lt;br /&gt;
  end using terms from&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this function, the code inside the interfacekit sensor changed handler will get executed every time the PhidgetInterfaceKit reports a change on one of its analog inputs. &lt;br /&gt;
Some events such as Attach and Detach belong to the base Phidget object and thus are common to all types of Phidgets. &lt;br /&gt;
Please refer to the PhidgetsOSA dictionary and the AppleScript examples for a list of events and their usage.&lt;br /&gt;
&lt;br /&gt;
===Working directly with the Phidget===&lt;br /&gt;
Some values can be read and sent directly to the Phidget. &lt;br /&gt;
For example, sensor values from the PhidgetInterfaceKit can be read with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=applescript&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  log &amp;quot;The first sensor has a value of: &amp;quot; &amp;amp; first interfacekit sensor&#039;s value&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These functions can be used inside a polling loop as an alternative to event driven programming.&lt;br /&gt;
&lt;br /&gt;
===Using the same Phidget in more than one Application===&lt;br /&gt;
One important thing to remember is that when working with Phidgets, a call to open will reserve the device until closed. This prevents any other instances from retrieving data from the Phidget, including other programs. &lt;br /&gt;
If your goal is to use the same Phidget among multiple AppleScripts and/or other applications, there are two approaches.&lt;br /&gt;
:1. Implement logic in the script that will use the same Phidget object if the script detects that a Phidget of the same type has already been initialized. &lt;br /&gt;
For example,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=applescript&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  if first phidget interfacekit exists then&lt;br /&gt;
    set ifkit to the first phidget interfacekit&lt;br /&gt;
  else&lt;br /&gt;
    set ifkit to make the phidget interfacekit&lt;br /&gt;
    open ifkit&lt;br /&gt;
  end if&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:2. The one connection per device limit does not apply when exclusively using the open Phidget Webservice. For more information, please see the &amp;quot;Connecting to the Phidgets&amp;quot; section of this document.&lt;br /&gt;
&lt;br /&gt;
===Working with multiple Phidgets===&lt;br /&gt;
Multiple Phidgets of the same type can easily be run inside the same program. &lt;br /&gt;
In our case, it requires another InterfaceKit instance to be defined and initialized. &lt;br /&gt;
The new instance can then be set up, opened and used in the same process as the previous one.&lt;br /&gt;
If the application needs to distinguish between the devices, open can be called with the serial number of a specific Phidget.&lt;br /&gt;
&lt;br /&gt;
===Other Phidgets===&lt;br /&gt;
The design given in this document can also be followed for almost all Phidgets. &lt;br /&gt;
For example, if you were using a PhidgetRFID instead of an PhidgetInterfacekit, you would declare an RFID object instead of an InterfaceKit. &lt;br /&gt;
The methods and events available would change but they can be accessed in a similar manner.&lt;br /&gt;
&lt;br /&gt;
===PhidgetsOSA Menu Bar===&lt;br /&gt;
[[Image:applescript_bar.jpg]]&lt;br /&gt;
&lt;br /&gt;
The PhidgetsOSA menu bar appears whenever AppleScript accesses the PhidgetsOSA application. &lt;br /&gt;
The menu bar is used to monitor the status of any accessed Phidgets. &lt;br /&gt;
&lt;br /&gt;
Additionally, it can be used to free the lock on a Phidget or quit the PhidgetsOSA application.&lt;br /&gt;
&lt;br /&gt;
==Building your Project==&lt;br /&gt;
Describe the different ways a project could be built using this language.&lt;br /&gt;
&lt;br /&gt;
==Common Problems and Solutions/Workarounds==&lt;br /&gt;
Here you can put various frequent problems and our recommended solutions.&lt;/div&gt;</summary>
		<author><name>192.168.3.159</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=Language_-_Adobe_Director&amp;diff=9355</id>
		<title>Language - Adobe Director</title>
		<link rel="alternate" type="text/html" href="https://www.phidgets.com/docs21/index.php?title=Language_-_Adobe_Director&amp;diff=9355"/>
		<updated>2011-11-14T15:29:13Z</updated>

		<summary type="html">&lt;p&gt;192.168.3.159: /* Drivers, Libraries and Resources */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Preamble about the language and its general strengths and weaknesses.&lt;br /&gt;
&lt;br /&gt;
==Assessment for use with Phidgets==&lt;br /&gt;
Our honest opinion on how well this language is suited to controlling Phidgets. If it is a poor choice, suggest and link similar (better) languages.&lt;br /&gt;
&lt;br /&gt;
==Support==&lt;br /&gt;
Adobe Director has a complete API for all Phidgets devices, and code samples for PhidgetInterfaceKit devices.&lt;br /&gt;
&lt;br /&gt;
For a complete list of our supported languages and their support status, [[Levels of Support|click here]].&lt;br /&gt;
&lt;br /&gt;
==Restrictions==&lt;br /&gt;
In this section, list any restrictions or limitations that this particular language may impose. For example, incompatibility with certain operating systems.&lt;br /&gt;
&lt;br /&gt;
==Development Environments and Compilers==&lt;br /&gt;
&lt;br /&gt;
Describe each major compiler and notable differences or important information. (eg. framework versions) If there are known issues/workarounds mention them and link to the corresponding issue at the bottom of the page. &lt;br /&gt;
&lt;br /&gt;
==Quick Links==&lt;br /&gt;
Before you can run your program, you need to set up the proper environment and get the necessary files off the Phidgets website. &lt;br /&gt;
Visit the drivers section at www.phidgets.com and get the latest:&lt;br /&gt;
* [http://www.phidgets.com/drivers.php Phidget Framework]&lt;br /&gt;
You will need the Phidget Framework to use and to program with Phidgets. We also recommend that you download the following reference materials:&lt;br /&gt;
* [http://www.phidgets.com/documentation/COM_API_Manual.pdf API Manual]&lt;br /&gt;
* [http://www.phidgets.com/downloads/examples/AdobeDirector_2.1.8.20110615.zip Adobe Director sample code]&lt;br /&gt;
* You can find a high level discussion about programming with Phidgets in general on the [[General API]] page. &lt;br /&gt;
* The [[Device Functionality]] page explains the general operational information for your device. &lt;br /&gt;
&lt;br /&gt;
You may want to have these pages open while working through these instructions.&lt;br /&gt;
&lt;br /&gt;
==Getting Started==&lt;br /&gt;
&lt;br /&gt;
This tutorial was written for Adobe Director 11.5 in Lingo and assumes its use. Other versions of director should work as well, and each would be set up in a similar manner. &lt;br /&gt;
First launch Director and generate a new movie file with a descriptive name such as PhidgetTest. &lt;br /&gt;
Next, insert an ActiveX control (Insert | Control | ActiveX...) and add the “PhidgetInterfaceKit Class”. &lt;br /&gt;
&lt;br /&gt;
The Phidget object will be added to your cast, and you can then drag and drop it into the stage to create a sprite for it.&lt;br /&gt;
Add a field control to your movie (Insert | Control | Field) for the purpose of capturing some simple output, as well as a button (Insert | Control | Button) labelled “Open” to get things started.&lt;br /&gt;
&lt;br /&gt;
[[Image:Getting_Started_Director.gif‎|border]]&lt;br /&gt;
&lt;br /&gt;
===Coding For Your Phidget===&lt;br /&gt;
&lt;br /&gt;
In this tutorial, the Phidget ActiveX object is assumed to be sprite 1 and the text field was given the member name “OutputField” to help distinguish it from the other objects. &lt;br /&gt;
By double clicking an ActiveX object, Director will fully list its functionality. &lt;br /&gt;
In Lingo, you can apply the functionality for an object’s sprite through CallStrings. &lt;br /&gt;
The object name for any type of Phidget is also listed in the API manual. &lt;br /&gt;
Every type of Phidget also shares some functionality from the base Phidget class.&lt;br /&gt;
&lt;br /&gt;
===Connecting to the Phidget===&lt;br /&gt;
&lt;br /&gt;
The program can try to connect to the Phidget through a call to open. Open will continuously try to connect to a Phidget, based on the parameters given, even trying to reconnect if it gets disconnected. &lt;br /&gt;
This means that simply calling open does not guarantee you can use the Phidget immediately. &lt;br /&gt;
We can account for a connection by using event driven programming and tracking the AttachEvents and DetachEvents, or by calling WaitForAttachment. &lt;br /&gt;
WaitForAttachment will block indefinitely until a connection is made to the Phidget, or an optional timeout is exceeded. &lt;br /&gt;
Here, the Phidget is opened on clicking the Open button inside the mouseUp event.&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=actionscript&amp;gt;&lt;br /&gt;
 on mouseUp me&lt;br /&gt;
     sprite(1).CallString(&amp;quot;Open()&amp;quot;)&lt;br /&gt;
     sprite(1).CallString(&amp;quot;WaitForAttachment(3000)&amp;quot;)&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The different parameters and open calls can be used to open the first Phidget of a type it can find, open based on a serial number, or even open across the network. &lt;br /&gt;
The API manual lists all of the available modes that open provides. &lt;br /&gt;
One important thing to remember is that when working with Phidgets, a local connection will reserve the device until closed. &lt;br /&gt;
This prevents any other instances from retrieving data from the Phidget, including other programs. &lt;br /&gt;
The one connection per device limit does not apply when exclusively using the Phidget Webservice.&lt;br /&gt;
You can use CallString(“Close”) at any time outside of the Phidget’s own event handlers to close the connection. &lt;br /&gt;
&lt;br /&gt;
===Event Driven Programming===&lt;br /&gt;
&lt;br /&gt;
We recommend the use of event driven programming when working with Phidgets. &lt;br /&gt;
This allows the program to execute other tasks until the Phidget fires a new event. &lt;br /&gt;
In Adobe director, you can hook an event handler inside a script for the Phidget object with the following code:  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=actionscript&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 on OnSensorChange(Index, SensorValue) me&lt;br /&gt;
      member(&amp;quot;OutputField&amp;quot;).text = string(Index) &amp;amp; &amp;quot;: &amp;quot; &amp;amp; string(SensorValue)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this method, the code inside OnSensorChange will get executed every time the InterfaceKit reports a change on one of its analog inputs. &lt;br /&gt;
Some events such as OnAttach and OnDetach belong to a base Phidget object and are common to all types of Phidgets. &lt;br /&gt;
Please refer to the API manual for a full list of events and their usage. &lt;br /&gt;
&lt;br /&gt;
===Working directly with the Phidget===&lt;br /&gt;
&lt;br /&gt;
Some values can be directly read and set on the Phidget, and inside polling loops used as an alternative to event driven programming. &lt;br /&gt;
Simply use the CallString such as SensorValue(Index) or OutputState(Index, OutputState) for InterfaceKits.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=actionscript&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 sprite(1).CallString(&amp;quot;OutputState(0,1)&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Working with multiple Phidgets===&lt;br /&gt;
&lt;br /&gt;
Multiple Phidgets of the same type can easily be run inside the same program. &lt;br /&gt;
In our case, it requires another PhidgetInterfaceKit ActiveX object to be created and placed. &lt;br /&gt;
The new object can then be set up, opened and used in the same process as the previous one. &lt;br /&gt;
If the application needs to distinguish between the devices, open can be called with the serial number of a specific Phidget.&lt;br /&gt;
&lt;br /&gt;
===Other Phidgets===&lt;br /&gt;
&lt;br /&gt;
The design given in this document can also be followed for almost all Phidgets. &lt;br /&gt;
For example, if you were using a PhidgetRFID instead of an Interfacekit, you would place a PhidgetRFID ActiveX object instead of a PhidgetInterfaceKit. &lt;br /&gt;
The methods and events available would change but they can be accessed in a similar manner.&lt;br /&gt;
&lt;br /&gt;
==Building your Project==&lt;br /&gt;
Describe the different ways a project could be built using this language.&lt;br /&gt;
&lt;br /&gt;
==Common Problems and Solutions/Workarounds==&lt;br /&gt;
Here you can put various frequent problems and our recommended solutions.&lt;/div&gt;</summary>
		<author><name>192.168.3.159</name></author>
	</entry>
</feed>