<?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=Djrudiak</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=Djrudiak"/>
	<link rel="alternate" type="text/html" href="https://www.phidgets.com/docs21/Special:Contributions/Djrudiak"/>
	<updated>2026-04-09T07:33:51Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.8</generator>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=Main_Page&amp;diff=19462</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="https://www.phidgets.com/docs21/index.php?title=Main_Page&amp;diff=19462"/>
		<updated>2012-05-03T15:34:25Z</updated>

		<summary type="html">&lt;p&gt;Djrudiak: /* Old Pages */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;table&amp;gt;&lt;br /&gt;
 &amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&lt;br /&gt;
__TOC__&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td valign=top align=center width=40%&amp;gt;&lt;br /&gt;
{{#widget:Google Gadget|url=http://www.calebegg.com/countdown.xml&amp;amp;amp;up_eve=end%20of%20Sprint%2018&amp;amp;amp;up_mon=5&amp;amp;amp;up_dat=11&amp;amp;amp;up_yer=2012&amp;amp;amp;synd=open&amp;amp;amp;w=200&amp;amp;amp;h=75&amp;amp;amp;title=&amp;amp;amp;lang=all&amp;amp;amp;country=ALL&amp;amp;amp;border=%23ffffff%7C3px%2C1px+solid+%23999999&amp;amp;amp;output=js|height=50}}&lt;br /&gt;
&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
==Phwiki==&lt;br /&gt;
&lt;br /&gt;
* [[Phidget Development Process]]&lt;br /&gt;
: [[Processes]]&lt;br /&gt;
: [[Standards]]&lt;br /&gt;
* [[Getting_Started_with_Phidgets|Phidgets Documentation Project]]&lt;br /&gt;
* [[Style_Guide|Documentation Style Guide]]&lt;br /&gt;
* [[Projects Status]]&lt;br /&gt;
*[[PhidgetTesting Overhaul]]&lt;br /&gt;
*[[Website Redesign Ideas]]&lt;br /&gt;
*[[Products]] - Repository for product artifacts&lt;br /&gt;
*[[Logbook Details]]&lt;br /&gt;
*[[R&amp;amp;D Specializations]]&lt;br /&gt;
*[[Phidgets Bored Room Awesomification]]&lt;br /&gt;
&lt;br /&gt;
==Internal Systems Documentation==&lt;br /&gt;
&lt;br /&gt;
[[File:trac.png|link=|alt=]] Bug Tracker for [http://sl/trac# Brian] or [http://trac/# everyone else]&lt;br /&gt;
&lt;br /&gt;
[[File:trac.png|link=|alt=]] [[How to use Trac]]&lt;br /&gt;
*[[InternalTools]] documentation.&lt;br /&gt;
*Phidgets Inc. Internal [[Network]] information.&lt;br /&gt;
*[[Phone system]]&lt;br /&gt;
*[[Product Photography]]&lt;br /&gt;
*[[OpenVPN new user HOWTO]]&lt;br /&gt;
*[[Product Keys &amp;amp; Site Logins]]&lt;br /&gt;
&lt;br /&gt;
==People&#039;s Lists of Pages==&lt;br /&gt;
&lt;br /&gt;
===Patrick===&lt;br /&gt;
&lt;br /&gt;
* [[Patrick&#039;s List]]&lt;br /&gt;
:[[Phidget21]]&lt;br /&gt;
:[[SBC]]&lt;br /&gt;
:[[SBC2]]&lt;br /&gt;
:[[Programming@Phidgets - serials and MAC addresses]]&lt;br /&gt;
:[[iPhone Developer Program]]&lt;br /&gt;
:[[Release Build Documentation]]&lt;br /&gt;
:[[Delphi]]&lt;br /&gt;
:[[LTIB]]&lt;br /&gt;
&lt;br /&gt;
===Erik===&lt;br /&gt;
*[[Erik&#039;s Logbook]]&lt;br /&gt;
*[[Erik&#039;s List]]&lt;br /&gt;
:[[Erik&#039;s HW TODO]]&lt;br /&gt;
&lt;br /&gt;
===Fraser===&lt;br /&gt;
&lt;br /&gt;
*[[Fraser - General]]&lt;br /&gt;
*[[Fraser - NXP]]&lt;br /&gt;
*[[Fraser - Spatial]]&lt;br /&gt;
*[[NXP Getting Started]]&lt;br /&gt;
*[[Fraser - Zigbee/Bluetooth]]&lt;br /&gt;
&lt;br /&gt;
===Mike Paradis===&lt;br /&gt;
*[[Mike&#039;s List]]&lt;br /&gt;
&lt;br /&gt;
===Brian===&lt;br /&gt;
&lt;br /&gt;
===Cora===&lt;br /&gt;
&lt;br /&gt;
[[User:Cora|Cora&#039;s List]]&lt;br /&gt;
&lt;br /&gt;
===Dan J. Rudiak===&lt;br /&gt;
#&#039;&#039;&#039;Real Pages&#039;&#039;&#039;&lt;br /&gt;
#* [[Documentation_Log|Documentation Log]]&lt;br /&gt;
#&#039;&#039;&#039;Wiki Information&#039;&#039;&#039;&lt;br /&gt;
#* [[Icon Gallery]]&lt;br /&gt;
#* [[Progress Bars]]&lt;br /&gt;
#[[User:Djrudiak|Dan&#039;s List]]&lt;br /&gt;
&lt;br /&gt;
===Old Pages===&lt;br /&gt;
* [[User:Djrudiak|Dan&#039;s List]]&lt;br /&gt;
* [[Michael Shan&#039;s List]]&lt;br /&gt;
* [[Evan&#039;s List]]&lt;br /&gt;
*[[Adam&#039;s List]]&lt;br /&gt;
&lt;br /&gt;
===Leo===&lt;br /&gt;
*[[Leo&#039;s Documentation]]&lt;br /&gt;
*[[Test Lab information]]&lt;br /&gt;
*[[Internal EMC Testing Status]]&lt;br /&gt;
*[[Travel Notes]]&lt;br /&gt;
*[[Leo&#039;s Logbook]]&lt;br /&gt;
&lt;br /&gt;
== Getting started ==&lt;br /&gt;
&lt;br /&gt;
Consult the [http://meta.wikipedia.org/wiki/MediaWiki_User%27s_Guide User&#039;s Guide] for information on using the wiki software.&lt;br /&gt;
&lt;br /&gt;
* [http://www.mediawiki.org/wiki/Help:Configuration_settings Configuration settings list]&lt;br /&gt;
* [http://www.mediawiki.org/wiki/Help:FAQ MediaWiki FAQ]&lt;br /&gt;
* [http://mail.wikipedia.org/mailman/listinfo/mediawiki-announce MediaWiki release mailing list]&lt;/div&gt;</summary>
		<author><name>Djrudiak</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=Main_Page&amp;diff=19461</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="https://www.phidgets.com/docs21/index.php?title=Main_Page&amp;diff=19461"/>
		<updated>2012-05-03T15:33:46Z</updated>

		<summary type="html">&lt;p&gt;Djrudiak: /* Old Pages */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;table&amp;gt;&lt;br /&gt;
 &amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&lt;br /&gt;
__TOC__&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td valign=top align=center width=40%&amp;gt;&lt;br /&gt;
{{#widget:Google Gadget|url=http://www.calebegg.com/countdown.xml&amp;amp;amp;up_eve=end%20of%20Sprint%2018&amp;amp;amp;up_mon=5&amp;amp;amp;up_dat=11&amp;amp;amp;up_yer=2012&amp;amp;amp;synd=open&amp;amp;amp;w=200&amp;amp;amp;h=75&amp;amp;amp;title=&amp;amp;amp;lang=all&amp;amp;amp;country=ALL&amp;amp;amp;border=%23ffffff%7C3px%2C1px+solid+%23999999&amp;amp;amp;output=js|height=50}}&lt;br /&gt;
&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
==Phwiki==&lt;br /&gt;
&lt;br /&gt;
* [[Phidget Development Process]]&lt;br /&gt;
: [[Processes]]&lt;br /&gt;
: [[Standards]]&lt;br /&gt;
* [[Getting_Started_with_Phidgets|Phidgets Documentation Project]]&lt;br /&gt;
* [[Style_Guide|Documentation Style Guide]]&lt;br /&gt;
* [[Projects Status]]&lt;br /&gt;
*[[PhidgetTesting Overhaul]]&lt;br /&gt;
*[[Website Redesign Ideas]]&lt;br /&gt;
*[[Products]] - Repository for product artifacts&lt;br /&gt;
*[[Logbook Details]]&lt;br /&gt;
*[[R&amp;amp;D Specializations]]&lt;br /&gt;
*[[Phidgets Bored Room Awesomification]]&lt;br /&gt;
&lt;br /&gt;
==Internal Systems Documentation==&lt;br /&gt;
&lt;br /&gt;
[[File:trac.png|link=|alt=]] Bug Tracker for [http://sl/trac# Brian] or [http://trac/# everyone else]&lt;br /&gt;
&lt;br /&gt;
[[File:trac.png|link=|alt=]] [[How to use Trac]]&lt;br /&gt;
*[[InternalTools]] documentation.&lt;br /&gt;
*Phidgets Inc. Internal [[Network]] information.&lt;br /&gt;
*[[Phone system]]&lt;br /&gt;
*[[Product Photography]]&lt;br /&gt;
*[[OpenVPN new user HOWTO]]&lt;br /&gt;
*[[Product Keys &amp;amp; Site Logins]]&lt;br /&gt;
&lt;br /&gt;
==People&#039;s Lists of Pages==&lt;br /&gt;
&lt;br /&gt;
===Patrick===&lt;br /&gt;
&lt;br /&gt;
* [[Patrick&#039;s List]]&lt;br /&gt;
:[[Phidget21]]&lt;br /&gt;
:[[SBC]]&lt;br /&gt;
:[[SBC2]]&lt;br /&gt;
:[[Programming@Phidgets - serials and MAC addresses]]&lt;br /&gt;
:[[iPhone Developer Program]]&lt;br /&gt;
:[[Release Build Documentation]]&lt;br /&gt;
:[[Delphi]]&lt;br /&gt;
:[[LTIB]]&lt;br /&gt;
&lt;br /&gt;
===Erik===&lt;br /&gt;
*[[Erik&#039;s Logbook]]&lt;br /&gt;
*[[Erik&#039;s List]]&lt;br /&gt;
:[[Erik&#039;s HW TODO]]&lt;br /&gt;
&lt;br /&gt;
===Fraser===&lt;br /&gt;
&lt;br /&gt;
*[[Fraser - General]]&lt;br /&gt;
*[[Fraser - NXP]]&lt;br /&gt;
*[[Fraser - Spatial]]&lt;br /&gt;
*[[NXP Getting Started]]&lt;br /&gt;
*[[Fraser - Zigbee/Bluetooth]]&lt;br /&gt;
&lt;br /&gt;
===Mike Paradis===&lt;br /&gt;
*[[Mike&#039;s List]]&lt;br /&gt;
&lt;br /&gt;
===Brian===&lt;br /&gt;
&lt;br /&gt;
===Cora===&lt;br /&gt;
&lt;br /&gt;
[[User:Cora|Cora&#039;s List]]&lt;br /&gt;
&lt;br /&gt;
===Dan J. Rudiak===&lt;br /&gt;
#&#039;&#039;&#039;Real Pages&#039;&#039;&#039;&lt;br /&gt;
#* [[Documentation_Log|Documentation Log]]&lt;br /&gt;
#&#039;&#039;&#039;Wiki Information&#039;&#039;&#039;&lt;br /&gt;
#* [[Icon Gallery]]&lt;br /&gt;
#* [[Progress Bars]]&lt;br /&gt;
#[[User:Djrudiak|Dan&#039;s List]]&lt;br /&gt;
&lt;br /&gt;
===Old Pages===&lt;br /&gt;
* [[User:Djrudiak|Dan&#039;s List]]&lt;br /&gt;
* [[Michael&#039;s List]]&lt;br /&gt;
* [[Evan&#039;s List]]&lt;br /&gt;
*[[Adam&#039;s List]]&lt;br /&gt;
&lt;br /&gt;
===Leo===&lt;br /&gt;
*[[Leo&#039;s Documentation]]&lt;br /&gt;
*[[Test Lab information]]&lt;br /&gt;
*[[Internal EMC Testing Status]]&lt;br /&gt;
*[[Travel Notes]]&lt;br /&gt;
*[[Leo&#039;s Logbook]]&lt;br /&gt;
&lt;br /&gt;
== Getting started ==&lt;br /&gt;
&lt;br /&gt;
Consult the [http://meta.wikipedia.org/wiki/MediaWiki_User%27s_Guide User&#039;s Guide] for information on using the wiki software.&lt;br /&gt;
&lt;br /&gt;
* [http://www.mediawiki.org/wiki/Help:Configuration_settings Configuration settings list]&lt;br /&gt;
* [http://www.mediawiki.org/wiki/Help:FAQ MediaWiki FAQ]&lt;br /&gt;
* [http://mail.wikipedia.org/mailman/listinfo/mediawiki-announce MediaWiki release mailing list]&lt;/div&gt;</summary>
		<author><name>Djrudiak</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=Main_Page&amp;diff=19460</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="https://www.phidgets.com/docs21/index.php?title=Main_Page&amp;diff=19460"/>
		<updated>2012-05-03T15:32:22Z</updated>

		<summary type="html">&lt;p&gt;Djrudiak: /* Dan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;table&amp;gt;&lt;br /&gt;
 &amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&lt;br /&gt;
__TOC__&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td valign=top align=center width=40%&amp;gt;&lt;br /&gt;
{{#widget:Google Gadget|url=http://www.calebegg.com/countdown.xml&amp;amp;amp;up_eve=end%20of%20Sprint%2018&amp;amp;amp;up_mon=5&amp;amp;amp;up_dat=11&amp;amp;amp;up_yer=2012&amp;amp;amp;synd=open&amp;amp;amp;w=200&amp;amp;amp;h=75&amp;amp;amp;title=&amp;amp;amp;lang=all&amp;amp;amp;country=ALL&amp;amp;amp;border=%23ffffff%7C3px%2C1px+solid+%23999999&amp;amp;amp;output=js|height=50}}&lt;br /&gt;
&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
==Phwiki==&lt;br /&gt;
&lt;br /&gt;
* [[Phidget Development Process]]&lt;br /&gt;
: [[Processes]]&lt;br /&gt;
: [[Standards]]&lt;br /&gt;
* [[Getting_Started_with_Phidgets|Phidgets Documentation Project]]&lt;br /&gt;
* [[Style_Guide|Documentation Style Guide]]&lt;br /&gt;
* [[Projects Status]]&lt;br /&gt;
*[[PhidgetTesting Overhaul]]&lt;br /&gt;
*[[Website Redesign Ideas]]&lt;br /&gt;
*[[Products]] - Repository for product artifacts&lt;br /&gt;
*[[Logbook Details]]&lt;br /&gt;
*[[R&amp;amp;D Specializations]]&lt;br /&gt;
*[[Phidgets Bored Room Awesomification]]&lt;br /&gt;
&lt;br /&gt;
==Internal Systems Documentation==&lt;br /&gt;
&lt;br /&gt;
[[File:trac.png|link=|alt=]] Bug Tracker for [http://sl/trac# Brian] or [http://trac/# everyone else]&lt;br /&gt;
&lt;br /&gt;
[[File:trac.png|link=|alt=]] [[How to use Trac]]&lt;br /&gt;
*[[InternalTools]] documentation.&lt;br /&gt;
*Phidgets Inc. Internal [[Network]] information.&lt;br /&gt;
*[[Phone system]]&lt;br /&gt;
*[[Product Photography]]&lt;br /&gt;
*[[OpenVPN new user HOWTO]]&lt;br /&gt;
*[[Product Keys &amp;amp; Site Logins]]&lt;br /&gt;
&lt;br /&gt;
==People&#039;s Lists of Pages==&lt;br /&gt;
&lt;br /&gt;
===Patrick===&lt;br /&gt;
&lt;br /&gt;
* [[Patrick&#039;s List]]&lt;br /&gt;
:[[Phidget21]]&lt;br /&gt;
:[[SBC]]&lt;br /&gt;
:[[SBC2]]&lt;br /&gt;
:[[Programming@Phidgets - serials and MAC addresses]]&lt;br /&gt;
:[[iPhone Developer Program]]&lt;br /&gt;
:[[Release Build Documentation]]&lt;br /&gt;
:[[Delphi]]&lt;br /&gt;
:[[LTIB]]&lt;br /&gt;
&lt;br /&gt;
===Erik===&lt;br /&gt;
*[[Erik&#039;s Logbook]]&lt;br /&gt;
*[[Erik&#039;s List]]&lt;br /&gt;
:[[Erik&#039;s HW TODO]]&lt;br /&gt;
&lt;br /&gt;
===Fraser===&lt;br /&gt;
&lt;br /&gt;
*[[Fraser - General]]&lt;br /&gt;
*[[Fraser - NXP]]&lt;br /&gt;
*[[Fraser - Spatial]]&lt;br /&gt;
*[[NXP Getting Started]]&lt;br /&gt;
*[[Fraser - Zigbee/Bluetooth]]&lt;br /&gt;
&lt;br /&gt;
===Mike Paradis===&lt;br /&gt;
*[[Mike&#039;s List]]&lt;br /&gt;
&lt;br /&gt;
===Brian===&lt;br /&gt;
&lt;br /&gt;
===Cora===&lt;br /&gt;
&lt;br /&gt;
[[User:Cora|Cora&#039;s List]]&lt;br /&gt;
&lt;br /&gt;
===Dan J. Rudiak===&lt;br /&gt;
#&#039;&#039;&#039;Real Pages&#039;&#039;&#039;&lt;br /&gt;
#* [[Documentation_Log|Documentation Log]]&lt;br /&gt;
#&#039;&#039;&#039;Wiki Information&#039;&#039;&#039;&lt;br /&gt;
#* [[Icon Gallery]]&lt;br /&gt;
#* [[Progress Bars]]&lt;br /&gt;
#[[User:Djrudiak|Dan&#039;s List]]&lt;br /&gt;
&lt;br /&gt;
===Old Pages===&lt;br /&gt;
* [[Michael&#039;s List]]&lt;br /&gt;
* [[Evan&#039;s List]]&lt;br /&gt;
*[[Adam&#039;s List]]&lt;br /&gt;
&lt;br /&gt;
===Leo===&lt;br /&gt;
*[[Leo&#039;s Documentation]]&lt;br /&gt;
*[[Test Lab information]]&lt;br /&gt;
*[[Internal EMC Testing Status]]&lt;br /&gt;
*[[Travel Notes]]&lt;br /&gt;
*[[Leo&#039;s Logbook]]&lt;br /&gt;
&lt;br /&gt;
== Getting started ==&lt;br /&gt;
&lt;br /&gt;
Consult the [http://meta.wikipedia.org/wiki/MediaWiki_User%27s_Guide User&#039;s Guide] for information on using the wiki software.&lt;br /&gt;
&lt;br /&gt;
* [http://www.mediawiki.org/wiki/Help:Configuration_settings Configuration settings list]&lt;br /&gt;
* [http://www.mediawiki.org/wiki/Help:FAQ MediaWiki FAQ]&lt;br /&gt;
* [http://mail.wikipedia.org/mailman/listinfo/mediawiki-announce MediaWiki release mailing list]&lt;/div&gt;</summary>
		<author><name>Djrudiak</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=Main_Page&amp;diff=19459</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="https://www.phidgets.com/docs21/index.php?title=Main_Page&amp;diff=19459"/>
		<updated>2012-05-03T15:32:02Z</updated>

		<summary type="html">&lt;p&gt;Djrudiak: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;table&amp;gt;&lt;br /&gt;
 &amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&lt;br /&gt;
__TOC__&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td valign=top align=center width=40%&amp;gt;&lt;br /&gt;
{{#widget:Google Gadget|url=http://www.calebegg.com/countdown.xml&amp;amp;amp;up_eve=end%20of%20Sprint%2018&amp;amp;amp;up_mon=5&amp;amp;amp;up_dat=11&amp;amp;amp;up_yer=2012&amp;amp;amp;synd=open&amp;amp;amp;w=200&amp;amp;amp;h=75&amp;amp;amp;title=&amp;amp;amp;lang=all&amp;amp;amp;country=ALL&amp;amp;amp;border=%23ffffff%7C3px%2C1px+solid+%23999999&amp;amp;amp;output=js|height=50}}&lt;br /&gt;
&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
==Phwiki==&lt;br /&gt;
&lt;br /&gt;
* [[Phidget Development Process]]&lt;br /&gt;
: [[Processes]]&lt;br /&gt;
: [[Standards]]&lt;br /&gt;
* [[Getting_Started_with_Phidgets|Phidgets Documentation Project]]&lt;br /&gt;
* [[Style_Guide|Documentation Style Guide]]&lt;br /&gt;
* [[Projects Status]]&lt;br /&gt;
*[[PhidgetTesting Overhaul]]&lt;br /&gt;
*[[Website Redesign Ideas]]&lt;br /&gt;
*[[Products]] - Repository for product artifacts&lt;br /&gt;
*[[Logbook Details]]&lt;br /&gt;
*[[R&amp;amp;D Specializations]]&lt;br /&gt;
*[[Phidgets Bored Room Awesomification]]&lt;br /&gt;
&lt;br /&gt;
==Internal Systems Documentation==&lt;br /&gt;
&lt;br /&gt;
[[File:trac.png|link=|alt=]] Bug Tracker for [http://sl/trac# Brian] or [http://trac/# everyone else]&lt;br /&gt;
&lt;br /&gt;
[[File:trac.png|link=|alt=]] [[How to use Trac]]&lt;br /&gt;
*[[InternalTools]] documentation.&lt;br /&gt;
*Phidgets Inc. Internal [[Network]] information.&lt;br /&gt;
*[[Phone system]]&lt;br /&gt;
*[[Product Photography]]&lt;br /&gt;
*[[OpenVPN new user HOWTO]]&lt;br /&gt;
*[[Product Keys &amp;amp; Site Logins]]&lt;br /&gt;
&lt;br /&gt;
==People&#039;s Lists of Pages==&lt;br /&gt;
&lt;br /&gt;
===Patrick===&lt;br /&gt;
&lt;br /&gt;
* [[Patrick&#039;s List]]&lt;br /&gt;
:[[Phidget21]]&lt;br /&gt;
:[[SBC]]&lt;br /&gt;
:[[SBC2]]&lt;br /&gt;
:[[Programming@Phidgets - serials and MAC addresses]]&lt;br /&gt;
:[[iPhone Developer Program]]&lt;br /&gt;
:[[Release Build Documentation]]&lt;br /&gt;
:[[Delphi]]&lt;br /&gt;
:[[LTIB]]&lt;br /&gt;
&lt;br /&gt;
===Erik===&lt;br /&gt;
*[[Erik&#039;s Logbook]]&lt;br /&gt;
*[[Erik&#039;s List]]&lt;br /&gt;
:[[Erik&#039;s HW TODO]]&lt;br /&gt;
&lt;br /&gt;
===Fraser===&lt;br /&gt;
&lt;br /&gt;
*[[Fraser - General]]&lt;br /&gt;
*[[Fraser - NXP]]&lt;br /&gt;
*[[Fraser - Spatial]]&lt;br /&gt;
*[[NXP Getting Started]]&lt;br /&gt;
*[[Fraser - Zigbee/Bluetooth]]&lt;br /&gt;
&lt;br /&gt;
===Mike Paradis===&lt;br /&gt;
*[[Mike&#039;s List]]&lt;br /&gt;
&lt;br /&gt;
===Brian===&lt;br /&gt;
&lt;br /&gt;
===Cora===&lt;br /&gt;
&lt;br /&gt;
[[User:Cora|Cora&#039;s List]]&lt;br /&gt;
&lt;br /&gt;
===Dan===&lt;br /&gt;
#&#039;&#039;&#039;Real Pages&#039;&#039;&#039;&lt;br /&gt;
#* [[Documentation_Log|Documentation Log]]&lt;br /&gt;
#&#039;&#039;&#039;Wiki Information&#039;&#039;&#039;&lt;br /&gt;
#* [[Icon Gallery]]&lt;br /&gt;
#* [[Progress Bars]]&lt;br /&gt;
#[[User:Djrudiak|Dan&#039;s List]]&lt;br /&gt;
&lt;br /&gt;
===Old Pages===&lt;br /&gt;
* [[Michael&#039;s List]]&lt;br /&gt;
* [[Evan&#039;s List]]&lt;br /&gt;
*[[Adam&#039;s List]]&lt;br /&gt;
&lt;br /&gt;
===Leo===&lt;br /&gt;
*[[Leo&#039;s Documentation]]&lt;br /&gt;
*[[Test Lab information]]&lt;br /&gt;
*[[Internal EMC Testing Status]]&lt;br /&gt;
*[[Travel Notes]]&lt;br /&gt;
*[[Leo&#039;s Logbook]]&lt;br /&gt;
&lt;br /&gt;
== Getting started ==&lt;br /&gt;
&lt;br /&gt;
Consult the [http://meta.wikipedia.org/wiki/MediaWiki_User%27s_Guide User&#039;s Guide] for information on using the wiki software.&lt;br /&gt;
&lt;br /&gt;
* [http://www.mediawiki.org/wiki/Help:Configuration_settings Configuration settings list]&lt;br /&gt;
* [http://www.mediawiki.org/wiki/Help:FAQ MediaWiki FAQ]&lt;br /&gt;
* [http://mail.wikipedia.org/mailman/listinfo/mediawiki-announce MediaWiki release mailing list]&lt;/div&gt;</summary>
		<author><name>Djrudiak</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=Main_Page&amp;diff=19455</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="https://www.phidgets.com/docs21/index.php?title=Main_Page&amp;diff=19455"/>
		<updated>2012-05-02T21:00:20Z</updated>

		<summary type="html">&lt;p&gt;Djrudiak: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;table&amp;gt;&lt;br /&gt;
 &amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Phwiki==&lt;br /&gt;
&lt;br /&gt;
* [[Phidget Development Process]]&lt;br /&gt;
: [[Processes]]&lt;br /&gt;
: [[Standards]]&lt;br /&gt;
* [[Getting_Started_with_Phidgets|Phidgets Documentation Project]]&lt;br /&gt;
* [[Style_Guide|Documentation Style Guide]]&lt;br /&gt;
* [[Projects Status]]&lt;br /&gt;
*[[PhidgetTesting Overhaul]]&lt;br /&gt;
*[[Website Redesign Ideas]]&lt;br /&gt;
*[[Products]] - Repository for product artifacts&lt;br /&gt;
*[[Logbook Details]]&lt;br /&gt;
*[[R&amp;amp;D Specializations]]&lt;br /&gt;
*[[Phidgets Bored Room Awesomification]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td valign=top align=center width=40%&amp;gt;&lt;br /&gt;
{{#widget:Google Gadget|url=http://www.calebegg.com/countdown.xml&amp;amp;amp;up_eve=end%20of%20Sprint%2017&amp;amp;amp;up_mon=5&amp;amp;amp;up_dat=11&amp;amp;amp;up_yer=2012&amp;amp;amp;synd=open&amp;amp;amp;w=200&amp;amp;amp;h=75&amp;amp;amp;title=&amp;amp;amp;lang=all&amp;amp;amp;country=ALL&amp;amp;amp;border=%23ffffff%7C3px%2C1px+solid+%23999999&amp;amp;amp;output=js|height=50}}&lt;br /&gt;
&lt;br /&gt;
{{#widget:Google Calendar|width=100%|id=phidgets.com_p6l4ek7ufge35mc5f6trssirl8@group.calendar.google.com|color=333333|id=en_gb.canadian#holiday@group.v.calendar.google.com|color=A32929|id=en_gb.china#holiday@group.v.calendar.google.com|color=856508|id=en_gb.usa#holiday@group.v.calendar.google.com|color=060D5E|view=AGENDA|timezone=America/Edmonton|showtitle=false|shownav=false|showdate=false|showtabs=false|showcals=false|showprint=false|showtz=false|border=false}}&lt;br /&gt;
&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Internal Systems Documentation==&lt;br /&gt;
&lt;br /&gt;
[[File:trac.png|link=|alt=]] Bug Tracker for [http://sl/trac# Brian] or [http://trac/# everyone else]&lt;br /&gt;
&lt;br /&gt;
[[File:trac.png|link=|alt=]] [[How to use Trac]]&lt;br /&gt;
*[[InternalTools]] documentation.&lt;br /&gt;
*Phidgets Inc. Internal [[Network]] information.&lt;br /&gt;
*[[Phone system]]&lt;br /&gt;
*[[Product Photography]]&lt;br /&gt;
*[[OpenVPN new user HOWTO]]&lt;br /&gt;
*[[Product Keys &amp;amp; Site Logins]]&lt;br /&gt;
&lt;br /&gt;
==People&#039;s Lists of Pages==&lt;br /&gt;
&lt;br /&gt;
===Patrick===&lt;br /&gt;
&lt;br /&gt;
* [[Patrick&#039;s List]]&lt;br /&gt;
:[[Phidget21]]&lt;br /&gt;
:[[SBC]]&lt;br /&gt;
:[[SBC2]]&lt;br /&gt;
:[[Programming@Phidgets - serials and MAC addresses]]&lt;br /&gt;
:[[iPhone Developer Program]]&lt;br /&gt;
:[[Release Build Documentation]]&lt;br /&gt;
:[[Delphi]]&lt;br /&gt;
:[[LTIB]]&lt;br /&gt;
&lt;br /&gt;
===Erik===&lt;br /&gt;
*[[Erik&#039;s Logbook]]&lt;br /&gt;
*[[Erik&#039;s List]]&lt;br /&gt;
:[[Erik&#039;s HW TODO]]&lt;br /&gt;
&lt;br /&gt;
===Fraser===&lt;br /&gt;
&lt;br /&gt;
*[[Fraser - General]]&lt;br /&gt;
*[[Fraser - NXP]]&lt;br /&gt;
*[[Fraser - Spatial]]&lt;br /&gt;
*[[NXP Getting Started]]&lt;br /&gt;
*[[Fraser - Zigbee/Bluetooth]]&lt;br /&gt;
&lt;br /&gt;
===Mike Paradis===&lt;br /&gt;
*[[Mike&#039;s List]]&lt;br /&gt;
&lt;br /&gt;
===Brian===&lt;br /&gt;
&lt;br /&gt;
===Cora===&lt;br /&gt;
&lt;br /&gt;
[[User:Cora|Cora&#039;s List]]&lt;br /&gt;
&lt;br /&gt;
===Dan===&lt;br /&gt;
#&#039;&#039;&#039;Real Pages&#039;&#039;&#039;&lt;br /&gt;
#* [[Documentation_Log|Documentation Log]]&lt;br /&gt;
#&#039;&#039;&#039;Wiki Information&#039;&#039;&#039;&lt;br /&gt;
#* [[Icon Gallery]]&lt;br /&gt;
#* [[Progress Bars]]&lt;br /&gt;
#[[User:Djrudiak|Dan&#039;s List]]&lt;br /&gt;
&lt;br /&gt;
===Old Pages===&lt;br /&gt;
* [[Michael&#039;s List]]&lt;br /&gt;
* [[Evan&#039;s List]]&lt;br /&gt;
*[[Adam&#039;s List]]&lt;br /&gt;
&lt;br /&gt;
===Leo===&lt;br /&gt;
*[[Leo&#039;s Documentation]]&lt;br /&gt;
*[[Test Lab information]]&lt;br /&gt;
*[[Internal EMC Testing Status]]&lt;br /&gt;
*[[Travel Notes]]&lt;br /&gt;
*[[Leo&#039;s Logbook]]&lt;br /&gt;
&lt;br /&gt;
== Getting started ==&lt;br /&gt;
&lt;br /&gt;
Consult the [http://meta.wikipedia.org/wiki/MediaWiki_User%27s_Guide User&#039;s Guide] for information on using the wiki software.&lt;br /&gt;
&lt;br /&gt;
* [http://www.mediawiki.org/wiki/Help:Configuration_settings Configuration settings list]&lt;br /&gt;
* [http://www.mediawiki.org/wiki/Help:FAQ MediaWiki FAQ]&lt;br /&gt;
* [http://mail.wikipedia.org/mailman/listinfo/mediawiki-announce MediaWiki release mailing list]&lt;/div&gt;</summary>
		<author><name>Djrudiak</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=Language_-_Delphi&amp;diff=19436</id>
		<title>Language - Delphi</title>
		<link rel="alternate" type="text/html" href="https://www.phidgets.com/docs21/index.php?title=Language_-_Delphi&amp;diff=19436"/>
		<updated>2012-05-02T15:43:38Z</updated>

		<summary type="html">&lt;p&gt;Djrudiak: /* Getting Started */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Language]]&lt;br /&gt;
{{OSLang|[[File:Icon-Delphi.png|64px|alt=|link=]]|&#039;&#039;&#039;[http://www.embarcadero.com/products/delphi Embarcadero Delphi]&#039;&#039;&#039; is an integrated development environment for console, desktop graphical, web application, and mobile applications.}}&lt;br /&gt;
==Support==&lt;br /&gt;
Delphi has a complete API for all Phidgets devices, and code samples for AdvancedServo, Servo, PhidgetInterfaceKit, and RFID.&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;
* 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;
* 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 Phidget Programming]] 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;amp;rarr;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;amp;rarr;New&amp;amp;rarr;Package - Delphi for Win32. Rename and save the package using File&amp;amp;rarr;Save Project As...&lt;br /&gt;
#Import the ActiveX component, go to Component&amp;amp;rarr;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;amp;rarr;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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&amp;lt;/div&amp;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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&amp;lt;/div&amp;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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight lang=delphi&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  PhidgetInterfaceKit1.OutputState[0] := true;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/div&amp;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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&amp;lt;/div&amp;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>Djrudiak</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=Language_-_C_Sharp_(.NET_Compact_Framework)&amp;diff=19435</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=19435"/>
		<updated>2012-05-02T15:39:17Z</updated>

		<summary type="html">&lt;p&gt;Djrudiak: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Language]]&lt;br /&gt;
{{OSLang|[[File:icon-CSharp.png|64x64px|link=|alt=]]|C#(.NET Compact Framework) is a modern, object-oriented programming language developed by [http://www.microsoft.com Microsoft] intended for developing applications for smart devices.}}&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
{{LanguageSupport|C#(.NET Compact Framework)|the complete Phidget API, including events|all Phidget devices.|the .NET Compact Framework. This frameworks is supported on devices with the Windows CE operating system. We provide instructions on how to set up your environment/compilers for [[#Visual Studio 2005/2008/2010 | Visual Studio 2005/2008/2010]]|}}&lt;br /&gt;
&lt;br /&gt;
==Quick Downloads==&lt;br /&gt;
{{QuickDownloads|C#(.NET Compact Framework)|&lt;br /&gt;
{{APIQuickDownloads|http://www.phidgets.com/documentation/Phidget21.NET.zip .NET}}|&lt;br /&gt;
{{ExampleQuickDownloads|http://www.phidgets.com/downloads/examples/CE_2.1.8.20120216.zip|}}|&lt;br /&gt;
{{ExtraLibraryQuickDownloads|http://www.phidgets.com/downloads/libraries/Phidget21-wincedevel_2.1.8.20120216.zip|Phidget Windows CE|(all architectures)}}&lt;br /&gt;
{{ExtraLibraryQuickDownloads|http://www.phidgets.com/downloads/libraries/Phidget21ARMV4I_2.1.8.20120216.CAB|Windows CE|Installer(ARMV4I)}}&lt;br /&gt;
{{ExtraLibraryQuickDownloads|http://www.phidgets.com/downloads/libraries/Phidget21x86_2.1.8.20120216.CAB|Windows CE|Installer(x86)}}&lt;br /&gt;
{{ExtraLibraryQuickDownloads|http://www.phidgets.com/downloads/libraries/Phidget21MIPSII_2.1.8.20120216.CAB|Windows CE|Installer(MIPSII)}}&lt;br /&gt;
}}&lt;br /&gt;
The source code for the Phidget Kernel driver for Windows CE is also provided:&lt;br /&gt;
* [http://www.phidgets.com/downloads/libraries/Phidget21CEkernalsource_2.1.8.20120216.zip Kernel Driver Source(all architectures)]&lt;br /&gt;
&lt;br /&gt;
==Getting started with C#(.NET Compact Framework)==&lt;br /&gt;
&lt;br /&gt;
If you are new to writing code for Phidgets, we recommend starting by running, then modifying existing examples. This will allow you to:&lt;br /&gt;
{{ExampleCodeReasons}}&lt;br /&gt;
&lt;br /&gt;
To develop applications on Windows CE, you will need a Windows(2000/XP/Vista/7) system in order to perform development on. The drivers can be easily installed onto the Windows CE system by using the installers in the [[#Libraries and Drivers | Libraries and Drivers]] section. You will also need the (.NET Compact Framework Libraries) on your development system to code against.&lt;br /&gt;
&lt;br /&gt;
==Windows (2000/XP/Vista/7)==&lt;br /&gt;
&lt;br /&gt;
===Description of Library Files===&lt;br /&gt;
C#(.NET Compact Framework) programs on Windows depend on the following files, which the installers above put onto your system:&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|phidget21.dll}}&amp;lt;/b&amp;gt; contains the actual Phidget library, which is used at run-time.  &lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|phidget.dll}}&amp;lt;/b&amp;gt; is the Phidgets kernel driver.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|Phidget21CE.NET.dll}}&amp;lt;/b&amp;gt; is the .NET(Compact Framework) Phidgets library.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|PhidgetWebService21.exe}}&amp;lt;/b&amp;gt; is used to control Phidgets remotely across a network using the [[#WebService | PhidgetWebservce]].&lt;br /&gt;
&lt;br /&gt;
If you do not want to use our installer, you can download the [http://www.phidgets.com/downloads/libraries/Phidget21-wincedevel_2.1.8.20120216.zip files]. Inside the zip file, please use the files that pertain to your architecture. These files should be placed in the {{Code|\Windows}} folder.&lt;br /&gt;
&lt;br /&gt;
===Visual Studio 2005/2008/2010===&lt;br /&gt;
&lt;br /&gt;
=====Use Our Examples=====&lt;br /&gt;
&lt;br /&gt;
We will start by downloading the examples and building an executable for them on the development machine. Visual Studio will be used for development. We will then transfer the executable onto the Windows CE machine to run.&lt;br /&gt;
&lt;br /&gt;
Please start by downloading the [http://www.phidgets.com/downloads/examples/CE_2.1.8.20120216.zip examples] and unpack them into a folder.  While these examples were written in Visual Studio 2005 and 2008, Visual Studio 2010 will easily open and upgrade them. To load all projects in Visual Studio, go to File &amp;amp;rarr; Open &amp;amp;rarr; Project, and open {{Code|WindowsCE.NET Examples.sln}} or {{Code|WindowsCE.NET Examples_vs2008.sln}} for Visual Studio 2005 and 2008, respectively.&lt;br /&gt;
&lt;br /&gt;
If you are opening the Phidget examples in Visual Studio 2010, you will need to go through the Visual Studio Conversion Wizard to convert the 2005 or 2008 project. &lt;br /&gt;
&lt;br /&gt;
[[File:VS2005 Conversion Wizard.PNG|link=|alt=Conversion Wizard]]&lt;br /&gt;
&lt;br /&gt;
The easiest way to confirm that your environment is set up properly will be to compile and run the {{Code|HelloWorld}} C#(.NET Compact Framework) example.&lt;br /&gt;
&lt;br /&gt;
Start by setting the {{Code|HelloWorld}} project as your start up project.&lt;br /&gt;
&lt;br /&gt;
Next, build the example project. Right click the {{Code|HelloWorld}} project and select {{Code|Build}} to create an executable. &lt;br /&gt;
&lt;br /&gt;
[[File:VS2005 CSharpCompact Build.PNG|link=|alt=Build]]&lt;br /&gt;
&lt;br /&gt;
Then in Windows Explorer, navigate to the {{Code|project directory\bin\Debug}} folder if you are targeting a debug configuration. The folder will be {{Code|project directory\bin\Release}} if you are targeting a release configuration. Regardless of whether you are targeting debug or release, you will find an executable named {{Code|HelloWorld.exe}}. Transfer this file onto the Windows CE system. &lt;br /&gt;
&lt;br /&gt;
The only thing left to do is to run the example! Double click on the executable on the Windows CE system to run it. &lt;br /&gt;
&lt;br /&gt;
This program will detect for devices that are attached/detached on the computer. Go ahead, and attach or detach your devices! &lt;br /&gt;
&lt;br /&gt;
After confirming that the {{Code|HelloWorld}} example is working, you can proceed to run the example for your device. If you aren&#039;t sure what the software example for your device is called, check the software object listed in the [[Device List | Getting Started Guide for your Device]]. Currently, the only devices we have example code is for the PhidgetInterfaceKit, PhidgetRFID, PhidgetTextLCD. Please ensure that you have set your start up project to be the one that matches your device before compiling. &lt;br /&gt;
&lt;br /&gt;
Once you have the C#(.NET Compact Framework) examples running, we have a [[#Follow the Examples|teaching]] section below to help you follow them.&lt;br /&gt;
&lt;br /&gt;
=====Write Your Own Code=====&lt;br /&gt;
&lt;br /&gt;
On the development computer, when you are building a project from scratch, or adding Phidget function calls to an existing project, you&#039;ll need to configure your environment to properly link the Phidget C#(.NET Compact Framework) libraries. To begin: &lt;br /&gt;
&lt;br /&gt;
1. Generate a new smart device Windows CE C# Console Applications project with a descriptive name such as PhidgetTest. &lt;br /&gt;
&lt;br /&gt;
[[File:VS2005 CSharpCompact New Project.PNG|link=|alt=New Project]]&lt;br /&gt;
&lt;br /&gt;
2. Add a reference to the Phidget .NET library.&lt;br /&gt;
&lt;br /&gt;
[[File:VS2005 CSharpCompact Add Reference 1.PNG|link=|alt=Add Reference]]&lt;br /&gt;
&lt;br /&gt;
3. Download the [http://www.phidgets.com/downloads/libraries/Phidget21-wincedevel_2.1.8.20120216.zip {{Code|Phidget21CE.NET.dll}}] file. The file is contained in the zip file. &lt;br /&gt;
&lt;br /&gt;
4. Under the .NET tab, select {{Code|Phidget21CE.NET.dll}}.&lt;br /&gt;
&lt;br /&gt;
[[File:VS2005 CSharpCompact Add Reference 2.PNG|link=|alt=Add Reference]]&lt;br /&gt;
&lt;br /&gt;
5. Then, in your code, you will need to include the Phidget .NET library:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=csharp&amp;gt;&lt;br /&gt;
  using Phidgets;&lt;br /&gt;
  using Phidgets.Events;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The project now has access to the Phidget function calls and you are ready to begin coding.&lt;br /&gt;
&lt;br /&gt;
The same [[#Follow the Examples|teaching ]] section which describes the examples also has further resources for programming your Phidget.&lt;br /&gt;
&lt;br /&gt;
==Follow the Examples==&lt;br /&gt;
&lt;br /&gt;
By following the instructions for your operating system and compiler above, you probably now have a working example and want to understand it better so you can change it to do what you want.  This teaching section has resources for you to learn from the examples and write your own.&lt;br /&gt;
&lt;br /&gt;
Your main reference for writing C# code will be our .NET API information, with syntax for all of our functions:&lt;br /&gt;
&lt;br /&gt;
{{UsingAPhidgetInCodeGeneral|both of which are available in C#|[http://www.phidgets.com/documentation/Phidget21.NET.zip .NET API]}}&lt;br /&gt;
&lt;br /&gt;
Here, you can find further examples. Coding in C#(.NET Compact Framework) is very similar to coding in C#, so you can take a look at our resources on the [[#Language - C Sharp | C# section]].&lt;br /&gt;
&lt;br /&gt;
===Example Flow===&lt;br /&gt;
&lt;br /&gt;
{{ExamplePseudocode|In C#(.NET Compact Framework), you can name these &#039;&#039;&#039;event&#039;&#039;&#039; functions whatever you like.  You will then pass them as function pointers to the Phidget .NET library below in the Main Code section.  This hooks them into the actual events when they occur. &amp;lt;br&amp;gt; &lt;br /&gt;
In the example code, the event functions common to all Phidgets are called things like &#039;&#039;&#039;AttachHandler()&#039;&#039;&#039; and &#039;&#039;&#039;DetachHandler()&#039;&#039;&#039;, etc.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Some event functions will be specific to each device, like when a tag is read on an RFID board, or when a sensor value changes on an Interface Kit.&lt;br /&gt;
Other functions are given in the examples to show you more detail on using your Phidget.  For example, &#039;&#039;&#039;DeviceInitialize()&#039;&#039;&#039; will show what needs to be set up for your Phidget before using it.&lt;br /&gt;
|Creating a Phidget software object in C#(.NET Compact Framework) is specific to the Phidget.  For a Phidget Spatial, for example, this would involve creating a {{Code|Spatial}} object.  The examples show how to do this and other API functions.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
The object provides device specific methods and properties which are available from the API for your specific Phidget.|&lt;br /&gt;
[http://www.phidgets.com/documentation/Phidget21.NET.zip .NET API]}}&lt;br /&gt;
&lt;br /&gt;
==Code Snippets==&lt;br /&gt;
&lt;br /&gt;
==Common Problems and Solutions/Workarounds==&lt;br /&gt;
&lt;br /&gt;
==={{ProblemSolution|All Operating Systems|The Phidgets.Events.ErrorEventHandler conflicts with System.IO.ErrorEventHandler.}}===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=csharp&amp;gt;&lt;br /&gt;
using System.IO;&lt;br /&gt;
using Phidgets;&lt;br /&gt;
using Phidgets.Events;&lt;br /&gt;
...&lt;br /&gt;
spatial.Error += new ErrorEventHandler(spatial_Error);&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
void spatial_Error(object sender, ErrorEventArgs e){&lt;br /&gt;
   ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above code produces the following errors:&lt;br /&gt;
&lt;br /&gt;
{{Code|&#039;ErrorEventHandler&#039; is an ambiguous reference between &#039;System.IO.ErrorEventHandler&#039; and &#039;Phidgets.Events.ErrorEventHandler&#039;}}.&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
{{Code|&#039;ErrorEventArgs&#039; is an ambiguous reference between &#039;System.IO.ErrorEventArgs&#039; and &#039;Phidgets.Events.ErrorEventArgs&#039;}}.&lt;br /&gt;
&lt;br /&gt;
The error is due to the {{Code|System.IO}} and {{Code|Phidgets.Events}} namespaces both having a class called {{Code|ErrorEventHandler}}.&lt;br /&gt;
&lt;br /&gt;
To get around this issue, use the fully qualified namespace when referring to the {{Code|ErrorEventHandler}} and {{Code|ErrorEventArgs}} classes:&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=csharp&amp;gt;&lt;br /&gt;
using System.IO;&lt;br /&gt;
using Phidgets;&lt;br /&gt;
using Phidgets.Events;&lt;br /&gt;
...&lt;br /&gt;
spatial.Error += new Phidgets.Events.ErrorEventHandler(spatial_Error);&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
void spatial_Error(object sender, Phidgets.Events.ErrorEventArgs e){&lt;br /&gt;
   ...&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;/div&gt;</summary>
		<author><name>Djrudiak</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=Language_-_Applescript&amp;diff=19434</id>
		<title>Language - Applescript</title>
		<link rel="alternate" type="text/html" href="https://www.phidgets.com/docs21/index.php?title=Language_-_Applescript&amp;diff=19434"/>
		<updated>2012-05-02T15:10:12Z</updated>

		<summary type="html">&lt;p&gt;Djrudiak: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Language]]&lt;br /&gt;
{{OSLang|[[File:icon-Applescript.png|64x64px]]|Applescript is a scripting language for OS X designed primarily for interfacing between applications.}}&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;
* 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;
* 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 Phidget Programming]] 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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight lang=applescript&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  tell ifkit to open&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&amp;lt;/div&amp;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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;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;
Please keep in mind that events are triggered from the PhidgetsOSA application and not from AppleScript. Thus, the AppleScript editor won&#039;t be able to receive replies when the script runs. In addition, any changes you make to the event code must be saved in order for the changes to take effect.&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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;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>Djrudiak</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=Template:ExamplePseudocode&amp;diff=19313</id>
		<title>Template:ExamplePseudocode</title>
		<link rel="alternate" type="text/html" href="https://www.phidgets.com/docs21/index.php?title=Template:ExamplePseudocode&amp;diff=19313"/>
		<updated>2012-04-25T20:47:49Z</updated>

		<summary type="html">&lt;p&gt;Djrudiak: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Hello World example has this general structure so you can follow along.  We also have [[General Phidget Programming|an in-depth general introduction]] to writing Phidget code (like open, read data, etc), as well as the {{{3}}} for specific syntax:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;source&amp;quot; style=&amp;quot;margin-left:15px;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot;&lt;br /&gt;
|&amp;lt;font face=&amp;quot;courier new&amp;quot; family=&amp;quot;monospace&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:#090;&amp;quot;&amp;gt;// ----- &#039;&#039;&#039;Event&#039;&#039;&#039; and Other Functions -----&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create any Language-Specific Functions (exception handling)&lt;br /&gt;
&lt;br /&gt;
Create General &#039;&#039;&#039;Attach&#039;&#039;&#039;, &#039;&#039;&#039;Detach&#039;&#039;&#039;, and &#039;&#039;&#039;Error&#039;&#039;&#039; Handling Functions:&lt;br /&gt;
:On attach: Print Hello Message&lt;br /&gt;
:On detach: Print Goodbye Message&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
| width=&amp;quot;15px&amp;quot; | &amp;amp;nbsp;&lt;br /&gt;
| &lt;br /&gt;
&amp;lt;font face=&amp;quot;courier new&amp;quot; family=&amp;quot;monospace&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:#00F;&amp;quot;&amp;gt;{{{1}}}&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot;&lt;br /&gt;
|style=white-space:nowrap|&amp;lt;font face=&amp;quot;courier new&amp;quot; family=&amp;quot;monospace&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:#090;&amp;quot;&amp;gt;// ----- &#039;&#039;&#039;Main&#039;&#039;&#039; Code -----&amp;lt;/span&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Create&#039;&#039;&#039; Manager Software Object&amp;lt;br&amp;gt;&lt;br /&gt;
Hook &#039;&#039;&#039;Event&#039;&#039;&#039; Functions created above to Device&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Open&#039;&#039;&#039; Device&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Wait for &#039;Enter&#039; key character input&lt;br /&gt;
:Handle on-going attach and detach events&lt;br /&gt;
:Print Hello and Goodbye messages&lt;br /&gt;
:Exit upon input&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Close&#039;&#039;&#039; Device&lt;br /&gt;
&lt;br /&gt;
Delete Device&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
| width=&amp;quot;15px&amp;quot; | &amp;amp;nbsp;&lt;br /&gt;
| &lt;br /&gt;
&amp;lt;font face=&amp;quot;courier new&amp;quot; family=&amp;quot;monospace&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:#00F;&amp;quot;&amp;gt;{{{2}}}&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;/div&gt;</summary>
		<author><name>Djrudiak</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=Template:ExamplePseudocode&amp;diff=19312</id>
		<title>Template:ExamplePseudocode</title>
		<link rel="alternate" type="text/html" href="https://www.phidgets.com/docs21/index.php?title=Template:ExamplePseudocode&amp;diff=19312"/>
		<updated>2012-04-25T20:46:53Z</updated>

		<summary type="html">&lt;p&gt;Djrudiak: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Hello World example has this general structure so you can follow along.  We also have [[General Phidget Programming|an in-depth general introduction]] to writing Phidget code (like open, read data, etc), as well as the {{{3}}} for specific syntax:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;0&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;source&amp;quot; style=&amp;quot;margin-left:15px;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot;&lt;br /&gt;
|&amp;lt;font face=&amp;quot;courier new&amp;quot; family=&amp;quot;monospace&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:#090;&amp;quot;&amp;gt;// ----- &#039;&#039;&#039;Event&#039;&#039;&#039; and Other Functions -----&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create any Language-Specific Functions (exception handling)&lt;br /&gt;
&lt;br /&gt;
Create General &#039;&#039;&#039;Attach&#039;&#039;&#039;, &#039;&#039;&#039;Detach&#039;&#039;&#039;, and &#039;&#039;&#039;Error&#039;&#039;&#039; Handling Functions:&lt;br /&gt;
:On attach: Print Hello Message&lt;br /&gt;
:On detach: Print Goodbye Message&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
| width=&amp;quot;15px&amp;quot; | &amp;amp;nbsp;&lt;br /&gt;
| &lt;br /&gt;
&amp;lt;font face=&amp;quot;courier new&amp;quot; family=&amp;quot;monospace&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:#00F;&amp;quot;&amp;gt;{{{1}}}&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot;&lt;br /&gt;
|style=white-space:nowrap|&amp;lt;font face=&amp;quot;courier new&amp;quot; family=&amp;quot;monospace&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:#090;&amp;quot;&amp;gt;// ----- &#039;&#039;&#039;Main&#039;&#039;&#039; Code -----&amp;lt;/span&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Create&#039;&#039;&#039; Manager Software Object&amp;lt;br&amp;gt;&lt;br /&gt;
Hook &#039;&#039;&#039;Event&#039;&#039;&#039; Functions created above to Device&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Open&#039;&#039;&#039; Device&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Wait for &#039;Enter&#039; key character input&lt;br /&gt;
:Handle on-going attach and detach events&lt;br /&gt;
:Print Hello and Goodbye messages&lt;br /&gt;
:Exit upon input&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Close&#039;&#039;&#039; Device&lt;br /&gt;
&lt;br /&gt;
Delete Device&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
| width=&amp;quot;15px&amp;quot; | &amp;amp;nbsp;&lt;br /&gt;
| &lt;br /&gt;
&amp;lt;font face=&amp;quot;courier new&amp;quot; family=&amp;quot;monospace&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:#00F;&amp;quot;&amp;gt;{{{2}}}&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;/div&gt;</summary>
		<author><name>Djrudiak</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=Language_-_C_Sharp&amp;diff=19255</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=19255"/>
		<updated>2012-04-24T21:07:53Z</updated>

		<summary type="html">&lt;p&gt;Djrudiak: /* Use Our Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Language]]&lt;br /&gt;
{{OSLang|[[File:icon-CSharp.png|64x64px|link=|alt=]]|C# is a modern, object-oriented programming language developed by [[http://www.microsoft.com Microsoft]].}}&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
{{LanguageSupport|C#|the complete Phidget API, including events|all Phidget devices.|the .NET or Mono framework. Both of the frameworks are supported on Windows. For Linux and OS X, only the Mono framework can be used. We provide instructions on how to set up your environment/compilers for [[#Visual Studio 2005/2008/2010 | Visual Studio 2005/2008/2010]], [[#Visual Studio 2003 | Visual Studio 2003]], [[#MonoDevelop | MonoDevelop]] and the [[#Mono | Mono command line compilers]]|}}&lt;br /&gt;
&lt;br /&gt;
==Quick Downloads==&lt;br /&gt;
{{QuickDownloads|C#|&lt;br /&gt;
{{APIQuickDownloads|http://www.phidgets.com/documentation/Phidget21.NET.zip .NET}}|&lt;br /&gt;
{{ExampleQuickDownloads|http://www.phidgets.com/downloads/examples/CSharp_2.1.8.20110615.zip|}}|&lt;br /&gt;
{{ExtraLibraryQuickDownloads|http://www.phidgets.com/downloads/libraries/phidget21-x86_2.1.8.20110615.zip|.NET Framework Files|}}&lt;br /&gt;
{{WindowsQuickDownloads}}&lt;br /&gt;
{{MacQuickDownloads}}&lt;br /&gt;
{{LinuxQuickDownloads}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Getting started with C#==&lt;br /&gt;
&lt;br /&gt;
If you are new to writing code for Phidgets, we recommend starting by running, then modifying existing examples. This will allow you to:&lt;br /&gt;
{{ExampleCodeReasons}}&lt;br /&gt;
&lt;br /&gt;
Instructions are divided up by operating system. Choose:&lt;br /&gt;
*[[#Windows(2000/XP/Vista/7)|Windows 2000 / XP / Vista / 7]]&lt;br /&gt;
*[[#OS X |OS X]]&lt;br /&gt;
*[[#Linux | Linux]] (including PhidgetSBC)&lt;br /&gt;
&lt;br /&gt;
==Windows (2000/XP/Vista/7)==&lt;br /&gt;
&lt;br /&gt;
===Description of Library Files===&lt;br /&gt;
C# programs on Windows depend on the following files, which the installers above put onto your system:&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|phidget21.dll}}&amp;lt;/b&amp;gt; contains the actual Phidget library, which is used at run-time.  By default, it is placed in {{Code|C:\Windows\System32}}.&lt;br /&gt;
You will also need one of the following two files, depending on the .NET framework version you are targeting:&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|Phidget21.NET.dll}}&amp;lt;/b&amp;gt; is the Phidget library for .NET framework &amp;lt;i&amp;gt;&amp;lt;b&amp;gt;2.0&amp;lt;/b&amp;gt;&amp;lt;/i&amp;gt; or higher. Your compiler has to know where this file is. By default, it is placed into {{Code|C:\Program Files\Phidgets}}. You can either point your compiler to that location, or copy and link to it in a directory for your project workspace. &lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|Phidget21.NET1.1.dll}}&amp;lt;/b&amp;gt; is the Phidget library for .NET framework &amp;lt;i&amp;gt;&amp;lt;b&amp;gt;1.1&amp;lt;/b&amp;gt;&amp;lt;/i&amp;gt;. Your compiler has to know where this file is. By default, is is placed into {{Code|C:\Program Files\Phidgets}}. You can either point your compiler to that location, or copy and link to it in a directory for your project workspace. &lt;br /&gt;
You can optionally install the following files:&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|Phidget21.NET.XML}}&amp;lt;/b&amp;gt; provides the IntelliSense in-line documentation for the .NET library in Visual Studio/MonoDevelop. This documentation is also visible in the Object Browser in Visual Studio. By default, it is placed into {{Code|C:\Program Files\Phidgets}}. &lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|Policy.2.1.Phidget21.NET.dll}}&amp;lt;/b&amp;gt; is the policy assembly for {{Code|Phidget21.NET.dll}}. Our installer places this file in the Global Assembly Cache(GAC) directory. It directs any programs compiled against version 2.1.0 or higher of {{Code|Phidget21.NET.dll}} to use the most recent installed version. &lt;br /&gt;
&lt;br /&gt;
If you do not want to use our installer, you can download the five [http://www.phidgets.com/downloads/libraries/Phidget21-windevel_2.1.8.20111220.zip files].&lt;br /&gt;
&lt;br /&gt;
Running the examples and writing your own code can be fairly compiler-specific, so we include instructions for each compiler below.&lt;br /&gt;
&lt;br /&gt;
===Visual Studio 2005/2008/2010===&lt;br /&gt;
&lt;br /&gt;
Microsoft makes free versions of Visual Studio available known as Express Editions.  The Express editions are suitable for most applications, but are limited in features for more complex applications. Please see [http://www.microsoft.com/visualstudio Microsoft Visual Studio] for more information.&lt;br /&gt;
&lt;br /&gt;
=====Use Our Examples=====&lt;br /&gt;
&lt;br /&gt;
Please start by downloading the [http://www.phidgets.com/downloads/examples/CSharp_2.1.8.20110615.zip examples] and unpack them into a folder.  While these examples were written in Visual Studio 2005 and 2008, Visual Studio 2010 will easily open and upgrade them. To load all projects in Visual Studio, go to File &amp;amp;rarr; Open &amp;amp;rarr; Project, and open {{Code|AllExamples/AllExamples.sln}} or {{Code|AllExamples/AllExamples_vs2008.sln}} for Visual Studio 2005 and 2008, respectively.&lt;br /&gt;
&lt;br /&gt;
If you are opening the Phidget examples in Visual Studio 2010, you will need to go through the Visual Studio Conversion Wizard to convert the 2005 or 2008 project. &lt;br /&gt;
&lt;br /&gt;
[[File:VS2005 Conversion Wizard.PNG|link=|alt=Conversion Wizard]]&lt;br /&gt;
&lt;br /&gt;
The easiest way to confirm that your environment is set up properly will be to compile and run the {{Code|HelloWorld}} C/C++ example.&lt;br /&gt;
&lt;br /&gt;
Start by setting the {{Code|HelloWorld}} project as your start up project.&lt;br /&gt;
&lt;br /&gt;
The only thing left to do is to run the example! Click on Debug &amp;amp;rarr; Start Debugging. Please note that the projects, by default try to find the {{Code|Phidget21.NET.dll}} in the {{Code|C:\Program Files\Phidgets}}. If you have it installed in another location, please change the path to the file&#039;s location accordingly. If you are receiving an error message regarding that the namespace Phidgets cannot be found, please re-add the reference to {{Code|Phidget21.NET.dll}}. Please see the [[#Write Your Own Code | Write Your Own Code ]] section for details. &lt;br /&gt;
&lt;br /&gt;
[[File:CSharp VS2005 Run.PNG|link=|alt=Run]]&lt;br /&gt;
&lt;br /&gt;
This program will detect for devices that are attached/detached on the computer. Go ahead, and attach or detach your devices! Here is an example output:&lt;br /&gt;
&lt;br /&gt;
[[File:CSharp VS2005 HelloWorld Output.PNG|link=|alt=HelloWorld Output]]&lt;br /&gt;
&lt;br /&gt;
After confirming that the {{Code|HelloWorld}} example is working, you can proceed to run the example for your device. If you aren&#039;t sure what the software example for your device is called, check the software object listed in the [[Device List | Getting Started Guide for your Device]]. Please ensure that you have set your start up project to be the one that matches your device before compiling. &lt;br /&gt;
&lt;br /&gt;
Once you have the C# examples running, we have a [[#Follow the Examples|teaching]] section below to help you follow them.&lt;br /&gt;
&lt;br /&gt;
=====Write Your Own Code=====&lt;br /&gt;
&lt;br /&gt;
When you are building a project from scratch, or adding Phidget function calls to an existing project, you&#039;ll need to configure your environment to properly link the Phidget C# libraries. To begin: &lt;br /&gt;
&lt;br /&gt;
1. Generate a new Visual C# Windows Applications project with a descriptive name such as PhidgetTest. &lt;br /&gt;
&lt;br /&gt;
[[File:CSharp VS2005 New Project.PNG|link=|alt=New Project]]&lt;br /&gt;
&lt;br /&gt;
2. Add a reference to the Phidget .NET library.&lt;br /&gt;
&lt;br /&gt;
[[File:CSharp VS2005 Add Reference.PNG|link=|alt=Add Reference]]&lt;br /&gt;
&lt;br /&gt;
3. Under the .NET tab, select {{Code|Phidget21.NET.dll}}.&lt;br /&gt;
If you used our installer, these files are installed in {{Code|C:\Program Files\Phidgets}}, by default. If it does not appear in this list, then you can browse to the Phidget Framework installation directory and add the file.&lt;br /&gt;
&lt;br /&gt;
[[File:CSharp VS2005 Add Reference 2.PNG|link=|alt=Add Reference]]&lt;br /&gt;
&lt;br /&gt;
4. Then, in your code, you will need to include the Phidget .NET library:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=csharp&amp;gt;&lt;br /&gt;
  using Phidgets;&lt;br /&gt;
  using Phidgets.Events;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The project now has access to the Phidget function calls and you are ready to begin coding.&lt;br /&gt;
&lt;br /&gt;
The same [[#Follow the Examples|teaching ]] section which describes the examples also has further resources for programming your Phidget.&lt;br /&gt;
&lt;br /&gt;
===Visual Studio 2003===&lt;br /&gt;
&lt;br /&gt;
=====Use Our Examples=====&lt;br /&gt;
&lt;br /&gt;
1. Download the [http://www.phidgets.com/downloads/examples/CSharp_2.1.8.20110615.zip examples] and unpack them into a folder. Here, you can find example programs for all the devices. If you are not sure what the software example for your device is called, check the software object listed in the [[Device List | Getting Started guide for your device]]. As the examples were written in newer versions of Visual Studio, Visual Studio 2003 is not able to open the examples. Fortunately, you can import the simple examples to a Visual Studio 2003 project. It will be difficult to import the full examples as you will need to recreate the GUI components. In the [[#Use Our Examples 2 | Use Our Examples]] section, it will be assumed that the simple examples are used. You will need this example source code to be copied into your C# project later on. &lt;br /&gt;
&lt;br /&gt;
2. Next, a new project will need to be created. Generate a new Visual C# console application project with a descriptive name such as PhidgetTest.&lt;br /&gt;
&lt;br /&gt;
[[File:CSharp_VS2003 New Project.PNG|link=|alt=New Project]]&lt;br /&gt;
&lt;br /&gt;
3. Add a reference to the Phidget .NET library.&lt;br /&gt;
&lt;br /&gt;
[[File:CSharp_VS2003 Add Reference 1.PNG|link=|alt=Add Reference]]&lt;br /&gt;
&lt;br /&gt;
4. Under the .NET tab, select {{Code|Phidget21.NET1.1.dll}}. If you used our installer, by default, this file is placed in {{Code|C:\Program Files\Phidgets}}. If it is in another location, please change the path to the file&#039;s location accordingly. &lt;br /&gt;
&lt;br /&gt;
[[File:CSharp_VS2003 Add Reference 2.PNG|link=|alt=Add Reference]]&lt;br /&gt;
&lt;br /&gt;
5. To import the simple example program into your project, please: open up {{Code|Class1.cs}}.&lt;br /&gt;
&lt;br /&gt;
6. Traverse to the example in Windows Explorer and locate the {{Code|Program.cs}} file.&lt;br /&gt;
&lt;br /&gt;
[[File:CSharp VS2003 Source Code.PNG|link=|alt=Source Code]]&lt;br /&gt;
&lt;br /&gt;
7. Copy and paste the contents from that file into {{Code|Class1.cs}}.&lt;br /&gt;
&lt;br /&gt;
8. Comment out the following line as it is not supported in .NET 1.1:&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=csharp&amp;gt;&lt;br /&gt;
  using System.Collections.Generic;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:CSharp VS2003 Source Code 2.PNG|link=|alt=Source Code]]&lt;br /&gt;
&lt;br /&gt;
9. Now, you can run the example. Click on Debug &amp;amp;rarr; Start.&lt;br /&gt;
&lt;br /&gt;
[[File:CSharp VS2003 Run.PNG|link=|alt=Run]]&lt;br /&gt;
&lt;br /&gt;
Once you have the C# examples running, we have a [[#Follow the Examples|teaching ]] section below to help you follow them.&lt;br /&gt;
&lt;br /&gt;
=====Write Your Own Code=====&lt;br /&gt;
&lt;br /&gt;
When you are building a project from scratch, or adding Phidget function calls to an existing project, you&#039;ll need to configure your development environment to properly link the Phidget .NET library. Please see the [[#Use Our Examples 2 | Use Our Examples ]] section for instructions.&lt;br /&gt;
&lt;br /&gt;
Then, in your code, you will need to include the Phidget .NET library:&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=csharp&amp;gt;&lt;br /&gt;
  using Phidgets;&lt;br /&gt;
  using Phidgets.Events;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The project now has access to the Phidget function calls and you are ready to begin coding.&lt;br /&gt;
&lt;br /&gt;
The same [[#Follow the Examples|teaching]] section which describes the examples also has further resources for programming your Phidget.&lt;br /&gt;
&lt;br /&gt;
===Mono===&lt;br /&gt;
&lt;br /&gt;
This section will provide instructions on how to compile using the {{Code|mcs}} compiler. Other compilers such as {{Code|gmcs}}, {{Code|smcs}}, and {{Code|dmcs}} all work in the same way.&lt;br /&gt;
&lt;br /&gt;
=====Use Our Examples=====&lt;br /&gt;
&lt;br /&gt;
Download the [http://www.phidgets.com/downloads/examples/CSharp_2.1.8.20110615.zip examples] and unpack them into a folder. Here, you can find example programs for all the devices. If you aren&#039;t sure what the software example for your device is called, check the software object listed in the [[Device List | Getting Started guide for your device]]. Please only use the simple examples. The full examples uses Windows Forms, which Mono and the Gtk# toolkit are not completely compatible with. Locate the {{Code|Program.cs}} file as this contains the example source code. Copy the file into your working directory, and rename it to {{Code|example.cs}}.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Place the {{Code|Phidget21.NET.dll}} in the same directory as your source code.&lt;br /&gt;
&lt;br /&gt;
To compile and build an executable, run:&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=bash&amp;gt;&lt;br /&gt;
mcs /out:example.exe /r:phidget21.NET.dll example.cs&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have the {{Code|Phidget21.NET.dll}} installed in another location, please change the path to the file&#039;s location accordingly.&lt;br /&gt;
&lt;br /&gt;
Afterwards, you will have an executable named {{Code|example.exe}} that you can run. Type the following to run the program:&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=bash&amp;gt;&lt;br /&gt;
mono example.exe&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once you have the C# examples running, we have a [[#Follow the Examples|teaching]] section below to help you follow them.&lt;br /&gt;
&lt;br /&gt;
=====Write Your Own Code=====&lt;br /&gt;
&lt;br /&gt;
When you are building a project from scratch, or adding Phidget function calls to an existing project, you&#039;ll need to configure your development environment to properly link the Phidget .NET library. Please see the [[#Use Our Examples 3 | Use Our Example ]] section for instructions.&lt;br /&gt;
&lt;br /&gt;
In your code, you will need to include the Phidget .NET library:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=csharp&amp;gt;&lt;br /&gt;
  using Phidgets;&lt;br /&gt;
  using Phidgets.Events;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The project now has access to the Phidget function calls and you are ready to begin coding.&lt;br /&gt;
&lt;br /&gt;
The same [[#Follow the Examples|teaching]] section which describes the examples also has further resources for programming your Phidget.&lt;br /&gt;
&lt;br /&gt;
===MonoDevelop===&lt;br /&gt;
&lt;br /&gt;
=====Use Our Examples=====&lt;br /&gt;
&lt;br /&gt;
Download the [http://www.phidgets.com/downloads/examples/CSharp_2.1.8.20110615.zip examples] and unpack them into a folder. Here, you can find example programs for all the devices. These examples were written in Visual Studio 2005 and 2008, but are also compatible with MonoDevelop.&lt;br /&gt;
&lt;br /&gt;
To load all projects in MonoDevelop, go to File &amp;amp;rarr; Open, and open {{Code|AllExamples/AllExamples.sln}}&lt;br /&gt;
&lt;br /&gt;
This will load all of the examples available for C#, and then you can set your main project to be the one that matches your device.  If you aren&#039;t sure what the software example for your device is called, check the software object listed in the [[Device List | Getting Started guide for your device]]. If you are running under the .NET framework, you can use either the full or simple examples. Otherwise, if you are running under the Mono framework, please only use the simple examples. The full examples uses Windows Forms, which is not completely compatible with Mono&#039;s Gtk#.&lt;br /&gt;
&lt;br /&gt;
[[File:CSharp MonoDevelop Win Start Up.PNG|link=|alt=Start Up Project]]&lt;br /&gt;
&lt;br /&gt;
The only thing left to do is to run the examples! Right click the project, and click on {{Code|Run With}} and select the target framework. Please note that the projects, by default try to find the {{Code|Phidget21.NET.dll}} in the {{Code|C\Program Files\Phidgets}}. If you have it installed in another location, please change the path to the file&#039;s location accordingly. If you are receiving an error message regarding that the namespace Phidgets cannot be found, please re-add the reference to {{Code|Phidget21.NET.dll}}. Please see the [[#Write Your Own Code 4 | Write Your Own Code]] section for details. &lt;br /&gt;
&lt;br /&gt;
[[File:CSharp MonoDevelop Win Run As.PNG|link=|alt=Run As]]&lt;br /&gt;
&lt;br /&gt;
Once you have the C# examples running, we have a [[#Follow the Examples|teaching]] section below to help you follow them.&lt;br /&gt;
&lt;br /&gt;
=====Write Your Own Code=====&lt;br /&gt;
&lt;br /&gt;
When you are building a project from scratch, or adding Phidget function calls to an existing project, you&#039;ll need to configure your  development environment to properly link the Phidget .NET library. To begin:&lt;br /&gt;
&lt;br /&gt;
1. Create a new C# empty project with a descriptive name such as PhidgetTest.&lt;br /&gt;
&lt;br /&gt;
[[File:CSharp MonoDevelop Win New Project.PNG|link=|alt=New Project]]&lt;br /&gt;
&lt;br /&gt;
2. Add a reference to the Phidget .NET library. &lt;br /&gt;
&lt;br /&gt;
[[File:CSharp MonoDevelop Win Reference.PNG|link=|alt=Add Reference]]&lt;br /&gt;
&lt;br /&gt;
3. Select {{Code|Phidget21.NET.dll}}. If you used our installer, by default, this file is placed in {{Code|C:\Program Files\Phidgets}}. If it is in another location, please change the path to the file&#039;s location accordingly. &lt;br /&gt;
&lt;br /&gt;
[[File:CSharp MonoDevelop Win Reference 2.PNG|link=|alt=Add Reference]]&lt;br /&gt;
&lt;br /&gt;
4. Then, in your code, you will need to include the Phidget .NET library:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=csharp&amp;gt;&lt;br /&gt;
  using Phidgets;&lt;br /&gt;
  using Phidgets.Events;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The project now has access to the Phidget function calls and you are ready to begin coding.&lt;br /&gt;
&lt;br /&gt;
The same [[#Follow the Examples|teaching]] section which describes the examples also has further resources for programming your Phidget.&lt;br /&gt;
&lt;br /&gt;
==OS X==&lt;br /&gt;
&lt;br /&gt;
C# has excellent support on OS X through the Mono framework. &lt;br /&gt;
&lt;br /&gt;
The first step in using C# on Mac is to install the Phidget .NET libraries.  Compile and install them as explained on the [[Device List|getting started guide for your device]].  Then, the [[OS - OS X]] page also describes the different Phidget files, their installed locations, and their roles....&lt;br /&gt;
&lt;br /&gt;
==Linux==&lt;br /&gt;
&lt;br /&gt;
C# has support on Linux through the Mono framework.&lt;br /&gt;
&lt;br /&gt;
===Use Our Examples===&lt;br /&gt;
 &lt;br /&gt;
The first step in using C# with Phidgets on Linux is to make sure that you have all of Mono installed.  Although you probably have already done this if you&#039;re a C# programmer, you want to make sure you have all of the packages you&#039;ll need.  Try:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=bash&amp;gt;&lt;br /&gt;
sudo apt-get mono-complete&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, you&#039;ll want to install the main Phidget Libraries.  Compile and install them as explained on the main [[OS - Linux | Linux page]].  That Linux page also describes the different Phidget files, their installed locations, and their roles.&lt;br /&gt;
&lt;br /&gt;
Then, you will need the Phidget .NET libraries.  These are part of the Windows library zip file download:&lt;br /&gt;
&lt;br /&gt;
* [http://www.phidgets.com/downloads/libraries/Phidget21-windevel.zip Phidget Windows Library Zip File]&lt;br /&gt;
&lt;br /&gt;
Extract the library zip file.  Descriptions for the files are available on the [[OS - Windows]] page, but for now we only need the {{Code|Phidget21.NET.dll}} file to run the Phidget C# examples in Mono.  So remember where you unzipped these Windows libraries - you will need to copy the {{Code|Phidget21.NET.dll}} file into your example directory shortly.&lt;br /&gt;
&lt;br /&gt;
Next, you&#039;ll want to download and extract the Phidget C# Examples (For Windows, not for .NET Compact):&lt;br /&gt;
&lt;br /&gt;
* [http://www.phidgets.com/downloads/examples/CSharp.zip C Sharp Examples for Windows]&lt;br /&gt;
&lt;br /&gt;
To check that your Linux, Phidget, and Mono setup is all working together, you&#039;ll want to run the C# examples.  Specifically, you&#039;ll want to run the &#039;&#039;simple&#039;&#039; C# examples. Find the source code for your device. The source file will be named the same as the software object for your device. If you are not sure what the software object for your device is, it can be found in the Software/API section on the [[Device List|Product Page]] for your device. &lt;br /&gt;
&lt;br /&gt;
Let&#039;s say you&#039;re running the Temperature Sensor example (for the 1048 or 1051).  The source code for the example is in the directory: &lt;br /&gt;
&lt;br /&gt;
:{{Code|TemperatureSensorExamples}} &amp;amp;rarr; {{Code|TemperatureSensor-simple}} &amp;amp;rarr; {{Code|TemperatureSensor-simple}} &amp;amp;rarr; {{Code|Program.cs}}&lt;br /&gt;
&lt;br /&gt;
Other examples will be in directories named appropriately for their software object name.  Once you have found the example you want to run, copy the {{Code|Phidget21.NET.dll}} file that you unzipped earlier into that example directory where the {{Code|Program.cs}} file is.  &lt;br /&gt;
&lt;br /&gt;
Then, compile the code.  When compiling, you need to link to the Phidget library. As the Phidget21.NET file is an &amp;quot;additional assembly&amp;quot; in C#/Mono, you can link to the assembly using the {{Code|-r}} &amp;quot;reference&amp;quot; switch:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=bash&amp;gt;&lt;br /&gt;
gmcs Program.cs -r:Phidget21.NET.dll&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will compile a {{Code|*.exe}} file - in this case, {{Code|Program.exe}}.  This you can then run under Mono:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=bash&amp;gt;&lt;br /&gt;
sudo mono Program.exe&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remember that the {{Code|sudo}} is needed unless you have your [[OS - Linux#Setting udev Rules|udev rules set on your Linux system]].&lt;br /&gt;
&lt;br /&gt;
If you will be compiling with an IDE such as GTK# or MonoDevelop, we don&#039;t have explicit instructions by IDE for Linux.  However, you will probably find the [[#MonoDevelop | MonoDevelop]] section in the Windows portion above useful.&lt;br /&gt;
&lt;br /&gt;
===Write Your Own Code===&lt;br /&gt;
&lt;br /&gt;
When writing your code from scratch, you start it as you would any C# code on Linux, such as within a text editor like Emacs, Vi, Gedit, or Kate. In your .cs source code file, you must include a reference to the Phidget Library:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=csharp&amp;gt;&lt;br /&gt;
using Phidgets; &lt;br /&gt;
using Phidgets.Events; &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, you would compile your completed C# code the same way as the examples above.&lt;br /&gt;
&lt;br /&gt;
Mono also has a few different IDEs which you can use to develop code, and these are especially useful if you are doing GUI development.  We provide instructions for MonoDevelop - one such IDE - being used [[#MonoDevelop|under Windows]].&lt;br /&gt;
&lt;br /&gt;
To learn how to write your own code for your Phidget, and to learn more about our API, we have a [[#Follow the Examples|teaching section]] to help you follow the provided C# examples and which has resources such as the API reference.&lt;br /&gt;
&lt;br /&gt;
==Windows CE==&lt;br /&gt;
&lt;br /&gt;
===Description of Library Files===&lt;br /&gt;
C# programs on Windows depend on the following files, which the installers above put onto your system:&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|phidget21.dll}}&amp;lt;/b&amp;gt; contains the actual Phidget library, which is used at run-time.  By default, it is placed in {{Code|C:\Windows\System32}}.&lt;br /&gt;
You will also need one of the following two files, depending on the .NET framework version you are targeting:&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|Phidget21.NET.dll}}&amp;lt;/b&amp;gt; is the Phidget library for .NET framework &amp;lt;i&amp;gt;&amp;lt;b&amp;gt;2.0&amp;lt;/b&amp;gt;&amp;lt;/i&amp;gt; or higher. Your compiler has to know where this file is. By default, it is placed into {{Code|C:\Program Files\Phidgets}}. You can either point your compiler to that location, or copy and link to it in a directory for your project workspace. &lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|Phidget21.NET1.1.dll}}&amp;lt;/b&amp;gt; is the Phidget library for .NET framework &amp;lt;i&amp;gt;&amp;lt;b&amp;gt;1.1&amp;lt;/b&amp;gt;&amp;lt;/i&amp;gt;. Your compiler has to know where this file is. By default, it is placed into {{Code|C:\Program Files\Phidgets}}. You can either point your compiler to that location, or copy and link to it in a directory for your project workspace. &lt;br /&gt;
You can optionally install the following files:&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|Phidget21.NET.XML}}&amp;lt;/b&amp;gt; provides the IntelliSense in-line documentation for the .NET library in Visual Studio/MonoDevelop. This documentation is also visible in the Object Browser in Visual Studio. By default, it is placed into {{Code|C:\Program Files\Phidgets}}. &lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|Policy.2.1.Phidget21.NET.dll}}&amp;lt;/b&amp;gt; is the policy assembly for {{Code|Phidget21.NET.dll}}. Our installer places this file in the Global Assembly Cache(GAC) directory. It directs any programs compiled against version 2.1.0 or higher of {{Code|Phidget21.NET.dll}} to use the most recent installed version. &lt;br /&gt;
&lt;br /&gt;
If you do not want to use our installer, you can download the five [http://www.phidgets.com/downloads/libraries/Phidget21-windevel_2.1.8.20111220.zip files].&lt;br /&gt;
&lt;br /&gt;
Running the examples and writing your own code can be fairly compiler-specific, so we include instructions for each compiler below.&lt;br /&gt;
&lt;br /&gt;
===Visual Studio 2005/2008/2010===&lt;br /&gt;
&lt;br /&gt;
Microsoft makes free versions of Visual Studio available known as Express Editions.  The Express editions are suitable for most applications, but are limited in features for more complex applications. Please see [http://www.microsoft.com/visualstudio Microsoft Visual Studio] for more information.&lt;br /&gt;
&lt;br /&gt;
=====Use Our Examples=====&lt;br /&gt;
&lt;br /&gt;
Please start by downloading the [http://www.phidgets.com/downloads/examples/CSharp_2.1.8.20110615.zip examples] and unpack them into a folder.  While these examples were written in Visual Studio 2005 and 2008, Visual Studio 2010 will easily open and upgrade them. To load all projects in Visual Studio, go to File &amp;amp;rarr; Open &amp;amp;rarr; Project, and open {{Code|AllExamples/AllExamples.sln}} or {{Code|AllExamples/AllExamples_vs2008.sln}} for Visual Studio 2005 and 2008, respectively.&lt;br /&gt;
&lt;br /&gt;
If you are opening the Phidget examples in Visual Studio 2010, you will need to go through the Visual Studio Conversion Wizard to convert the 2005 or 2008 project. &lt;br /&gt;
[[File:VS2005 Conversion Wizard.PNG|link=|alt=Conversion Wizard]]&lt;br /&gt;
&lt;br /&gt;
The easiest way to confirm that your environment is set up properly will be to compile and run the {{Code|HelloWorld}} C/C++ example.&lt;br /&gt;
&lt;br /&gt;
Start by setting the {{Code|HelloWorld}} project as your start up project.&lt;br /&gt;
&lt;br /&gt;
The only thing left to do is to run the example! Click on Debug &amp;amp;rarr; Start Debugging. Please note that the projects, by default try to find the {{Code|Phidget21.NET.dll}} in the {{Code|C:\Program Files\Phidgets}}. If you have it installed in another location, please change the path to the file&#039;s location accordingly. If you are receiving an error message regarding that the namespace Phidgets cannot be found, please re-add the reference to {{Code|Phidget21.NET.dll}}. Please see the [[#Write Your Own Code | Write Your Own Code ]] section for details. &lt;br /&gt;
&lt;br /&gt;
[[File:CSharp VS2005 Run.PNG|link=|alt=Run]]&lt;br /&gt;
&lt;br /&gt;
This program will detect for devices that are attached/detached on the computer. Go ahead, and attach or detach your devices! Here is an example output:&lt;br /&gt;
&lt;br /&gt;
[[File:CSharp VS2005 HelloWorld Output.PNG|link=|alt=HelloWorld Output]]&lt;br /&gt;
&lt;br /&gt;
After confirming that the {{Code|HelloWorld}} example is working, you can proceed to run the example for your device. If you aren&#039;t sure what the software example for your device is called, check the software object listed in the [[Device List | Getting Started Guide for your Device]]. Please ensure that you have set your start up project to be the one that matches your device before compiling. &lt;br /&gt;
&lt;br /&gt;
Once you have the C# examples running, we have a [[#Follow the Examples|teaching]] section below to help you follow them.&lt;br /&gt;
&lt;br /&gt;
=====Write Your Own Code=====&lt;br /&gt;
&lt;br /&gt;
When you are building a project from scratch, or adding Phidget function calls to an existing project, you&#039;ll need to configure your environment to properly link the Phidget C# libraries. To begin: &lt;br /&gt;
&lt;br /&gt;
1. Generate a new Visual C# Windows Applications project with a descriptive name such as PhidgetTest. &lt;br /&gt;
&lt;br /&gt;
[[File:CSharp VS2005 New Project.PNG|link=|alt=New Project]]&lt;br /&gt;
&lt;br /&gt;
2. Add a reference to the Phidget .NET library.&lt;br /&gt;
&lt;br /&gt;
[[File:CSharp VS2005 Add Reference.PNG|link=|alt=Add Reference]]&lt;br /&gt;
&lt;br /&gt;
3. Under the .NET tab, select {{Code|Phidget21.NET.dll}}.&lt;br /&gt;
If you used our installer, these files are installed in {{Code|C:\Program Files\Phidgets}}, by default. If it does not appear in this list, then you can browse to the Phidget Framework installation directory and add the file.&lt;br /&gt;
&lt;br /&gt;
[[File:CSharp VS2005 Add Reference 2.PNG|link=|alt=Add Reference]]&lt;br /&gt;
&lt;br /&gt;
4. Then, in your code, you will need to include the Phidget .NET library:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=csharp&amp;gt;&lt;br /&gt;
  using Phidgets;&lt;br /&gt;
  using Phidgets.Events;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The project now has access to the Phidget function calls and you are ready to begin coding.&lt;br /&gt;
&lt;br /&gt;
The same [[#Follow the Examples|teaching ]] section which describes the examples also has further resources for programming your Phidget.&lt;br /&gt;
&lt;br /&gt;
==Follow the Examples==&lt;br /&gt;
&lt;br /&gt;
By following the instructions for your operating system and compiler above, you probably now have a working example and want to understand it better so you can change it to do what you want.  This teaching section has resources for you to learn from the examples and write your own.&lt;br /&gt;
&lt;br /&gt;
Next, comes our API information.  These resources outline the C# Phidget functions:&lt;br /&gt;
&lt;br /&gt;
{{UsingAPhidgetInCodeGeneral|both of which are available in C#|[http://www.phidgets.com/documentation/Phidget21.NET.zip .NET API]}}&lt;br /&gt;
&lt;br /&gt;
===Example Flow===&lt;br /&gt;
&lt;br /&gt;
{{ExamplePseudocode|In C#, you can name these &#039;&#039;&#039;event&#039;&#039;&#039; functions whatever you like.  You will then pass them as function pointers to the Phidget .NET library below in the Main Code section.  This hooks them into the actual events when they occur. &amp;lt;br&amp;gt; &lt;br /&gt;
In the example code, the event functions common to all Phidgets are called things like &#039;&#039;&#039;AttachHandler()&#039;&#039;&#039; and &#039;&#039;&#039;DetachHandler()&#039;&#039;&#039;, etc.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Some event functions will be specific to each device, like when a tag is read on an RFID board, or when a sensor value changes on an Interface Kit.&lt;br /&gt;
Other functions are given in the examples to show you more detail on using your Phidget.  For example, &#039;&#039;&#039;DeviceInitialize()&#039;&#039;&#039; will show what needs to be set up for your Phidget before using it.&lt;br /&gt;
|Creating a Phidget software object in C# is specific to the Phidget.  For a Phidget Spatial, for example, this would involve creating a {{Code|Spatial}} object.  The examples show how to do this and other API functions.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
The object provides device specific methods and properties which are available from the API for your specific Phidget.|&lt;br /&gt;
[http://www.phidgets.com/documentation/Phidget21.NET.zip .NET API]}}&lt;br /&gt;
&lt;br /&gt;
===Code Snippets===&lt;br /&gt;
&lt;br /&gt;
==Common Problems and Solutions/Workarounds==&lt;br /&gt;
&lt;br /&gt;
==={{ProblemSolution|All Operating Systems|The Phidgets.Events.ErrorEventHandler conflicts with System.IO.ErrorEventHandler.}}===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=csharp&amp;gt;&lt;br /&gt;
using System.IO;&lt;br /&gt;
using Phidgets;&lt;br /&gt;
using Phidgets.Events;&lt;br /&gt;
...&lt;br /&gt;
spatial.Error += new ErrorEventHandler(spatial_Error);&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
void spatial_Error(object sender, ErrorEventArgs e){&lt;br /&gt;
   ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above code produces the following errors:&lt;br /&gt;
&lt;br /&gt;
{{Code|&#039;ErrorEventHandler&#039; is an ambiguous reference between &#039;System.IO.ErrorEventHandler&#039; and &#039;Phidgets.Events.ErrorEventHandler&#039;}}.&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
{{Code|&#039;ErrorEventArgs&#039; is an ambiguous reference between &#039;System.IO.ErrorEventArgs&#039; and &#039;Phidgets.Events.ErrorEventArgs&#039;}}.&lt;br /&gt;
&lt;br /&gt;
The error is due to the {{Code|System.IO}} and {{Code|Phidgets.Events}} namespaces both having a class called {{Code|ErrorEventHandler}}.&lt;br /&gt;
&lt;br /&gt;
To get around this issue, use the fully qualified namespace when referring to the {{Code|ErrorEventHandler}} and {{Code|ErrorEventArgs}} classes:&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=csharp&amp;gt;&lt;br /&gt;
using System.IO;&lt;br /&gt;
using Phidgets;&lt;br /&gt;
using Phidgets.Events;&lt;br /&gt;
...&lt;br /&gt;
spatial.Error += new Phidgets.Events.ErrorEventHandler(spatial_Error);&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
void spatial_Error(object sender, Phidgets.Events.ErrorEventArgs e){&lt;br /&gt;
   ...&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;/div&gt;</summary>
		<author><name>Djrudiak</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=Language_-_C_Sharp_(.NET_Compact_Framework)&amp;diff=19254</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=19254"/>
		<updated>2012-04-24T21:07:30Z</updated>

		<summary type="html">&lt;p&gt;Djrudiak: /* Use Our Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Language]]&lt;br /&gt;
{{OSLang|[[File:icon-CSharp.png|64x64px|link=|alt=]]|C#(.NET Compact Framework) is a modern, object-oriented programming language developed by [[http://www.microsoft.com Microsoft]] intended for developing applications for smart devices.}}&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
{{LanguageSupport|C#(.NET Compact Framework)|the complete Phidget API, including events|all Phidget devices.|the .NET Compact Framework. This frameworks is supported on devices with the Windows CE operating system. We provide instructions on how to set up your environment/compilers for [[#Visual Studio 2005/2008/2010 | Visual Studio 2005/2008/2010]]|}}&lt;br /&gt;
&lt;br /&gt;
==Quick Downloads==&lt;br /&gt;
{{QuickDownloads|C#(.NET Compact Framework)|&lt;br /&gt;
{{APIQuickDownloads|http://www.phidgets.com/documentation/Phidget21.NET.zip .NET}}|&lt;br /&gt;
{{ExampleQuickDownloads|http://www.phidgets.com/downloads/examples/CE_2.1.8.20120216.zip|}}|&lt;br /&gt;
{{ExtraLibraryQuickDownloads|http://www.phidgets.com/downloads/libraries/Phidget21-wincedevel_2.1.8.20120216.zip|Phidget Windows CE|(all architectures)}}&lt;br /&gt;
{{ExtraLibraryQuickDownloads|http://www.phidgets.com/downloads/libraries/Phidget21ARMV4I_2.1.8.20120216.CAB|Windows CE|Installer(ARMV4I)}}&lt;br /&gt;
{{ExtraLibraryQuickDownloads|http://www.phidgets.com/downloads/libraries/Phidget21x86_2.1.8.20120216.CAB|Windows CE|Installer(x86)}}&lt;br /&gt;
{{ExtraLibraryQuickDownloads|http://www.phidgets.com/downloads/libraries/Phidget21MIPSII_2.1.8.20120216.CAB|Windows CE|Installer(MIPSII)}}&lt;br /&gt;
}}&lt;br /&gt;
The source code for the Phidget Kernel driver for Windows CE is also provided:&lt;br /&gt;
* [http://www.phidgets.com/downloads/libraries/Phidget21CEkernalsource_2.1.8.20120216.zip Kernel Driver Source(all architectures)]&lt;br /&gt;
&lt;br /&gt;
==Getting started with C#(.NET Compact Framework)==&lt;br /&gt;
&lt;br /&gt;
If you are new to writing code for Phidgets, we recommend starting by running, then modifying existing examples. This will allow you to:&lt;br /&gt;
{{ExampleCodeReasons}}&lt;br /&gt;
&lt;br /&gt;
To develop applications on Windows CE, you will need a Windows(2000/XP/Vista/7) system in order to perform development on. The drivers can be easily installed onto the Windows CE system by using the installers in the [[#Libraries and Drivers | Libraries and Drivers]] section. You will also need the (.NET Compact Framework Libraries) on your development system to code against.&lt;br /&gt;
&lt;br /&gt;
==Windows (2000/XP/Vista/7)==&lt;br /&gt;
&lt;br /&gt;
===Description of Library Files===&lt;br /&gt;
C#(.NET Compact Framework) programs on Windows depend on the following files, which the installers above put onto your system:&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|phidget21.dll}}&amp;lt;/b&amp;gt; contains the actual Phidget library, which is used at run-time.  &lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|phidget.dll}}&amp;lt;/b&amp;gt; is the Phidgets kernel driver.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|Phidget21CE.NET.dll}}&amp;lt;/b&amp;gt; is the .NET(Compact Framework) Phidgets library.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|PhidgetWebService21.exe}}&amp;lt;/b&amp;gt; is used to control Phidgets remotely across a network using the [[#WebService | PhidgetWebservce]].&lt;br /&gt;
&lt;br /&gt;
If you do not want to use our installer, you can download the [http://www.phidgets.com/downloads/libraries/Phidget21-wincedevel_2.1.8.20120216.zip files]. Inside the zip file, please use the files that pertain to your architecture. These files should be placed in the {{Code|\Windows}} folder.&lt;br /&gt;
&lt;br /&gt;
===Visual Studio 2005/2008/2010===&lt;br /&gt;
&lt;br /&gt;
=====Use Our Examples=====&lt;br /&gt;
&lt;br /&gt;
We will start by downloading the examples and building an executable for them on the development machine. Visual Studio will be used for development. We will then transfer the executable onto the Windows CE machine to run.&lt;br /&gt;
&lt;br /&gt;
Please start by downloading the [http://www.phidgets.com/downloads/examples/CE_2.1.8.20120216.zip examples] and unpack them into a folder.  While these examples were written in Visual Studio 2005 and 2008, Visual Studio 2010 will easily open and upgrade them. To load all projects in Visual Studio, go to File &amp;amp;rarr; Open &amp;amp;rarr; Project, and open {{Code|WindowsCE.NET Examples.sln}} or {{Code|WindowsCE.NET Examples_vs2008.sln}} for Visual Studio 2005 and 2008, respectively.&lt;br /&gt;
&lt;br /&gt;
If you are opening the Phidget examples in Visual Studio 2010, you will need to go through the Visual Studio Conversion Wizard to convert the 2005 or 2008 project. &lt;br /&gt;
&lt;br /&gt;
[[File:VS2005 Conversion Wizard.PNG|link=|alt=Conversion Wizard]]&lt;br /&gt;
&lt;br /&gt;
The easiest way to confirm that your environment is set up properly will be to compile and run the {{Code|HelloWorld}} C#(.NET Compact Framework) example.&lt;br /&gt;
&lt;br /&gt;
Start by setting the {{Code|HelloWorld}} project as your start up project.&lt;br /&gt;
&lt;br /&gt;
Next, build the example project. Right click the {{Code|HelloWorld}} project and select {{Code|Build}} to create an executable. &lt;br /&gt;
&lt;br /&gt;
[[File:VS2005 CSharpCompact Build.PNG|link=|alt=Build]]&lt;br /&gt;
&lt;br /&gt;
Then in Windows Explorer, navigate to the {{Code|project directory\bin\Debug}} folder if you are targeting a debug configuration. The folder will be {{Code|project directory\bin\Release}} if you are targeting a release configuration. Regardless of whether you are targeting debug or release, you will find an executable named {{Code|HelloWorld.exe}}. Transfer this file onto the Windows CE system. &lt;br /&gt;
&lt;br /&gt;
The only thing left to do is to run the example! Double click on the executable on the Windows CE system to run it. &lt;br /&gt;
&lt;br /&gt;
This program will detect for devices that are attached/detached on the computer. Go ahead, and attach or detach your devices! &lt;br /&gt;
&lt;br /&gt;
After confirming that the {{Code|HelloWorld}} example is working, you can proceed to run the example for your device. If you aren&#039;t sure what the software example for your device is called, check the software object listed in the [[Device List | Getting Started Guide for your Device]]. Currently, the only devices we have example code is for the PhidgetInterfaceKit, PhidgetRFID, PhidgetTextLCD. Please ensure that you have set your start up project to be the one that matches your device before compiling. &lt;br /&gt;
&lt;br /&gt;
Once you have the C#(.NET Compact Framework) examples running, we have a [[#Follow the Examples|teaching]] section below to help you follow them.&lt;br /&gt;
&lt;br /&gt;
=====Write Your Own Code=====&lt;br /&gt;
&lt;br /&gt;
On the development computer, when you are building a project from scratch, or adding Phidget function calls to an existing project, you&#039;ll need to configure your environment to properly link the Phidget C#(.NET Compact Framework) libraries. To begin: &lt;br /&gt;
&lt;br /&gt;
1. Generate a new smart device Windows CE C# Console Applications project with a descriptive name such as PhidgetTest. &lt;br /&gt;
&lt;br /&gt;
[[File:VS2005 CSharpCompact New Project.PNG|link=|alt=New Project]]&lt;br /&gt;
&lt;br /&gt;
2. Add a reference to the Phidget .NET library.&lt;br /&gt;
&lt;br /&gt;
[[File:VS2005 CSharpCompact Add Reference 1.PNG|link=|alt=Add Reference]]&lt;br /&gt;
&lt;br /&gt;
3. Download the [http://www.phidgets.com/downloads/libraries/Phidget21-wincedevel_2.1.8.20120216.zip {{Code|Phidget21CE.NET.dll}}] file. The file is contained in the zip file. &lt;br /&gt;
&lt;br /&gt;
4. Under the .NET tab, select {{Code|Phidget21CE.NET.dll}}.&lt;br /&gt;
&lt;br /&gt;
[[File:VS2005 CSharpCompact Add Reference 2.PNG|link=|alt=Add Reference]]&lt;br /&gt;
&lt;br /&gt;
5. Then, in your code, you will need to include the Phidget .NET library:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=csharp&amp;gt;&lt;br /&gt;
  using Phidgets;&lt;br /&gt;
  using Phidgets.Events;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The project now has access to the Phidget function calls and you are ready to begin coding.&lt;br /&gt;
&lt;br /&gt;
The same [[#Follow the Examples|teaching ]] section which describes the examples also has further resources for programming your Phidget.&lt;br /&gt;
&lt;br /&gt;
==Follow the Examples==&lt;br /&gt;
&lt;br /&gt;
By following the instructions for your operating system and compiler above, you probably now have a working example and want to understand it better so you can change it to do what you want.  This teaching section has resources for you to learn from the examples and write your own.&lt;br /&gt;
&lt;br /&gt;
Next, comes our API information.  These resources outline the C#(.NET Compact Framework) Phidget functions:&lt;br /&gt;
&lt;br /&gt;
{{UsingAPhidgetInCodeGeneral|both of which are available in C#|[http://www.phidgets.com/documentation/Phidget21.NET.zip .NET API]}}&lt;br /&gt;
&lt;br /&gt;
Here, you can find further examples. Coding in C#(.NET Compact Framework) is very similar to coding in C#, so you can take a look at our resources on the [[#Language - C Sharp | C# section]].&lt;br /&gt;
&lt;br /&gt;
===Example Flow===&lt;br /&gt;
&lt;br /&gt;
{{ExamplePseudocode|In C#(.NET Compact Framework), you can name these &#039;&#039;&#039;event&#039;&#039;&#039; functions whatever you like.  You will then pass them as function pointers to the Phidget .NET library below in the Main Code section.  This hooks them into the actual events when they occur. &amp;lt;br&amp;gt; &lt;br /&gt;
In the example code, the event functions common to all Phidgets are called things like &#039;&#039;&#039;AttachHandler()&#039;&#039;&#039; and &#039;&#039;&#039;DetachHandler()&#039;&#039;&#039;, etc.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Some event functions will be specific to each device, like when a tag is read on an RFID board, or when a sensor value changes on an Interface Kit.&lt;br /&gt;
Other functions are given in the examples to show you more detail on using your Phidget.  For example, &#039;&#039;&#039;DeviceInitialize()&#039;&#039;&#039; will show what needs to be set up for your Phidget before using it.&lt;br /&gt;
|Creating a Phidget software object in C#(.NET Compact Framework) is specific to the Phidget.  For a Phidget Spatial, for example, this would involve creating a {{Code|Spatial}} object.  The examples show how to do this and other API functions.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
The object provides device specific methods and properties which are available from the API for your specific Phidget.|&lt;br /&gt;
[http://www.phidgets.com/documentation/Phidget21.NET.zip .NET API]}}&lt;br /&gt;
&lt;br /&gt;
==Code Snippets==&lt;br /&gt;
&lt;br /&gt;
==Common Problems and Solutions/Workarounds==&lt;br /&gt;
&lt;br /&gt;
==={{ProblemSolution|All Operating Systems|The Phidgets.Events.ErrorEventHandler conflicts with System.IO.ErrorEventHandler.}}===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=csharp&amp;gt;&lt;br /&gt;
using System.IO;&lt;br /&gt;
using Phidgets;&lt;br /&gt;
using Phidgets.Events;&lt;br /&gt;
...&lt;br /&gt;
spatial.Error += new ErrorEventHandler(spatial_Error);&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
void spatial_Error(object sender, ErrorEventArgs e){&lt;br /&gt;
   ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above code produces the following errors:&lt;br /&gt;
&lt;br /&gt;
{{Code|&#039;ErrorEventHandler&#039; is an ambiguous reference between &#039;System.IO.ErrorEventHandler&#039; and &#039;Phidgets.Events.ErrorEventHandler&#039;}}.&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
{{Code|&#039;ErrorEventArgs&#039; is an ambiguous reference between &#039;System.IO.ErrorEventArgs&#039; and &#039;Phidgets.Events.ErrorEventArgs&#039;}}.&lt;br /&gt;
&lt;br /&gt;
The error is due to the {{Code|System.IO}} and {{Code|Phidgets.Events}} namespaces both having a class called {{Code|ErrorEventHandler}}.&lt;br /&gt;
&lt;br /&gt;
To get around this issue, use the fully qualified namespace when referring to the {{Code|ErrorEventHandler}} and {{Code|ErrorEventArgs}} classes:&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=csharp&amp;gt;&lt;br /&gt;
using System.IO;&lt;br /&gt;
using Phidgets;&lt;br /&gt;
using Phidgets.Events;&lt;br /&gt;
...&lt;br /&gt;
spatial.Error += new Phidgets.Events.ErrorEventHandler(spatial_Error);&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
void spatial_Error(object sender, Phidgets.Events.ErrorEventArgs e){&lt;br /&gt;
   ...&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;/div&gt;</summary>
		<author><name>Djrudiak</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=Language_-_Visual_Basic_(.NET_Compact_Framework)&amp;diff=19211</id>
		<title>Language - Visual Basic (.NET Compact Framework)</title>
		<link rel="alternate" type="text/html" href="https://www.phidgets.com/docs21/index.php?title=Language_-_Visual_Basic_(.NET_Compact_Framework)&amp;diff=19211"/>
		<updated>2012-04-20T21:48:26Z</updated>

		<summary type="html">&lt;p&gt;Djrudiak: /* Use Our Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Language]]&lt;br /&gt;
{{OSLang|[[File:icon-Visual Basic Net.png|64x64px|link=|alt=]]|Visual Basic(.NET Compact Framework) is a modern, object-oriented programming language developed by [[http://www.microsoft.com Microsoft]] intended for developing applications for smart devices.}}&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
{{LanguageSupport|Visual Basic(.NET Compact Framework)|the complete Phidget API, including events|all Phidget devices.|the .NET Compact Framework. This frameworks is supported on devices with the Windows CE operating system. We provide instructions on how to set up your environment/compilers for [[#Visual Studio 2005/2008/2010 | Visual Studio 2005/2008/2010]]|}}&lt;br /&gt;
&lt;br /&gt;
==Quick Downloads==&lt;br /&gt;
{{QuickDownloads|Visual Basic(.NET Compact Framework)|&lt;br /&gt;
{{APIQuickDownloads|http://www.phidgets.com/documentation/Phidget21.NET.zip .NET}}|&lt;br /&gt;
{{ExampleQuickDownloads|http://www.phidgets.com/downloads/examples/CE_2.1.8.20120216.zip|}}|&lt;br /&gt;
{{ExtraLibraryQuickDownloads|http://www.phidgets.com/downloads/libraries/Phidget21-wincedevel_2.1.8.20120216.zip|Phidget Windows CE|(all architectures)}}&lt;br /&gt;
{{ExtraLibraryQuickDownloads|http://www.phidgets.com/downloads/libraries/Phidget21ARMV4I_2.1.8.20120216.CAB|Windows CE|Installer(ARMV4I)}}&lt;br /&gt;
{{ExtraLibraryQuickDownloads|http://www.phidgets.com/downloads/libraries/Phidget21x86_2.1.8.20120216.CAB|Windows CE|Installer(x86)}}&lt;br /&gt;
{{ExtraLibraryQuickDownloads|http://www.phidgets.com/downloads/libraries/Phidget21MIPSII_2.1.8.20120216.CAB|Windows CE|Installer(MIPSII)}}&lt;br /&gt;
}}&lt;br /&gt;
The source code for the Phidget Kernel driver for Windows CE is also provided:&lt;br /&gt;
* [http://www.phidgets.com/downloads/libraries/Phidget21CEkernalsource_2.1.8.20120216.zip Kernel Driver Source(all architectures)]&lt;br /&gt;
&lt;br /&gt;
==Getting started with Visual Basic(.NET Compact Framework)==&lt;br /&gt;
&lt;br /&gt;
If you are new to writing code for Phidgets, we recommend starting by running, then modifying existing examples. This will allow you to:&lt;br /&gt;
{{ExampleCodeReasons}}&lt;br /&gt;
&lt;br /&gt;
To develop applications on Windows CE, you will need a Windows(2000/XP/Vista/7) system in order to perform development on. The drivers can be easily installed onto the Windows CE system by using the installers in the [[#Libraries and Drivers | Libraries and Drivers]] section. You will also need the (.NET Compact Framework Libraries) on your development system to code against.&lt;br /&gt;
&lt;br /&gt;
==Windows (2000/XP/Vista/7)==&lt;br /&gt;
&lt;br /&gt;
===Description of Library Files===&lt;br /&gt;
Visual Basic(.NET Compact Framework) programs on Windows depend on the following files, which the installers above put onto your system:&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|phidget21.dll}}&amp;lt;/b&amp;gt; contains the actual Phidget library, which is used at run-time.  &lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|phidget.dll}}&amp;lt;/b&amp;gt; is the Phidgets kernel driver.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|Phidget21CE.NET.dll}}&amp;lt;/b&amp;gt; is the .NET(Compact Framework) Phidgets library.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|PhidgetWebService21.exe}}&amp;lt;/b&amp;gt; is used to control Phidgets remotely across a network using the [[#WebService | PhidgetWebservce]].&lt;br /&gt;
&lt;br /&gt;
If you do not want to use our installer, you can download the [http://www.phidgets.com/downloads/libraries/Phidget21-wincedevel_2.1.8.20120216.zip files]. Inside the zip file, please use the files that pertain to your architecture. These files should be placed in the {{Code|\Windows}} folder.&lt;br /&gt;
&lt;br /&gt;
===Visual Studio 2008/2010===&lt;br /&gt;
&lt;br /&gt;
=====Use Our Examples=====&lt;br /&gt;
&lt;br /&gt;
We will start by downloading the examples and building an executable for them on the development machine. Visual Studio will be used for development. We will then transfer the executable onto the Windows CE machine to run.&lt;br /&gt;
&lt;br /&gt;
Please start by downloading the [http://www.phidgets.com/downloads/examples/CE_2.1.8.20120216.zip examples] and unpack them into a folder.  While these examples were written in Visual Studio 2008, Visual Studio 2010 will easily open and upgrade them. Please note that we do not have examples for Visual Studio 2005. &lt;br /&gt;
&lt;br /&gt;
If you are opening the Phidget examples in Visual Studio 2010, you will need to go through the Visual Studio Conversion Wizard to convert the 2008 project.&lt;br /&gt;
 &lt;br /&gt;
[[File:VS2005 Conversion Wizard.PNG|link=|alt=Conversion Wizard]]&lt;br /&gt;
&lt;br /&gt;
The easiest way to confirm that your environment is set up properly will be to compile and run the {{Code|HelloWorld}} Visual Basic(.NET Compact Framework) example.&lt;br /&gt;
&lt;br /&gt;
Next, build the example project. Right click the {{Code|HelloWorld}} project and select {{Code|Build}} to create an executable. &lt;br /&gt;
&lt;br /&gt;
[[File:VS2008 VBNETCompact Build.PNG|link=|alt=Build]]&lt;br /&gt;
&lt;br /&gt;
Then in Windows Explorer, navigate to the {{Code|project directory\bin\Debug}} folder if you are targeting a debug configuration. The folder will be {{Code|project directory\bin\Release}} if you are targeting a release configuration. Regardless of whether you are targeting debug or release, you will find an executable named {{Code|HelloWorld.exe}}. Transfer this file onto the Windows CE system. &lt;br /&gt;
&lt;br /&gt;
The only thing left to do is to run the example! Double click on the executable on the Windows CE system to run it. &lt;br /&gt;
&lt;br /&gt;
This program will detect for devices that are attached/detached on the computer. Go ahead, and attach or detach your devices! &lt;br /&gt;
&lt;br /&gt;
After confirming that the {{Code|HelloWorld}} example is working, you can proceed to run the example for your device. If you aren&#039;t sure what the software example for your device is called, check the software object listed in the [[Device List | Getting Started Guide for your Device]]. Currently, the only devices we have example code is for the PhidgetInterfaceKit, PhidgetRFID, PhidgetTextLCD. Please ensure that you have set your start up project to be the one that matches your device before compiling. &lt;br /&gt;
&lt;br /&gt;
Once you have the Visual Basic(.NET Compact Framework) examples running, we have a [[#Follow the Examples|teaching]] section below to help you follow them.&lt;br /&gt;
&lt;br /&gt;
=====Write Your Own Code=====&lt;br /&gt;
&lt;br /&gt;
On the development computer, when you are building a project from scratch, or adding Phidget function calls to an existing project, you&#039;ll need to configure your environment to properly link the Phidget Visual Basic(.NET Compact Framework) libraries. To begin: &lt;br /&gt;
&lt;br /&gt;
1. Generate a new smart device Visual Basic Console Applications project with a descriptive name such as PhidgetTest. &lt;br /&gt;
&lt;br /&gt;
[[File:VS2008 VBNETCompact New Project 1.PNG|link=|alt=New Project]]&lt;br /&gt;
&lt;br /&gt;
[[File:VS2008 VBNETCompact New Project 2.PNG|link=|alt=New Project]]&lt;br /&gt;
&lt;br /&gt;
2. Add a reference to the Phidget .NET library.&lt;br /&gt;
&lt;br /&gt;
[[File:VS2008 VBNETCompact Add Reference 1.PNG|link=|alt=Add Reference]]&lt;br /&gt;
&lt;br /&gt;
3. Download the [http://www.phidgets.com/downloads/libraries/Phidget21-wincedevel_2.1.8.20120216.zip {{Code|Phidget21CE.NET.dll}}] file. The file is contained in the zip file. &lt;br /&gt;
&lt;br /&gt;
4. Under the .NET tab, select {{Code|Phidget21CE.NET.dll}}.&lt;br /&gt;
&lt;br /&gt;
[[File:VS2008 VBNETCompact Add Reference 2.PNG|link=|alt=Add Reference]]&lt;br /&gt;
&lt;br /&gt;
5. Then, in your code, you will need to include the Phidget .NET library:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=csharp&amp;gt;&lt;br /&gt;
  using Phidgets;&lt;br /&gt;
  using Phidgets.Events;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The project now has access to the Phidget function calls and you are ready to begin coding.&lt;br /&gt;
&lt;br /&gt;
The same [[#Follow the Examples|teaching ]] section which describes the examples also has further resources for programming your Phidget.&lt;br /&gt;
&lt;br /&gt;
==Follow the Examples==&lt;br /&gt;
&lt;br /&gt;
By following the instructions for your operating system and compiler above, you probably now have a working example and want to understand it better so you can change it to do what you want.  This teaching section has resources for you to learn from the examples and write your own.&lt;br /&gt;
&lt;br /&gt;
Next, comes our API information.  These resources outline the Visual Basic(.NET Compact Framework) Phidget functions:&lt;br /&gt;
&lt;br /&gt;
{{UsingAPhidgetInCodeGeneral|both of which are available in Visual Basic|[http://www.phidgets.com/documentation/Phidget21.NET.zip .NET API]}}&lt;br /&gt;
&lt;br /&gt;
Here, you can find further examples. Coding in Visual Basic(.NET Compact Framework) is very similar to coding in Visual Basic, so you can take a look at our resources on the [[#Language - Visual Basic .NET | section]].&lt;br /&gt;
&lt;br /&gt;
===Example Flow===&lt;br /&gt;
&lt;br /&gt;
{{ExamplePseudocode|In Visual Basic(.NET Compact Framework), you can name these &#039;&#039;&#039;event&#039;&#039;&#039; functions whatever you like.  You will then pass them as function pointers to the Phidget .NET library below in the Main Code section.  This hooks them into the actual events when they occur. &amp;lt;br&amp;gt; &lt;br /&gt;
In the example code, the event functions common to all Phidgets are called things like &#039;&#039;&#039;AttachHandler()&#039;&#039;&#039; and &#039;&#039;&#039;DetachHandler()&#039;&#039;&#039;, etc.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Some event functions will be specific to each device, like when a tag is read on an RFID board, or when a sensor value changes on an Interface Kit.&lt;br /&gt;
Other functions are given in the examples to show you more detail on using your Phidget.  For example, &#039;&#039;&#039;DeviceInitialize()&#039;&#039;&#039; will show what needs to be set up for your Phidget before using it.&lt;br /&gt;
|Creating a Phidget software object in Visual Basic(.NET Compact Framework) is specific to the Phidget.  For a Phidget Spatial, for example, this would involve creating a {{Code|Spatial}} object.  The examples show how to do this and other API functions.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
The object provides device specific methods and properties which are available from the API for your specific Phidget.|&lt;br /&gt;
[http://www.phidgets.com/documentation/Phidget21.NET.zip .NET API]}}&lt;br /&gt;
&lt;br /&gt;
==Code Snippets==&lt;br /&gt;
&lt;br /&gt;
==Common Problems and Solutions/Workarounds==&lt;br /&gt;
&lt;br /&gt;
==={{ProblemSolution|All Operating Systems|The Phidgets.Events.ErrorEventHandler conflicts with System.IO.ErrorEventHandler.}}===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=csharp&amp;gt;&lt;br /&gt;
using System.IO;&lt;br /&gt;
using Phidgets;&lt;br /&gt;
using Phidgets.Events;&lt;br /&gt;
...&lt;br /&gt;
spatial.Error += new ErrorEventHandler(spatial_Error);&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
void spatial_Error(object sender, ErrorEventArgs e){&lt;br /&gt;
   ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above code produces the following errors:&lt;br /&gt;
&lt;br /&gt;
{{Code|&#039;ErrorEventHandler&#039; is an ambiguous reference between &#039;System.IO.ErrorEventHandler&#039; and &#039;Phidgets.Events.ErrorEventHandler&#039;}}.&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
{{Code|&#039;ErrorEventArgs&#039; is an ambiguous reference between &#039;System.IO.ErrorEventArgs&#039; and &#039;Phidgets.Events.ErrorEventArgs&#039;}}.&lt;br /&gt;
&lt;br /&gt;
The error is due to the {{Code|System.IO}} and {{Code|Phidgets.Events}} namespaces both having a class called {{Code|ErrorEventHandler}}.&lt;br /&gt;
&lt;br /&gt;
To get around this issue, use the fully qualified namespace when referring to the {{Code|ErrorEventHandler}} and {{Code|ErrorEventArgs}} classes:&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=csharp&amp;gt;&lt;br /&gt;
using System.IO;&lt;br /&gt;
using Phidgets;&lt;br /&gt;
using Phidgets.Events;&lt;br /&gt;
...&lt;br /&gt;
spatial.Error += new Phidgets.Events.ErrorEventHandler(spatial_Error);&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
void spatial_Error(object sender, Phidgets.Events.ErrorEventArgs e){&lt;br /&gt;
   ...&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;/div&gt;</summary>
		<author><name>Djrudiak</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=Language_-_C_Sharp_(.NET_Compact_Framework)&amp;diff=19210</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=19210"/>
		<updated>2012-04-20T21:46:15Z</updated>

		<summary type="html">&lt;p&gt;Djrudiak: /* Use Our Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Language]]&lt;br /&gt;
{{OSLang|[[File:icon-CSharp.png|64x64px|link=|alt=]]|C#(.NET Compact Framework) is a modern, object-oriented programming language developed by [[http://www.microsoft.com Microsoft]] intended for developing applications for smart devices.}}&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
{{LanguageSupport|C#(.NET Compact Framework)|the complete Phidget API, including events|all Phidget devices.|the .NET Compact Framework. This frameworks is supported on devices with the Windows CE operating system. We provide instructions on how to set up your environment/compilers for [[#Visual Studio 2005/2008/2010 | Visual Studio 2005/2008/2010]]|}}&lt;br /&gt;
&lt;br /&gt;
==Quick Downloads==&lt;br /&gt;
{{QuickDownloads|C#(.NET Compact Framework)|&lt;br /&gt;
{{APIQuickDownloads|http://www.phidgets.com/documentation/Phidget21.NET.zip .NET}}|&lt;br /&gt;
{{ExampleQuickDownloads|http://www.phidgets.com/downloads/examples/CE_2.1.8.20120216.zip|}}|&lt;br /&gt;
{{ExtraLibraryQuickDownloads|http://www.phidgets.com/downloads/libraries/Phidget21-wincedevel_2.1.8.20120216.zip|Phidget Windows CE|(all architectures)}}&lt;br /&gt;
{{ExtraLibraryQuickDownloads|http://www.phidgets.com/downloads/libraries/Phidget21ARMV4I_2.1.8.20120216.CAB|Windows CE|Installer(ARMV4I)}}&lt;br /&gt;
{{ExtraLibraryQuickDownloads|http://www.phidgets.com/downloads/libraries/Phidget21x86_2.1.8.20120216.CAB|Windows CE|Installer(x86)}}&lt;br /&gt;
{{ExtraLibraryQuickDownloads|http://www.phidgets.com/downloads/libraries/Phidget21MIPSII_2.1.8.20120216.CAB|Windows CE|Installer(MIPSII)}}&lt;br /&gt;
}}&lt;br /&gt;
The source code for the Phidget Kernel driver for Windows CE is also provided:&lt;br /&gt;
* [http://www.phidgets.com/downloads/libraries/Phidget21CEkernalsource_2.1.8.20120216.zip Kernel Driver Source(all architectures)]&lt;br /&gt;
&lt;br /&gt;
==Getting started with C#(.NET Compact Framework)==&lt;br /&gt;
&lt;br /&gt;
If you are new to writing code for Phidgets, we recommend starting by running, then modifying existing examples. This will allow you to:&lt;br /&gt;
{{ExampleCodeReasons}}&lt;br /&gt;
&lt;br /&gt;
To develop applications on Windows CE, you will need a Windows(2000/XP/Vista/7) system in order to perform development on. The drivers can be easily installed onto the Windows CE system by using the installers in the [[#Libraries and Drivers | Libraries and Drivers]] section. You will also need the (.NET Compact Framework Libraries) on your development system to code against.&lt;br /&gt;
&lt;br /&gt;
==Windows (2000/XP/Vista/7)==&lt;br /&gt;
&lt;br /&gt;
===Description of Library Files===&lt;br /&gt;
C#(.NET Compact Framework) programs on Windows depend on the following files, which the installers above put onto your system:&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|phidget21.dll}}&amp;lt;/b&amp;gt; contains the actual Phidget library, which is used at run-time.  &lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|phidget.dll}}&amp;lt;/b&amp;gt; is the Phidgets kernel driver.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|Phidget21CE.NET.dll}}&amp;lt;/b&amp;gt; is the .NET(Compact Framework) Phidgets library.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|PhidgetWebService21.exe}}&amp;lt;/b&amp;gt; is used to control Phidgets remotely across a network using the [[#WebService | PhidgetWebservce]].&lt;br /&gt;
&lt;br /&gt;
If you do not want to use our installer, you can download the [http://www.phidgets.com/downloads/libraries/Phidget21-wincedevel_2.1.8.20120216.zip files]. Inside the zip file, please use the files that pertain to your architecture. These files should be placed in the {{Code|\Windows}} folder.&lt;br /&gt;
&lt;br /&gt;
===Visual Studio 2005/2008/2010===&lt;br /&gt;
&lt;br /&gt;
=====Use Our Examples=====&lt;br /&gt;
&lt;br /&gt;
We will start by downloading the examples and building an executable for them on the development machine. Visual Studio will be used for development. We will then transfer the executable onto the Windows CE machine to run.&lt;br /&gt;
&lt;br /&gt;
Please start by downloading the [http://www.phidgets.com/downloads/examples/CE_2.1.8.20120216.zip examples] and unpack them into a folder.  While these examples were written in Visual Studio 2005 and 2008, Visual Studio 2010 will easily open and upgrade them. To load all projects in Visual Studio, go to File &amp;amp;rarr; Open &amp;amp;rarr; Project, and open {{Code|WindowsCE.NET Examples.sln}} or {{Code|WindowsCE.NET Examples_vs2008.sln}} for Visual Studio 2005 and 2008, respectively.&lt;br /&gt;
&lt;br /&gt;
If you are opening the Phidget examples in Visual Studio 2010, you will need to go through the Visual Studio Conversion Wizard to convert the 2005 or 2008 project. &lt;br /&gt;
[[File:VS2005 Conversion Wizard.PNG|link=|alt=Conversion Wizard]]&lt;br /&gt;
&lt;br /&gt;
The easiest way to confirm that your environment is set up properly will be to compile and run the {{Code|HelloWorld}} C#(.NET Compact Framework) example.&lt;br /&gt;
&lt;br /&gt;
Start by setting the {{Code|HelloWorld}} project as your start up project.&lt;br /&gt;
&lt;br /&gt;
Next, build the example project. Right click the {{Code|HelloWorld}} project and select {{Code|Build}} to create an executable. &lt;br /&gt;
&lt;br /&gt;
[[File:VS2005 CSharpCompact Build.PNG|link=|alt=Build]]&lt;br /&gt;
&lt;br /&gt;
Then in Windows Explorer, navigate to the {{Code|project directory\bin\Debug}} folder if you are targeting a debug configuration. The folder will be {{Code|project directory\bin\Release}} if you are targeting a release configuration. Regardless of whether you are targeting debug or release, you will find an executable named {{Code|HelloWorld.exe}}. Transfer this file onto the Windows CE system. &lt;br /&gt;
&lt;br /&gt;
The only thing left to do is to run the example! Double click on the executable on the Windows CE system to run it. &lt;br /&gt;
&lt;br /&gt;
This program will detect for devices that are attached/detached on the computer. Go ahead, and attach or detach your devices! &lt;br /&gt;
&lt;br /&gt;
After confirming that the {{Code|HelloWorld}} example is working, you can proceed to run the example for your device. If you aren&#039;t sure what the software example for your device is called, check the software object listed in the [[Device List | Getting Started Guide for your Device]]. Currently, the only devices we have example code is for the PhidgetInterfaceKit, PhidgetRFID, PhidgetTextLCD. Please ensure that you have set your start up project to be the one that matches your device before compiling. &lt;br /&gt;
&lt;br /&gt;
Once you have the C#(.NET Compact Framework) examples running, we have a [[#Follow the Examples|teaching]] section below to help you follow them.&lt;br /&gt;
&lt;br /&gt;
=====Write Your Own Code=====&lt;br /&gt;
&lt;br /&gt;
On the development computer, when you are building a project from scratch, or adding Phidget function calls to an existing project, you&#039;ll need to configure your environment to properly link the Phidget C#(.NET Compact Framework) libraries. To begin: &lt;br /&gt;
&lt;br /&gt;
1. Generate a new smart device Windows CE C# Console Applications project with a descriptive name such as PhidgetTest. &lt;br /&gt;
&lt;br /&gt;
[[File:VS2005 CSharpCompact New Project.PNG|link=|alt=New Project]]&lt;br /&gt;
&lt;br /&gt;
2. Add a reference to the Phidget .NET library.&lt;br /&gt;
&lt;br /&gt;
[[File:VS2005 CSharpCompact Add Reference 1.PNG|link=|alt=Add Reference]]&lt;br /&gt;
&lt;br /&gt;
3. Download the [http://www.phidgets.com/downloads/libraries/Phidget21-wincedevel_2.1.8.20120216.zip {{Code|Phidget21CE.NET.dll}}] file. The file is contained in the zip file. &lt;br /&gt;
&lt;br /&gt;
4. Under the .NET tab, select {{Code|Phidget21CE.NET.dll}}.&lt;br /&gt;
&lt;br /&gt;
[[File:VS2005 CSharpCompact Add Reference 2.PNG|link=|alt=Add Reference]]&lt;br /&gt;
&lt;br /&gt;
5. Then, in your code, you will need to include the Phidget .NET library:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=csharp&amp;gt;&lt;br /&gt;
  using Phidgets;&lt;br /&gt;
  using Phidgets.Events;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The project now has access to the Phidget function calls and you are ready to begin coding.&lt;br /&gt;
&lt;br /&gt;
The same [[#Follow the Examples|teaching ]] section which describes the examples also has further resources for programming your Phidget.&lt;br /&gt;
&lt;br /&gt;
==Follow the Examples==&lt;br /&gt;
&lt;br /&gt;
By following the instructions for your operating system and compiler above, you probably now have a working example and want to understand it better so you can change it to do what you want.  This teaching section has resources for you to learn from the examples and write your own.&lt;br /&gt;
&lt;br /&gt;
Next, comes our API information.  These resources outline the C#(.NET Compact Framework) Phidget functions:&lt;br /&gt;
&lt;br /&gt;
{{UsingAPhidgetInCodeGeneral|both of which are available in C#|[http://www.phidgets.com/documentation/Phidget21.NET.zip .NET API]}}&lt;br /&gt;
&lt;br /&gt;
Here, you can find further examples. Coding in C#(.NET Compact Framework) is very similar to coding in C#, so you can take a look at our resources on the [[#Language - C Sharp | C# section]].&lt;br /&gt;
&lt;br /&gt;
===Example Flow===&lt;br /&gt;
&lt;br /&gt;
{{ExamplePseudocode|In C#(.NET Compact Framework), you can name these &#039;&#039;&#039;event&#039;&#039;&#039; functions whatever you like.  You will then pass them as function pointers to the Phidget .NET library below in the Main Code section.  This hooks them into the actual events when they occur. &amp;lt;br&amp;gt; &lt;br /&gt;
In the example code, the event functions common to all Phidgets are called things like &#039;&#039;&#039;AttachHandler()&#039;&#039;&#039; and &#039;&#039;&#039;DetachHandler()&#039;&#039;&#039;, etc.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Some event functions will be specific to each device, like when a tag is read on an RFID board, or when a sensor value changes on an Interface Kit.&lt;br /&gt;
Other functions are given in the examples to show you more detail on using your Phidget.  For example, &#039;&#039;&#039;DeviceInitialize()&#039;&#039;&#039; will show what needs to be set up for your Phidget before using it.&lt;br /&gt;
|Creating a Phidget software object in C#(.NET Compact Framework) is specific to the Phidget.  For a Phidget Spatial, for example, this would involve creating a {{Code|Spatial}} object.  The examples show how to do this and other API functions.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
The object provides device specific methods and properties which are available from the API for your specific Phidget.|&lt;br /&gt;
[http://www.phidgets.com/documentation/Phidget21.NET.zip .NET API]}}&lt;br /&gt;
&lt;br /&gt;
==Code Snippets==&lt;br /&gt;
&lt;br /&gt;
==Common Problems and Solutions/Workarounds==&lt;br /&gt;
&lt;br /&gt;
==={{ProblemSolution|All Operating Systems|The Phidgets.Events.ErrorEventHandler conflicts with System.IO.ErrorEventHandler.}}===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=csharp&amp;gt;&lt;br /&gt;
using System.IO;&lt;br /&gt;
using Phidgets;&lt;br /&gt;
using Phidgets.Events;&lt;br /&gt;
...&lt;br /&gt;
spatial.Error += new ErrorEventHandler(spatial_Error);&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
void spatial_Error(object sender, ErrorEventArgs e){&lt;br /&gt;
   ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above code produces the following errors:&lt;br /&gt;
&lt;br /&gt;
{{Code|&#039;ErrorEventHandler&#039; is an ambiguous reference between &#039;System.IO.ErrorEventHandler&#039; and &#039;Phidgets.Events.ErrorEventHandler&#039;}}.&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
{{Code|&#039;ErrorEventArgs&#039; is an ambiguous reference between &#039;System.IO.ErrorEventArgs&#039; and &#039;Phidgets.Events.ErrorEventArgs&#039;}}.&lt;br /&gt;
&lt;br /&gt;
The error is due to the {{Code|System.IO}} and {{Code|Phidgets.Events}} namespaces both having a class called {{Code|ErrorEventHandler}}.&lt;br /&gt;
&lt;br /&gt;
To get around this issue, use the fully qualified namespace when referring to the {{Code|ErrorEventHandler}} and {{Code|ErrorEventArgs}} classes:&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=csharp&amp;gt;&lt;br /&gt;
using System.IO;&lt;br /&gt;
using Phidgets;&lt;br /&gt;
using Phidgets.Events;&lt;br /&gt;
...&lt;br /&gt;
spatial.Error += new Phidgets.Events.ErrorEventHandler(spatial_Error);&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
void spatial_Error(object sender, Phidgets.Events.ErrorEventArgs e){&lt;br /&gt;
   ...&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;/div&gt;</summary>
		<author><name>Djrudiak</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=Language_-_Visual_Basic_(.NET_Compact_Framework)&amp;diff=19209</id>
		<title>Language - Visual Basic (.NET Compact Framework)</title>
		<link rel="alternate" type="text/html" href="https://www.phidgets.com/docs21/index.php?title=Language_-_Visual_Basic_(.NET_Compact_Framework)&amp;diff=19209"/>
		<updated>2012-04-20T21:41:07Z</updated>

		<summary type="html">&lt;p&gt;Djrudiak: /* Use Our Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Language]]&lt;br /&gt;
{{OSLang|[[File:icon-Visual Basic Net.png|64x64px|link=|alt=]]|Visual Basic(.NET Compact Framework) is a modern, object-oriented programming language developed by [[http://www.microsoft.com Microsoft]] intended for developing applications for smart devices.}}&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
{{LanguageSupport|Visual Basic(.NET Compact Framework)|the complete Phidget API, including events|all Phidget devices.|the .NET Compact Framework. This frameworks is supported on devices with the Windows CE operating system. We provide instructions on how to set up your environment/compilers for [[#Visual Studio 2005/2008/2010 | Visual Studio 2005/2008/2010]]|}}&lt;br /&gt;
&lt;br /&gt;
==Quick Downloads==&lt;br /&gt;
{{QuickDownloads|Visual Basic(.NET Compact Framework)|&lt;br /&gt;
{{APIQuickDownloads|http://www.phidgets.com/documentation/Phidget21.NET.zip .NET}}|&lt;br /&gt;
{{ExampleQuickDownloads|http://www.phidgets.com/downloads/examples/CE_2.1.8.20120216.zip|}}|&lt;br /&gt;
{{ExtraLibraryQuickDownloads|http://www.phidgets.com/downloads/libraries/Phidget21-wincedevel_2.1.8.20120216.zip|Phidget Windows CE|(all architectures)}}&lt;br /&gt;
{{ExtraLibraryQuickDownloads|http://www.phidgets.com/downloads/libraries/Phidget21ARMV4I_2.1.8.20120216.CAB|Windows CE|Installer(ARMV4I)}}&lt;br /&gt;
{{ExtraLibraryQuickDownloads|http://www.phidgets.com/downloads/libraries/Phidget21x86_2.1.8.20120216.CAB|Windows CE|Installer(x86)}}&lt;br /&gt;
{{ExtraLibraryQuickDownloads|http://www.phidgets.com/downloads/libraries/Phidget21MIPSII_2.1.8.20120216.CAB|Windows CE|Installer(MIPSII)}}&lt;br /&gt;
}}&lt;br /&gt;
The source code for the Phidget Kernel driver for Windows CE is also provided:&lt;br /&gt;
* [http://www.phidgets.com/downloads/libraries/Phidget21CEkernalsource_2.1.8.20120216.zip Kernel Driver Source(all architectures)]&lt;br /&gt;
&lt;br /&gt;
==Getting started with Visual Basic(.NET Compact Framework)==&lt;br /&gt;
&lt;br /&gt;
If you are new to writing code for Phidgets, we recommend starting by running, then modifying existing examples. This will allow you to:&lt;br /&gt;
{{ExampleCodeReasons}}&lt;br /&gt;
&lt;br /&gt;
To develop applications on Windows CE, you will need a Windows(2000/XP/Vista/7) system in order to perform development on. The drivers can be easily installed onto the Windows CE system by using the installers in the [[#Libraries and Drivers | Libraries and Drivers]] section. You will also need the (.NET Compact Framework Libraries) on your development system to code against.&lt;br /&gt;
&lt;br /&gt;
==Windows (2000/XP/Vista/7)==&lt;br /&gt;
&lt;br /&gt;
===Description of Library Files===&lt;br /&gt;
Visual Basic(.NET Compact Framework) programs on Windows depend on the following files, which the installers above put onto your system:&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|phidget21.dll}}&amp;lt;/b&amp;gt; contains the actual Phidget library, which is used at run-time.  &lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|phidget.dll}}&amp;lt;/b&amp;gt; is the Phidgets kernel driver.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|Phidget21CE.NET.dll}}&amp;lt;/b&amp;gt; is the .NET(Compact Framework) Phidgets library.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|PhidgetWebService21.exe}}&amp;lt;/b&amp;gt; is used to control Phidgets remotely across a network using the [[#WebService | PhidgetWebservce]].&lt;br /&gt;
&lt;br /&gt;
If you do not want to use our installer, you can download the [http://www.phidgets.com/downloads/libraries/Phidget21-wincedevel_2.1.8.20120216.zip files]. Inside the zip file, please use the files that pertain to your architecture. These files should be placed in the {{Code|\Windows}} folder.&lt;br /&gt;
&lt;br /&gt;
===Visual Studio 2008/2010===&lt;br /&gt;
&lt;br /&gt;
=====Use Our Examples=====&lt;br /&gt;
&lt;br /&gt;
We will start by downloading the examples and building an executable for them on the development machine. Visual Studio will be used for development. We will then transfer the executable onto the Windows CE machine to run.&lt;br /&gt;
&lt;br /&gt;
Please start by downloading the [http://www.phidgets.com/downloads/examples/CE_2.1.8.20120216.zip examples] and unpack them into a folder.  While these examples were written in Visual Studio 2008, Visual Studio 2010 will easily open and upgrade them. Please note that we do not have examples for Visual Studio 2005. &lt;br /&gt;
&lt;br /&gt;
If you are opening the Phidget examples in Visual Studio 2010, you will need to go through the Visual Studio Conversion Wizard to convert the 2008 project.&lt;br /&gt;
 &lt;br /&gt;
[[File:VS2005 Conversion Wizard.PNG|link=|alt=Conversion Wizard]]&lt;br /&gt;
&lt;br /&gt;
The easiest way to confirm that your environment is set up properly will be to compile and run the {{Code|HelloWorld}} Visual Basic(.NET Compact Framework) example.&lt;br /&gt;
&lt;br /&gt;
Next, build the example project. Right click the {{Code|HelloWorld}} project and select {{Code|Build}} to create an executable. &lt;br /&gt;
&lt;br /&gt;
[[File:VS2008 VBNETCompact Build.PNG|link=|alt=Build]]&lt;br /&gt;
&lt;br /&gt;
Then in Windows Explorer, navigate to the {{Code|project directory\bin\Debug}} folder if you are are targeting a debug configuration. The folder will be {{Code|project directory\bin\Release}} if you are targeting a release configuration. Regardless of whether you are targeting debug or release, you will find an executable named {{Code|HelloWorld.exe}}. Transfer this file onto the Windows CE system. &lt;br /&gt;
&lt;br /&gt;
The only thing left to do is to run the example! Double click on the executable on the Windows CE system to run it. &lt;br /&gt;
&lt;br /&gt;
This program will detect for devices that are attached/detached on the computer. Go ahead, and attach or detach your devices! &lt;br /&gt;
&lt;br /&gt;
After confirming that the {{Code|HelloWorld}} example is working, you can proceed to run the example for your device. If you aren&#039;t sure what the software example for your device is called, check the software object listed in the [[Device List | Getting Started Guide for your Device]]. Currently, the only devices we have example code is for the PhidgetInterfaceKit, PhidgetRFID, PhidgetTextLCD. Please ensure that you have set your start up project to be the one that matches your device before compiling. &lt;br /&gt;
&lt;br /&gt;
Once you have the Visual Basic(.NET Compact Framework) examples running, we have a [[#Follow the Examples|teaching]] section below to help you follow them.&lt;br /&gt;
&lt;br /&gt;
=====Write Your Own Code=====&lt;br /&gt;
&lt;br /&gt;
On the development computer, when you are building a project from scratch, or adding Phidget function calls to an existing project, you&#039;ll need to configure your environment to properly link the Phidget Visual Basic(.NET Compact Framework) libraries. To begin: &lt;br /&gt;
&lt;br /&gt;
1. Generate a new smart device Visual Basic Console Applications project with a descriptive name such as PhidgetTest. &lt;br /&gt;
&lt;br /&gt;
[[File:VS2008 VBNETCompact New Project 1.PNG|link=|alt=New Project]]&lt;br /&gt;
&lt;br /&gt;
[[File:VS2008 VBNETCompact New Project 2.PNG|link=|alt=New Project]]&lt;br /&gt;
&lt;br /&gt;
2. Add a reference to the Phidget .NET library.&lt;br /&gt;
&lt;br /&gt;
[[File:VS2008 VBNETCompact Add Reference 1.PNG|link=|alt=Add Reference]]&lt;br /&gt;
&lt;br /&gt;
3. Download the [http://www.phidgets.com/downloads/libraries/Phidget21-wincedevel_2.1.8.20120216.zip {{Code|Phidget21CE.NET.dll}}] file. The file is contained in the zip file. &lt;br /&gt;
&lt;br /&gt;
4. Under the .NET tab, select {{Code|Phidget21CE.NET.dll}}.&lt;br /&gt;
&lt;br /&gt;
[[File:VS2008 VBNETCompact Add Reference 2.PNG|link=|alt=Add Reference]]&lt;br /&gt;
&lt;br /&gt;
5. Then, in your code, you will need to include the Phidget .NET library:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=csharp&amp;gt;&lt;br /&gt;
  using Phidgets;&lt;br /&gt;
  using Phidgets.Events;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The project now has access to the Phidget function calls and you are ready to begin coding.&lt;br /&gt;
&lt;br /&gt;
The same [[#Follow the Examples|teaching ]] section which describes the examples also has further resources for programming your Phidget.&lt;br /&gt;
&lt;br /&gt;
==Follow the Examples==&lt;br /&gt;
&lt;br /&gt;
By following the instructions for your operating system and compiler above, you probably now have a working example and want to understand it better so you can change it to do what you want.  This teaching section has resources for you to learn from the examples and write your own.&lt;br /&gt;
&lt;br /&gt;
Next, comes our API information.  These resources outline the Visual Basic(.NET Compact Framework) Phidget functions:&lt;br /&gt;
&lt;br /&gt;
{{UsingAPhidgetInCodeGeneral|both of which are available in Visual Basic|[http://www.phidgets.com/documentation/Phidget21.NET.zip .NET API]}}&lt;br /&gt;
&lt;br /&gt;
Here, you can find further examples. Coding in Visual Basic(.NET Compact Framework) is very similar to coding in Visual Basic, so you can take a look at our resources on the [[#Language - Visual Basic .NET | section]].&lt;br /&gt;
&lt;br /&gt;
===Example Flow===&lt;br /&gt;
&lt;br /&gt;
{{ExamplePseudocode|In Visual Basic(.NET Compact Framework), you can name these &#039;&#039;&#039;event&#039;&#039;&#039; functions whatever you like.  You will then pass them as function pointers to the Phidget .NET library below in the Main Code section.  This hooks them into the actual events when they occur. &amp;lt;br&amp;gt; &lt;br /&gt;
In the example code, the event functions common to all Phidgets are called things like &#039;&#039;&#039;AttachHandler()&#039;&#039;&#039; and &#039;&#039;&#039;DetachHandler()&#039;&#039;&#039;, etc.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Some event functions will be specific to each device, like when a tag is read on an RFID board, or when a sensor value changes on an Interface Kit.&lt;br /&gt;
Other functions are given in the examples to show you more detail on using your Phidget.  For example, &#039;&#039;&#039;DeviceInitialize()&#039;&#039;&#039; will show what needs to be set up for your Phidget before using it.&lt;br /&gt;
|Creating a Phidget software object in Visual Basic(.NET Compact Framework) is specific to the Phidget.  For a Phidget Spatial, for example, this would involve creating a {{Code|Spatial}} object.  The examples show how to do this and other API functions.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
The object provides device specific methods and properties which are available from the API for your specific Phidget.|&lt;br /&gt;
[http://www.phidgets.com/documentation/Phidget21.NET.zip .NET API]}}&lt;br /&gt;
&lt;br /&gt;
==Code Snippets==&lt;br /&gt;
&lt;br /&gt;
==Common Problems and Solutions/Workarounds==&lt;br /&gt;
&lt;br /&gt;
==={{ProblemSolution|All Operating Systems|The Phidgets.Events.ErrorEventHandler conflicts with System.IO.ErrorEventHandler.}}===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=csharp&amp;gt;&lt;br /&gt;
using System.IO;&lt;br /&gt;
using Phidgets;&lt;br /&gt;
using Phidgets.Events;&lt;br /&gt;
...&lt;br /&gt;
spatial.Error += new ErrorEventHandler(spatial_Error);&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
void spatial_Error(object sender, ErrorEventArgs e){&lt;br /&gt;
   ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above code produces the following errors:&lt;br /&gt;
&lt;br /&gt;
{{Code|&#039;ErrorEventHandler&#039; is an ambiguous reference between &#039;System.IO.ErrorEventHandler&#039; and &#039;Phidgets.Events.ErrorEventHandler&#039;}}.&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
{{Code|&#039;ErrorEventArgs&#039; is an ambiguous reference between &#039;System.IO.ErrorEventArgs&#039; and &#039;Phidgets.Events.ErrorEventArgs&#039;}}.&lt;br /&gt;
&lt;br /&gt;
The error is due to the {{Code|System.IO}} and {{Code|Phidgets.Events}} namespaces both having a class called {{Code|ErrorEventHandler}}.&lt;br /&gt;
&lt;br /&gt;
To get around this issue, use the fully qualified namespace when referring to the {{Code|ErrorEventHandler}} and {{Code|ErrorEventArgs}} classes:&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=csharp&amp;gt;&lt;br /&gt;
using System.IO;&lt;br /&gt;
using Phidgets;&lt;br /&gt;
using Phidgets.Events;&lt;br /&gt;
...&lt;br /&gt;
spatial.Error += new Phidgets.Events.ErrorEventHandler(spatial_Error);&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
void spatial_Error(object sender, Phidgets.Events.ErrorEventArgs e){&lt;br /&gt;
   ...&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;/div&gt;</summary>
		<author><name>Djrudiak</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=Language_-_C_Sharp&amp;diff=19205</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=19205"/>
		<updated>2012-04-20T21:27:27Z</updated>

		<summary type="html">&lt;p&gt;Djrudiak: /* Windows CE */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Language]]&lt;br /&gt;
{{OSLang|[[File:icon-CSharp.png|64x64px|link=|alt=]]|C# is a modern, object-oriented programming language developed by [[http://www.microsoft.com Microsoft]].}}&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
{{LanguageSupport|C#|the complete Phidget API, including events|all Phidget devices.|the .NET or Mono framework. Both of the frameworks are supported on Windows. For Linux and OS X, only the Mono framework can be used. We provide instructions on how to set up your environment/compilers for [[#Visual Studio 2005/2008/2010 | Visual Studio 2005/2008/2010]], [[#Visual Studio 2003 | Visual Studio 2003]], [[#MonoDevelop | MonoDevelop]] and the [[#Mono | Mono command line compilers]]|}}&lt;br /&gt;
&lt;br /&gt;
==Quick Downloads==&lt;br /&gt;
{{QuickDownloads|C#|&lt;br /&gt;
{{APIQuickDownloads|http://www.phidgets.com/documentation/Phidget21.NET.zip .NET}}|&lt;br /&gt;
{{ExampleQuickDownloads|http://www.phidgets.com/downloads/examples/CSharp_2.1.8.20110615.zip|}}|&lt;br /&gt;
{{ExtraLibraryQuickDownloads|http://www.phidgets.com/downloads/libraries/phidget21-x86_2.1.8.20110615.zip|.NET Framework Files|}}&lt;br /&gt;
{{WindowsQuickDownloads}}&lt;br /&gt;
{{MacQuickDownloads}}&lt;br /&gt;
{{LinuxQuickDownloads}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Getting started with C#==&lt;br /&gt;
&lt;br /&gt;
If you are new to writing code for Phidgets, we recommend starting by running, then modifying existing examples. This will allow you to:&lt;br /&gt;
{{ExampleCodeReasons}}&lt;br /&gt;
&lt;br /&gt;
Instructions are divided up by operating system. Choose:&lt;br /&gt;
*[[#Windows(2000/XP/Vista/7)|Windows 2000 / XP / Vista / 7]]&lt;br /&gt;
*[[#OS X |OS X]]&lt;br /&gt;
*[[#Linux | Linux]] (including PhidgetSBC)&lt;br /&gt;
&lt;br /&gt;
==Windows (2000/XP/Vista/7)==&lt;br /&gt;
&lt;br /&gt;
===Description of Library Files===&lt;br /&gt;
C# programs on Windows depend on the following files, which the installers above put onto your system:&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|phidget21.dll}}&amp;lt;/b&amp;gt; contains the actual Phidget library, which is used at run-time.  By default, it is placed in {{Code|C:\Windows\System32}}.&lt;br /&gt;
You will also need one of the following two files, depending on the .NET framework version you are targeting:&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|Phidget21.NET.dll}}&amp;lt;/b&amp;gt; is the Phidget library for .NET framework &amp;lt;i&amp;gt;&amp;lt;b&amp;gt;2.0&amp;lt;/b&amp;gt;&amp;lt;/i&amp;gt; or higher. Your compiler has to know where this file is. By default, it is placed into {{Code|C:\Program Files\Phidgets}}. You can either point your compiler to that location, or copy and link to it in a directory for your project workspace. &lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|Phidget21.NET1.1.dll}}&amp;lt;/b&amp;gt; is the Phidget library for .NET framework &amp;lt;i&amp;gt;&amp;lt;b&amp;gt;1.1&amp;lt;/b&amp;gt;&amp;lt;/i&amp;gt;. Your compiler has to know where this file is. By default, is is placed into {{Code|C:\Program Files\Phidgets}}. You can either point your compiler to that location, or copy and link to it in a directory for your project workspace. &lt;br /&gt;
You can optionally install the following files:&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|Phidget21.NET.XML}}&amp;lt;/b&amp;gt; provides the IntelliSense in-line documentation for the .NET library in Visual Studio/MonoDevelop. This documentation is also visible in the Object Browser in Visual Studio. By default, it is placed into {{Code|C:\Program Files\Phidgets}}. &lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|Policy.2.1.Phidget21.NET.dll}}&amp;lt;/b&amp;gt; is the policy assembly for {{Code|Phidget21.NET.dll}}. Our installer places this file in the Global Assembly Cache(GAC) directory. It directs any programs compiled against version 2.1.0 or higher of {{Code|Phidget21.NET.dll}} to use the most recent installed version. &lt;br /&gt;
&lt;br /&gt;
If you do not want to use our installer, you can download the five [http://www.phidgets.com/downloads/libraries/Phidget21-windevel_2.1.8.20111220.zip files].&lt;br /&gt;
&lt;br /&gt;
Running the examples and writing your own code can be fairly compiler-specific, so we include instructions for each compiler below.&lt;br /&gt;
&lt;br /&gt;
===Visual Studio 2005/2008/2010===&lt;br /&gt;
&lt;br /&gt;
Microsoft makes free versions of Visual Studio available known as Express Editions.  The Express editions are suitable for most applications, but are limited in features for more complex applications. Please see [http://www.microsoft.com/visualstudio Microsoft Visual Studio] for more information.&lt;br /&gt;
&lt;br /&gt;
=====Use Our Examples=====&lt;br /&gt;
&lt;br /&gt;
Please start by downloading the [http://www.phidgets.com/downloads/examples/CSharp_2.1.8.20110615.zip examples] and unpack them into a folder.  While these examples were written in Visual Studio 2005 and 2008, Visual Studio 2010 will easily open and upgrade them. To load all projects in Visual Studio, go to File &amp;amp;rarr; Open &amp;amp;rarr; Project, and open {{Code|AllExamples/AllExamples.sln}} or {{Code|AllExamples/AllExamples_vs2008.sln}} for Visual Studio 2005 and 2008, respectively.&lt;br /&gt;
&lt;br /&gt;
If you are opening the Phidget examples in Visual Studio 2010, you will need to go through the Visual Studio Conversion Wizard to convert the 2005 or 2008 project. &lt;br /&gt;
[[File:VS2005 Conversion Wizard.PNG|link=|alt=Conversion Wizard]]&lt;br /&gt;
&lt;br /&gt;
The easiest way to confirm that your environment is set up properly will be to compile and run the {{Code|HelloWorld}} C/C++ example.&lt;br /&gt;
&lt;br /&gt;
Start by setting the {{Code|HelloWorld}} project as your start up project.&lt;br /&gt;
&lt;br /&gt;
The only thing left to do is to run the example! Click on Debug &amp;amp;rarr; Start Debugging. Please note that the projects, by default try to find the {{Code|Phidget21.NET.dll}} in the {{Code|C:\Program Files\Phidgets}}. If you have it installed in another location, please change the path to the file&#039;s location accordingly. If you are receiving an error message regarding that the namespace Phidgets cannot be found, please re-add the reference to {{Code|Phidget21.NET.dll}}. Please see the [[#Write Your Own Code | Write Your Own Code ]] section for details. &lt;br /&gt;
&lt;br /&gt;
[[File:CSharp VS2005 Run.PNG|link=|alt=Run]]&lt;br /&gt;
&lt;br /&gt;
This program will detect for devices that are attached/detached on the computer. Go ahead, and attach or detach your devices! Here is an example output:&lt;br /&gt;
&lt;br /&gt;
[[File:CSharp VS2005 HelloWorld Output.PNG|link=|alt=HelloWorld Output]]&lt;br /&gt;
&lt;br /&gt;
After confirming that the {{Code|HelloWorld}} example is working, you can proceed to run the example for your device. If you aren&#039;t sure what the software example for your device is called, check the software object listed in the [[Device List | Getting Started Guide for your Device]]. Please ensure that you have set your start up project to be the one that matches your device before compiling. &lt;br /&gt;
&lt;br /&gt;
Once you have the C# examples running, we have a [[#Follow the Examples|teaching]] section below to help you follow them.&lt;br /&gt;
&lt;br /&gt;
=====Write Your Own Code=====&lt;br /&gt;
&lt;br /&gt;
When you are building a project from scratch, or adding Phidget function calls to an existing project, you&#039;ll need to configure your environment to properly link the Phidget C# libraries. To begin: &lt;br /&gt;
&lt;br /&gt;
1. Generate a new Visual C# Windows Applications project with a descriptive name such as PhidgetTest. &lt;br /&gt;
&lt;br /&gt;
[[File:CSharp VS2005 New Project.PNG|link=|alt=New Project]]&lt;br /&gt;
&lt;br /&gt;
2. Add a reference to the Phidget .NET library.&lt;br /&gt;
&lt;br /&gt;
[[File:CSharp VS2005 Add Reference.PNG|link=|alt=Add Reference]]&lt;br /&gt;
&lt;br /&gt;
3. Under the .NET tab, select {{Code|Phidget21.NET.dll}}.&lt;br /&gt;
If you used our installer, these files are installed in {{Code|C:\Program Files\Phidgets}}, by default. If it does not appear in this list, then you can browse to the Phidget Framework installation directory and add the file.&lt;br /&gt;
&lt;br /&gt;
[[File:CSharp VS2005 Add Reference 2.PNG|link=|alt=Add Reference]]&lt;br /&gt;
&lt;br /&gt;
4. Then, in your code, you will need to include the Phidget .NET library:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=csharp&amp;gt;&lt;br /&gt;
  using Phidgets;&lt;br /&gt;
  using Phidgets.Events;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The project now has access to the Phidget function calls and you are ready to begin coding.&lt;br /&gt;
&lt;br /&gt;
The same [[#Follow the Examples|teaching ]] section which describes the examples also has further resources for programming your Phidget.&lt;br /&gt;
&lt;br /&gt;
===Visual Studio 2003===&lt;br /&gt;
&lt;br /&gt;
=====Use Our Examples=====&lt;br /&gt;
&lt;br /&gt;
1. Download the [http://www.phidgets.com/downloads/examples/CSharp_2.1.8.20110615.zip examples] and unpack them into a folder. Here, you can find example programs for all the devices. If you are not sure what the software example for your device is called, check the software object listed in the [[Device List | Getting Started guide for your device]]. As the examples were written in newer versions of Visual Studio, Visual Studio 2003 is not able to open the examples. Fortunately, you can import the simple examples to a Visual Studio 2003 project. It will be difficult to import the full examples as you will need to recreate the GUI components. In the [[#Use Our Examples 2 | Use Our Examples]] section, it will be assumed that the simple examples are used. You will need this example source code to be copied into your C# project later on. &lt;br /&gt;
&lt;br /&gt;
2. Next, a new project will need to be created. Generate a new Visual C# console application project with a descriptive name such as PhidgetTest.&lt;br /&gt;
&lt;br /&gt;
[[File:CSharp_VS2003 New Project.PNG|link=|alt=New Project]]&lt;br /&gt;
&lt;br /&gt;
3. Add a reference to the Phidget .NET library.&lt;br /&gt;
&lt;br /&gt;
[[File:CSharp_VS2003 Add Reference 1.PNG|link=|alt=Add Reference]]&lt;br /&gt;
&lt;br /&gt;
4. Under the .NET tab, select {{Code|Phidget21.NET1.1.dll}}. If you used our installer, by default, this file is placed in {{Code|C:\Program Files\Phidgets}}. If it is in another location, please change the path to the file&#039;s location accordingly. &lt;br /&gt;
&lt;br /&gt;
[[File:CSharp_VS2003 Add Reference 2.PNG|link=|alt=Add Reference]]&lt;br /&gt;
&lt;br /&gt;
5. To import the simple example program into your project, please: open up {{Code|Class1.cs}}.&lt;br /&gt;
&lt;br /&gt;
6. Traverse to the example in Windows Explorer and locate the {{Code|Program.cs}} file.&lt;br /&gt;
&lt;br /&gt;
[[File:CSharp VS2003 Source Code.PNG|link=|alt=Source Code]]&lt;br /&gt;
&lt;br /&gt;
7. Copy and paste the contents from that file into {{Code|Class1.cs}}.&lt;br /&gt;
&lt;br /&gt;
8. Comment out the following line as it is not supported in .NET 1.1:&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=csharp&amp;gt;&lt;br /&gt;
  using System.Collections.Generic;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:CSharp VS2003 Source Code 2.PNG|link=|alt=Source Code]]&lt;br /&gt;
&lt;br /&gt;
9. Now, you can run the example. Click on Debug &amp;amp;rarr; Start.&lt;br /&gt;
&lt;br /&gt;
[[File:CSharp VS2003 Run.PNG|link=|alt=Run]]&lt;br /&gt;
&lt;br /&gt;
Once you have the C# examples running, we have a [[#Follow the Examples|teaching ]] section below to help you follow them.&lt;br /&gt;
&lt;br /&gt;
=====Write Your Own Code=====&lt;br /&gt;
&lt;br /&gt;
When you are building a project from scratch, or adding Phidget function calls to an existing project, you&#039;ll need to configure your development environment to properly link the Phidget .NET library. Please see the [[#Use Our Examples 2 | Use Our Examples ]] section for instructions.&lt;br /&gt;
&lt;br /&gt;
Then, in your code, you will need to include the Phidget .NET library:&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=csharp&amp;gt;&lt;br /&gt;
  using Phidgets;&lt;br /&gt;
  using Phidgets.Events;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The project now has access to the Phidget function calls and you are ready to begin coding.&lt;br /&gt;
&lt;br /&gt;
The same [[#Follow the Examples|teaching]] section which describes the examples also has further resources for programming your Phidget.&lt;br /&gt;
&lt;br /&gt;
===Mono===&lt;br /&gt;
&lt;br /&gt;
This section will provide instructions on how to compile using the {{Code|mcs}} compiler. Other compilers such as {{Code|gmcs}}, {{Code|smcs}}, and {{Code|dmcs}} all work in the same way.&lt;br /&gt;
&lt;br /&gt;
=====Use Our Examples=====&lt;br /&gt;
&lt;br /&gt;
Download the [http://www.phidgets.com/downloads/examples/CSharp_2.1.8.20110615.zip examples] and unpack them into a folder. Here, you can find example programs for all the devices. If you aren&#039;t sure what the software example for your device is called, check the software object listed in the [[Device List | Getting Started guide for your device]]. Please only use the simple examples. The full examples uses Windows Forms, which Mono and the Gtk# toolkit are not completely compatible with. Locate the {{Code|Program.cs}} file as this contains the example source code. Copy the file into your working directory, and rename it to {{Code|example.cs}}.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Place the {{Code|Phidget21.NET.dll}} in the same directory as your source code.&lt;br /&gt;
&lt;br /&gt;
To compile and build an executable, run:&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=bash&amp;gt;&lt;br /&gt;
mcs /out:example.exe /r:phidget21.NET.dll example.cs&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have the {{Code|Phidget21.NET.dll}} installed in another location, please change the path to the file&#039;s location accordingly.&lt;br /&gt;
&lt;br /&gt;
Afterwards, you will have an executable named {{Code|example.exe}} that you can run. Type the following to run the program:&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=bash&amp;gt;&lt;br /&gt;
mono example.exe&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once you have the C# examples running, we have a [[#Follow the Examples|teaching]] section below to help you follow them.&lt;br /&gt;
&lt;br /&gt;
=====Write Your Own Code=====&lt;br /&gt;
&lt;br /&gt;
When you are building a project from scratch, or adding Phidget function calls to an existing project, you&#039;ll need to configure your development environment to properly link the Phidget .NET library. Please see the [[#Use Our Examples 3 | Use Our Example ]] section for instructions.&lt;br /&gt;
&lt;br /&gt;
In your code, you will need to include the Phidget .NET library:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=csharp&amp;gt;&lt;br /&gt;
  using Phidgets;&lt;br /&gt;
  using Phidgets.Events;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The project now has access to the Phidget function calls and you are ready to begin coding.&lt;br /&gt;
&lt;br /&gt;
The same [[#Follow the Examples|teaching]] section which describes the examples also has further resources for programming your Phidget.&lt;br /&gt;
&lt;br /&gt;
===MonoDevelop===&lt;br /&gt;
&lt;br /&gt;
=====Use Our Examples=====&lt;br /&gt;
&lt;br /&gt;
Download the [http://www.phidgets.com/downloads/examples/CSharp_2.1.8.20110615.zip examples] and unpack them into a folder. Here, you can find example programs for all the devices. These examples were written in Visual Studio 2005 and 2008, but are also compatible with MonoDevelop.&lt;br /&gt;
&lt;br /&gt;
To load all projects in MonoDevelop, go to File &amp;amp;rarr; Open, and open {{Code|AllExamples/AllExamples.sln}}&lt;br /&gt;
&lt;br /&gt;
This will load all of the examples available for C#, and then you can set your main project to be the one that matches your device.  If you aren&#039;t sure what the software example for your device is called, check the software object listed in the [[Device List | Getting Started guide for your device]]. If you are running under the .NET framework, you can use either the full or simple examples. Otherwise, if you are running under the Mono framework, please only use the simple examples. The full examples uses Windows Forms, which is not completely compatible with Mono&#039;s Gtk#.&lt;br /&gt;
&lt;br /&gt;
[[File:CSharp MonoDevelop Win Start Up.PNG|link=|alt=Start Up Project]]&lt;br /&gt;
&lt;br /&gt;
The only thing left to do is to run the examples! Right click the project, and click on {{Code|Run With}} and select the target framework. Please note that the projects, by default try to find the {{Code|Phidget21.NET.dll}} in the {{Code|C\Program Files\Phidgets}}. If you have it installed in another location, please change the path to the file&#039;s location accordingly. If you are receiving an error message regarding that the namespace Phidgets cannot be found, please re-add the reference to {{Code|Phidget21.NET.dll}}. Please see the [[#Write Your Own Code 4 | Write Your Own Code]] section for details. &lt;br /&gt;
&lt;br /&gt;
[[File:CSharp MonoDevelop Win Run As.PNG|link=|alt=Run As]]&lt;br /&gt;
&lt;br /&gt;
Once you have the C# examples running, we have a [[#Follow the Examples|teaching]] section below to help you follow them.&lt;br /&gt;
&lt;br /&gt;
=====Write Your Own Code=====&lt;br /&gt;
&lt;br /&gt;
When you are building a project from scratch, or adding Phidget function calls to an existing project, you&#039;ll need to configure your  development environment to properly link the Phidget .NET library. To begin:&lt;br /&gt;
&lt;br /&gt;
1. Create a new C# empty project with a descriptive name such as PhidgetTest.&lt;br /&gt;
&lt;br /&gt;
[[File:CSharp MonoDevelop Win New Project.PNG|link=|alt=New Project]]&lt;br /&gt;
&lt;br /&gt;
2. Add a reference to the Phidget .NET library. &lt;br /&gt;
&lt;br /&gt;
[[File:CSharp MonoDevelop Win Reference.PNG|link=|alt=Add Reference]]&lt;br /&gt;
&lt;br /&gt;
3. Select {{Code|Phidget21.NET.dll}}. If you used our installer, by default, this file is placed in {{Code|C:\Program Files\Phidgets}}. If it is in another location, please change the path to the file&#039;s location accordingly. &lt;br /&gt;
&lt;br /&gt;
[[File:CSharp MonoDevelop Win Reference 2.PNG|link=|alt=Add Reference]]&lt;br /&gt;
&lt;br /&gt;
4. Then, in your code, you will need to include the Phidget .NET library:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=csharp&amp;gt;&lt;br /&gt;
  using Phidgets;&lt;br /&gt;
  using Phidgets.Events;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The project now has access to the Phidget function calls and you are ready to begin coding.&lt;br /&gt;
&lt;br /&gt;
The same [[#Follow the Examples|teaching]] section which describes the examples also has further resources for programming your Phidget.&lt;br /&gt;
&lt;br /&gt;
==OS X==&lt;br /&gt;
&lt;br /&gt;
C# has excellent support on OS X through the Mono framework. &lt;br /&gt;
&lt;br /&gt;
The first step in using C# on Mac is to install the Phidget .NET libraries.  Compile and install them as explained on the [[Device List|getting started guide for your device]].  Then, the [[OS - OS X]] page also describes the different Phidget files, their installed locations, and their roles....&lt;br /&gt;
&lt;br /&gt;
==Linux==&lt;br /&gt;
&lt;br /&gt;
C# has support on Linux through the Mono framework.&lt;br /&gt;
&lt;br /&gt;
===Use Our Examples===&lt;br /&gt;
 &lt;br /&gt;
The first step in using C# with Phidgets on Linux is to make sure that you have all of Mono installed.  Although you probably have already done this if you&#039;re a C# programmer, you want to make sure you have all of the packages you&#039;ll need.  Try:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=bash&amp;gt;&lt;br /&gt;
sudo apt-get mono-complete&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, you&#039;ll want to install the main Phidget Libraries.  Compile and install them as explained on the main [[OS - Linux | Linux page]].  That Linux page also describes the different Phidget files, their installed locations, and their roles.&lt;br /&gt;
&lt;br /&gt;
Then, you will need the Phidget .NET libraries.  These are part of the Windows library zip file download:&lt;br /&gt;
&lt;br /&gt;
* [http://www.phidgets.com/downloads/libraries/Phidget21-windevel.zip Phidget Windows Library Zip File]&lt;br /&gt;
&lt;br /&gt;
Extract the library zip file.  Descriptions for the files are available on the [[OS - Windows]] page, but for now we only need the {{Code|Phidget21.NET.dll}} file to run the Phidget C# examples in Mono.  So remember where you unzipped these Windows libraries - you will need to copy the {{Code|Phidget21.NET.dll}} file into your example directory shortly.&lt;br /&gt;
&lt;br /&gt;
Next, you&#039;ll want to download and extract the Phidget C# Examples (For Windows, not for .NET Compact):&lt;br /&gt;
&lt;br /&gt;
* [http://www.phidgets.com/downloads/examples/CSharp.zip C Sharp Examples for Windows]&lt;br /&gt;
&lt;br /&gt;
To check that your Linux, Phidget, and Mono setup is all working together, you&#039;ll want to run the C# examples.  Specifically, you&#039;ll want to run the &#039;&#039;simple&#039;&#039; C# examples. Find the source code for your device. The source file will be named the same as the software object for your device. If you are not sure what the software object for your device is, it can be found in the Software/API section on the [[Device List|Product Page]] for your device. &lt;br /&gt;
&lt;br /&gt;
Let&#039;s say you&#039;re running the Temperature Sensor example (for the 1048 or 1051).  The source code for the example is in the directory: &lt;br /&gt;
&lt;br /&gt;
:{{Code|TemperatureSensorExamples}} &amp;amp;rarr; {{Code|TemperatureSensor-simple}} &amp;amp;rarr; {{Code|TemperatureSensor-simple}} &amp;amp;rarr; {{Code|Program.cs}}&lt;br /&gt;
&lt;br /&gt;
Other examples will be in directories named appropriately for their software object name.  Once you have found the example you want to run, copy the {{Code|Phidget21.NET.dll}} file that you unzipped earlier into that example directory where the {{Code|Program.cs}} file is.  &lt;br /&gt;
&lt;br /&gt;
Then, compile the code.  When compiling, you need to link to the Phidget library. As the Phidget21.NET file is an &amp;quot;additional assembly&amp;quot; in C#/Mono, you can link to the assembly using the {{Code|-r}} &amp;quot;reference&amp;quot; switch:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=bash&amp;gt;&lt;br /&gt;
gmcs Program.cs -r:Phidget21.NET.dll&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will compile a {{Code|*.exe}} file - in this case, {{Code|Program.exe}}.  This you can then run under Mono:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=bash&amp;gt;&lt;br /&gt;
sudo mono Program.exe&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remember that the {{Code|sudo}} is needed unless you have your [[OS - Linux#Setting udev Rules|udev rules set on your Linux system]].&lt;br /&gt;
&lt;br /&gt;
If you will be compiling with an IDE such as GTK# or MonoDevelop, we don&#039;t have explicit instructions by IDE for Linux.  However, you will probably find the [[#MonoDevelop | MonoDevelop]] section in the Windows portion above useful.&lt;br /&gt;
&lt;br /&gt;
===Write Your Own Code===&lt;br /&gt;
&lt;br /&gt;
When writing your code from scratch, you start it as you would any C# code on Linux, such as within a text editor like Emacs, Vi, Gedit, or Kate. In your .cs source code file, you must include a reference to the Phidget Library:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=csharp&amp;gt;&lt;br /&gt;
using Phidgets; &lt;br /&gt;
using Phidgets.Events; &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, you would compile your completed C# code the same way as the examples above.&lt;br /&gt;
&lt;br /&gt;
Mono also has a few different IDEs which you can use to develop code, and these are especially useful if you are doing GUI development.  We provide instructions for MonoDevelop - one such IDE - being used [[#MonoDevelop|under Windows]].&lt;br /&gt;
&lt;br /&gt;
To learn how to write your own code for your Phidget, and to learn more about our API, we have a [[#Follow the Examples|teaching section]] to help you follow the provided C# examples and which has resources such as the API reference.&lt;br /&gt;
&lt;br /&gt;
==Windows CE==&lt;br /&gt;
&lt;br /&gt;
===Description of Library Files===&lt;br /&gt;
C# programs on Windows depend on the following files, which the installers above put onto your system:&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|phidget21.dll}}&amp;lt;/b&amp;gt; contains the actual Phidget library, which is used at run-time.  By default, it is placed in {{Code|C:\Windows\System32}}.&lt;br /&gt;
You will also need one of the following two files, depending on the .NET framework version you are targeting:&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|Phidget21.NET.dll}}&amp;lt;/b&amp;gt; is the Phidget library for .NET framework &amp;lt;i&amp;gt;&amp;lt;b&amp;gt;2.0&amp;lt;/b&amp;gt;&amp;lt;/i&amp;gt; or higher. Your compiler has to know where this file is. By default, it is placed into {{Code|C:\Program Files\Phidgets}}. You can either point your compiler to that location, or copy and link to it in a directory for your project workspace. &lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|Phidget21.NET1.1.dll}}&amp;lt;/b&amp;gt; is the Phidget library for .NET framework &amp;lt;i&amp;gt;&amp;lt;b&amp;gt;1.1&amp;lt;/b&amp;gt;&amp;lt;/i&amp;gt;. Your compiler has to know where this file is. By default, it is placed into {{Code|C:\Program Files\Phidgets}}. You can either point your compiler to that location, or copy and link to it in a directory for your project workspace. &lt;br /&gt;
You can optionally install the following files:&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|Phidget21.NET.XML}}&amp;lt;/b&amp;gt; provides the IntelliSense in-line documentation for the .NET library in Visual Studio/MonoDevelop. This documentation is also visible in the Object Browser in Visual Studio. By default, it is placed into {{Code|C:\Program Files\Phidgets}}. &lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|Policy.2.1.Phidget21.NET.dll}}&amp;lt;/b&amp;gt; is the policy assembly for {{Code|Phidget21.NET.dll}}. Our installer places this file in the Global Assembly Cache(GAC) directory. It directs any programs compiled against version 2.1.0 or higher of {{Code|Phidget21.NET.dll}} to use the most recent installed version. &lt;br /&gt;
&lt;br /&gt;
If you do not want to use our installer, you can download the five [http://www.phidgets.com/downloads/libraries/Phidget21-windevel_2.1.8.20111220.zip files].&lt;br /&gt;
&lt;br /&gt;
Running the examples and writing your own code can be fairly compiler-specific, so we include instructions for each compiler below.&lt;br /&gt;
&lt;br /&gt;
===Visual Studio 2005/2008/2010===&lt;br /&gt;
&lt;br /&gt;
Microsoft makes free versions of Visual Studio available known as Express Editions.  The Express editions are suitable for most applications, but are limited in features for more complex applications. Please see [http://www.microsoft.com/visualstudio Microsoft Visual Studio] for more information.&lt;br /&gt;
&lt;br /&gt;
=====Use Our Examples=====&lt;br /&gt;
&lt;br /&gt;
Please start by downloading the [http://www.phidgets.com/downloads/examples/CSharp_2.1.8.20110615.zip examples] and unpack them into a folder.  While these examples were written in Visual Studio 2005 and 2008, Visual Studio 2010 will easily open and upgrade them. To load all projects in Visual Studio, go to File &amp;amp;rarr; Open &amp;amp;rarr; Project, and open {{Code|AllExamples/AllExamples.sln}} or {{Code|AllExamples/AllExamples_vs2008.sln}} for Visual Studio 2005 and 2008, respectively.&lt;br /&gt;
&lt;br /&gt;
If you are opening the Phidget examples in Visual Studio 2010, you will need to go through the Visual Studio Conversion Wizard to convert the 2005 or 2008 project. &lt;br /&gt;
[[File:VS2005 Conversion Wizard.PNG|link=|alt=Conversion Wizard]]&lt;br /&gt;
&lt;br /&gt;
The easiest way to confirm that your environment is set up properly will be to compile and run the {{Code|HelloWorld}} C/C++ example.&lt;br /&gt;
&lt;br /&gt;
Start by setting the {{Code|HelloWorld}} project as your start up project.&lt;br /&gt;
&lt;br /&gt;
The only thing left to do is to run the example! Click on Debug &amp;amp;rarr; Start Debugging. Please note that the projects, by default try to find the {{Code|Phidget21.NET.dll}} in the {{Code|C:\Program Files\Phidgets}}. If you have it installed in another location, please change the path to the file&#039;s location accordingly. If you are receiving an error message regarding that the namespace Phidgets cannot be found, please re-add the reference to {{Code|Phidget21.NET.dll}}. Please see the [[#Write Your Own Code | Write Your Own Code ]] section for details. &lt;br /&gt;
&lt;br /&gt;
[[File:CSharp VS2005 Run.PNG|link=|alt=Run]]&lt;br /&gt;
&lt;br /&gt;
This program will detect for devices that are attached/detached on the computer. Go ahead, and attach or detach your devices! Here is an example output:&lt;br /&gt;
&lt;br /&gt;
[[File:CSharp VS2005 HelloWorld Output.PNG|link=|alt=HelloWorld Output]]&lt;br /&gt;
&lt;br /&gt;
After confirming that the {{Code|HelloWorld}} example is working, you can proceed to run the example for your device. If you aren&#039;t sure what the software example for your device is called, check the software object listed in the [[Device List | Getting Started Guide for your Device]]. Please ensure that you have set your start up project to be the one that matches your device before compiling. &lt;br /&gt;
&lt;br /&gt;
Once you have the C# examples running, we have a [[#Follow the Examples|teaching]] section below to help you follow them.&lt;br /&gt;
&lt;br /&gt;
=====Write Your Own Code=====&lt;br /&gt;
&lt;br /&gt;
When you are building a project from scratch, or adding Phidget function calls to an existing project, you&#039;ll need to configure your environment to properly link the Phidget C# libraries. To begin: &lt;br /&gt;
&lt;br /&gt;
1. Generate a new Visual C# Windows Applications project with a descriptive name such as PhidgetTest. &lt;br /&gt;
&lt;br /&gt;
[[File:CSharp VS2005 New Project.PNG|link=|alt=New Project]]&lt;br /&gt;
&lt;br /&gt;
2. Add a reference to the Phidget .NET library.&lt;br /&gt;
&lt;br /&gt;
[[File:CSharp VS2005 Add Reference.PNG|link=|alt=Add Reference]]&lt;br /&gt;
&lt;br /&gt;
3. Under the .NET tab, select {{Code|Phidget21.NET.dll}}.&lt;br /&gt;
If you used our installer, these files are installed in {{Code|C:\Program Files\Phidgets}}, by default. If it does not appear in this list, then you can browse to the Phidget Framework installation directory and add the file.&lt;br /&gt;
&lt;br /&gt;
[[File:CSharp VS2005 Add Reference 2.PNG|link=|alt=Add Reference]]&lt;br /&gt;
&lt;br /&gt;
4. Then, in your code, you will need to include the Phidget .NET library:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=csharp&amp;gt;&lt;br /&gt;
  using Phidgets;&lt;br /&gt;
  using Phidgets.Events;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The project now has access to the Phidget function calls and you are ready to begin coding.&lt;br /&gt;
&lt;br /&gt;
The same [[#Follow the Examples|teaching ]] section which describes the examples also has further resources for programming your Phidget.&lt;br /&gt;
&lt;br /&gt;
==Follow the Examples==&lt;br /&gt;
&lt;br /&gt;
By following the instructions for your operating system and compiler above, you probably now have a working example and want to understand it better so you can change it to do what you want.  This teaching section has resources for you to learn from the examples and write your own.&lt;br /&gt;
&lt;br /&gt;
Next, comes our API information.  These resources outline the C# Phidget functions:&lt;br /&gt;
&lt;br /&gt;
{{UsingAPhidgetInCodeGeneral|both of which are available in C#|[http://www.phidgets.com/documentation/Phidget21.NET.zip .NET API]}}&lt;br /&gt;
&lt;br /&gt;
===Example Flow===&lt;br /&gt;
&lt;br /&gt;
{{ExamplePseudocode|In C#, you can name these &#039;&#039;&#039;event&#039;&#039;&#039; functions whatever you like.  You will then pass them as function pointers to the Phidget .NET library below in the Main Code section.  This hooks them into the actual events when they occur. &amp;lt;br&amp;gt; &lt;br /&gt;
In the example code, the event functions common to all Phidgets are called things like &#039;&#039;&#039;AttachHandler()&#039;&#039;&#039; and &#039;&#039;&#039;DetachHandler()&#039;&#039;&#039;, etc.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Some event functions will be specific to each device, like when a tag is read on an RFID board, or when a sensor value changes on an Interface Kit.&lt;br /&gt;
Other functions are given in the examples to show you more detail on using your Phidget.  For example, &#039;&#039;&#039;DeviceInitialize()&#039;&#039;&#039; will show what needs to be set up for your Phidget before using it.&lt;br /&gt;
|Creating a Phidget software object in C# is specific to the Phidget.  For a Phidget Spatial, for example, this would involve creating a {{Code|Spatial}} object.  The examples show how to do this and other API functions.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
The object provides device specific methods and properties which are available from the API for your specific Phidget.|&lt;br /&gt;
[http://www.phidgets.com/documentation/Phidget21.NET.zip .NET API]}}&lt;br /&gt;
&lt;br /&gt;
===Code Snippets===&lt;br /&gt;
&lt;br /&gt;
==Common Problems and Solutions/Workarounds==&lt;br /&gt;
&lt;br /&gt;
==={{ProblemSolution|All Operating Systems|The Phidgets.Events.ErrorEventHandler conflicts with System.IO.ErrorEventHandler.}}===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=csharp&amp;gt;&lt;br /&gt;
using System.IO;&lt;br /&gt;
using Phidgets;&lt;br /&gt;
using Phidgets.Events;&lt;br /&gt;
...&lt;br /&gt;
spatial.Error += new ErrorEventHandler(spatial_Error);&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
void spatial_Error(object sender, ErrorEventArgs e){&lt;br /&gt;
   ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above code produces the following errors:&lt;br /&gt;
&lt;br /&gt;
{{Code|&#039;ErrorEventHandler&#039; is an ambiguous reference between &#039;System.IO.ErrorEventHandler&#039; and &#039;Phidgets.Events.ErrorEventHandler&#039;}}.&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
{{Code|&#039;ErrorEventArgs&#039; is an ambiguous reference between &#039;System.IO.ErrorEventArgs&#039; and &#039;Phidgets.Events.ErrorEventArgs&#039;}}.&lt;br /&gt;
&lt;br /&gt;
The error is due to the {{Code|System.IO}} and {{Code|Phidgets.Events}} namespaces both having a class called {{Code|ErrorEventHandler}}.&lt;br /&gt;
&lt;br /&gt;
To get around this issue, use the fully qualified namespace when referring to the {{Code|ErrorEventHandler}} and {{Code|ErrorEventArgs}} classes:&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=csharp&amp;gt;&lt;br /&gt;
using System.IO;&lt;br /&gt;
using Phidgets;&lt;br /&gt;
using Phidgets.Events;&lt;br /&gt;
...&lt;br /&gt;
spatial.Error += new Phidgets.Events.ErrorEventHandler(spatial_Error);&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
void spatial_Error(object sender, Phidgets.Events.ErrorEventArgs e){&lt;br /&gt;
   ...&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;/div&gt;</summary>
		<author><name>Djrudiak</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=OS_-_Windows_CE&amp;diff=19201</id>
		<title>OS - Windows CE</title>
		<link rel="alternate" type="text/html" href="https://www.phidgets.com/docs21/index.php?title=OS_-_Windows_CE&amp;diff=19201"/>
		<updated>2012-04-20T20:56:14Z</updated>

		<summary type="html">&lt;p&gt;Djrudiak: /* Using the WebService */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:OS]]&lt;br /&gt;
{{OSLang|[[File:Icon-Windows CE.png‎|64x64px|link=]]|On Windows CE, Phidgets can be either plugged directly into a USB Port or run over a network using the [[#WebService | WebService]].}}&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
Phidgets are designed to run on &#039;&#039;&#039;Windows CE 5.0 or newer&#039;&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
==Getting Started (Libraries and Drivers)==&lt;br /&gt;
&lt;br /&gt;
If this is your first Phidget, we highly recommend working through the Getting Started guide [[Device List|for your specific Phidget device]]. &lt;br /&gt;
&lt;br /&gt;
In addition to owning a Windows CE system, you will also need a Windows (2000/XP/Vista/7) system for developing and deploying Windows CE applications.&lt;br /&gt;
&lt;br /&gt;
If you are already a pro, and just want the Windows CE installer:&lt;br /&gt;
&lt;br /&gt;
* [http://www.phidgets.com/downloads/libraries/Phidget21ARMV4I_2.1.8.20110615.CAB ARM4VI]&lt;br /&gt;
* [http://www.phidgets.com/downloads/libraries/Phidget21x86_2.1.8.20110615.CAB x86]&lt;br /&gt;
* [http://www.phidgets.com/downloads/libraries/Phidget21MIPSII_2.1.8.20110615.CAB MIPSII]&lt;br /&gt;
&lt;br /&gt;
The above installers are intended for the target Windows CE system. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For special cases where you want to install the Phidget libraries without the installer, please see the [[#Advanced Uses | Advanced Uses]] section. You will also have to download the Windows CE Libraries on your development machine.&lt;br /&gt;
*[http://www.phidgets.com/downloads/libraries/Phidget21-wincedevel_2.1.8.20120216.zip Phidget21 Windows CE Libraries] (All architectures)&lt;br /&gt;
*[http://www.phidgets.com/downloads/libraries/Phidget21CEkernalsource_2.1.8.20120216.zip Kernel Driver Source]&lt;br /&gt;
*[http://www.phidgets.com/Drivers_Info.html#wince Software License]&lt;br /&gt;
&lt;br /&gt;
===Installing===&lt;br /&gt;
&lt;br /&gt;
To install the libraries on the Windows CE machine, follow these steps:&lt;br /&gt;
&lt;br /&gt;
1. Download one of the Phidget installer for your system, depending on whether your system is ARM4VI, x86, or MIPSII.&lt;br /&gt;
* [http://www.phidgets.com/downloads/libraries/Phidget21ARMV4I_2.1.8.20110615.CAB ARM4VI]&lt;br /&gt;
* [http://www.phidgets.com/downloads/libraries/Phidget21x86_2.1.8.20110615.CAB x86]&lt;br /&gt;
* [http://www.phidgets.com/downloads/libraries/Phidget21MIPSII_2.1.8.20110615.CAB MIPSII]&lt;br /&gt;
&lt;br /&gt;
2. Open up the {{Code|CAB}} installer, and proceed through the wizard. If you have installed the Phidgets library before on the same system, it may mention that the Phidget libraries are already installed. This is safe to ignore. Please note that by default, the installer places the [[#Description of Library files | Phidget libraries]] in {{Code|\Program Files\Phidgets}}. &lt;br /&gt;
&lt;br /&gt;
3. Once the installation is complete, you are ready to program with Phidgets.&lt;br /&gt;
&lt;br /&gt;
For a description of what was installed onto your system, please see the [[#Description of Library files | Description of Library Files]] section. &lt;br /&gt;
&lt;br /&gt;
Proceed onto to the [[#Phidget Control Panel | next]] section where an example program will be run to confirm that the libraries were installed correctly.&lt;br /&gt;
&lt;br /&gt;
===Checking===&lt;br /&gt;
&lt;br /&gt;
To confirm the libraries were installed and work correctly, you can check if the software component works.&lt;br /&gt;
&lt;br /&gt;
If you have the Phidgets library installed on your system, you can verify that the software component is working by running the {{Code|\Program Files\Phidgets\HelloWorld.exe}} application and seeing if the Phidget device is listed in the output. You can run the application by simply double clicking on it in Windows Explorer. Note that if the Phidget is already plugged into the system, you will have to re-attach it after the Phidget libraries are installed.&lt;br /&gt;
&lt;br /&gt;
If the Phidget is plugged into an USB port and you are not able to see that the Phidget is in the list, there may be a hardware issue. &lt;br /&gt;
&lt;br /&gt;
====Troubleshooting====&lt;br /&gt;
&lt;br /&gt;
If the examples &#039;&#039;&#039;do not&#039;&#039;&#039; work but USB &#039;&#039;&#039;does&#039;&#039;&#039; work (i.e. your computer can consistently see the device in the [[#Hardware|hardware]]), take a moment to check the basics:&lt;br /&gt;
* You are using Windows CE 5.0 or greater.&lt;br /&gt;
* You have the correct package installed according to your system&#039;s architecture.&lt;br /&gt;
* No other programs, drivers, or processes are using that USB port in software&lt;br /&gt;
* The Phidget libraries are the latest version (visit the [[#Getting Started (Libraries and Drivers)| getting started section]] to download them)&lt;br /&gt;
&lt;br /&gt;
* Check the [[#Common Problems and Solutions|common problems]] section below, some specific combinations can cause problems&lt;br /&gt;
&lt;br /&gt;
If your problem doesn&#039;t seem to be fixed by these steps, make sure that the Phidget is seen &#039;&#039;&#039;consistently&#039;&#039;&#039; by USB (if it is erratic, try our [[General Troubleshooting|general troubleshooting guide]]).  If you are still having problems after using the troubleshooting guide, please [[Contact Information|ask us]]!&lt;br /&gt;
&lt;br /&gt;
==Programming Languages==&lt;br /&gt;
&lt;br /&gt;
Phidgets’ philosophy is that you do not have to be an electrical engineer in order to do projects that use devices like sensors, motors, motor controllers, and interface boards. All you need to know is how to program.&lt;br /&gt;
&lt;br /&gt;
After you have installed the drivers above, you should pick a programming language, install libraries, and run the examples for that specific language. You can learn more about what is needed to program in a particular language by choosing the language of your preference below. If you need help choosing a language, please look at the [[Software Overview#Language Support |language comparison table]]. &lt;br /&gt;
&lt;br /&gt;
Phidgets’ philosophy is that you do not have to be an electrical engineer in order to do projects that use devices like sensors, motors, motor controllers, and interface boards. All you need to know is how to program. &lt;br /&gt;
&lt;br /&gt;
On Windows CE, we recommend the following languages:&lt;br /&gt;
&lt;br /&gt;
*[[Language - C Sharp (.NET Compact Framework)|C Sharp (.NET Compact Framework)]]&lt;br /&gt;
*[[Language - C/C++|C/C++]]&lt;br /&gt;
*[[Language - Visual Basic (.NET Compact Framework)|Visual Basic (.NET Compact Framework)]]&lt;br /&gt;
&lt;br /&gt;
==WebService==&lt;br /&gt;
&lt;br /&gt;
The Phidget WebService allows you to remotely control a Phidget over a network.&lt;br /&gt;
&lt;br /&gt;
Drivers for the Phidget WebService on Windows CE are already included in the [[#Getting Started (Libraries and Drivers) | Drivers]] above. The WebService is started with the {{Code|PhidgetWebservice21.exe}} application. &lt;br /&gt;
&lt;br /&gt;
You can connect to a Phidget hosted on another computer if you know the IP address/host name of the host computer. &lt;br /&gt;
&lt;br /&gt;
This section helps you install, check, and use the WebService on Windows CE, but we also have an overview of the [[Phidget WebService]] in general.&lt;br /&gt;
&lt;br /&gt;
===Turning the WebService On and Off===&lt;br /&gt;
&lt;br /&gt;
The WebService can be turned on and off using command line.  If you used our installer, the WebService utility is automatically installed in {{Code|\Program Files\Phidgets}}. &lt;br /&gt;
&lt;br /&gt;
You can get command line help with {{Code|PhidgetWebservice21.exe}} using the -h option:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=bash&amp;gt;&lt;br /&gt;
 PhidgetWebservice21 -h&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=text&amp;gt;&lt;br /&gt;
&#039;phidgetwebservice21&#039; is a Phidget and Dictionary server from Phidgets Inc. See www.phidgets.com for more information.&lt;br /&gt;
Usage: phidgetwebservice21 [OPTION]&lt;br /&gt;
All parameters are optional. The default parameters are: port=5001, ServerName=(Computer Name) and no password&lt;br /&gt;
&lt;br /&gt;
Options:&lt;br /&gt;
  -p      Port&lt;br /&gt;
  -n      Server Name&lt;br /&gt;
  -P      Password&lt;br /&gt;
  -v      Debug mode&lt;br /&gt;
  -h      Display this help&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please note that as Windows CE does not support the use of mDNS, the -n option cannot be used. &lt;br /&gt;
&lt;br /&gt;
To find the defaults used by {{Code|phidget21webservice}}, the command line is the fastest way to learn the IP address of your computer:&lt;br /&gt;
*For your IP address, type {{Code|ipconfig}} in the command line.&lt;br /&gt;
**A line in the return text, will say something like {{Code|IP Address ........ 192.168.2.198}}, which is your IP.&lt;br /&gt;
&lt;br /&gt;
Here are some usage examples. The Windows command line is used. Traverse to the Phidget installation directory(By default, it is located in {{Code|\Program Files\Phidgets}}).&lt;br /&gt;
&lt;br /&gt;
To start the WebService with default parameters:&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=bash&amp;gt;&lt;br /&gt;
 PhidgetWebservice21.exe&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To start the WebService on port 5002:&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=bash&amp;gt;&lt;br /&gt;
 PhidgetWebservice21.exe -p 5002&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To stop the WebService, simply close the command line window or press {{Code|Ctrl}} and {{Code|c}} at the same time in the command line window.&lt;br /&gt;
&lt;br /&gt;
===Using the WebService===&lt;br /&gt;
&lt;br /&gt;
To use a Phidget over the WebService, you&#039;ll want to:&lt;br /&gt;
&lt;br /&gt;
* Start the WebService on the computer that directly connects to the Phidget&lt;br /&gt;
* Run your program on the remote computer that will control the Phidget over the network&lt;br /&gt;
&lt;br /&gt;
The easiest way to test these steps on Windows CE is simply to start the WebService and run the Phidget program on the same computer.  Later, you can replace one of the two ends with a different computer and/or operating system.&lt;br /&gt;
&lt;br /&gt;
To quickly create code to run remotely, we will need to modify the example code. We will go over how to modify the C#(.NET Compact Framework) in Visual Studio. Please go ahead and download the [http://www.phidgets.com/downloads/examples/CE_2.1.8.20120216.zip example code]. Extract it, and open up the {{Code|\CE\HelloWorld\HelloWorld.sln}} in Visual Studio. &lt;br /&gt;
&lt;br /&gt;
Find the line in our {{Code|HelloWorld}} example that says:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=bash&amp;gt;&lt;br /&gt;
 manager.open();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and change it to be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=bash&amp;gt;&lt;br /&gt;
 manager.open(&amp;quot;127.0.0.1&amp;quot;, 5001);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IP address &amp;quot;127.0.0.1&amp;quot; simply loops back to the same computer, and 5001 is the default port as found from using {{Code|phidget21webservice -h}} in [[#Setting Up the WebService|the Setting Up the WebService]] section. &lt;br /&gt;
&lt;br /&gt;
Build the project in Visual Studio. This will create an executable in the {{Code|Project Folder\bin\Debug}}(if you are running in debug mode).&lt;br /&gt;
&lt;br /&gt;
1. Start a command line window to run this test.  First, traverse to the {{Code|\Program Files\Phidgets}} directory and start the WebService.&lt;br /&gt;
&lt;br /&gt;
This will broadcast any Phidget events, and receive any Phidget requests, both over the network.&lt;br /&gt;
&lt;br /&gt;
2. Transfer the newly created executable onto the Windows CE system. Double click on the application to run it. &lt;br /&gt;
&lt;br /&gt;
3. Now, plug in the Phidget to the Windows CE system!  The {{Code|Phidget21webservice}} program captures the {{Code|Attach}} event and other events and sends them out over the network and the example application will receive them.&lt;br /&gt;
&lt;br /&gt;
4. You can confirm that the WebService was indeed behind this exchange by killing the WebService process while still allowing the remote program to run. Simply, in the command line window, press {{Code|Ctrl}} and {{Code|c}} at the same time.&lt;br /&gt;
&lt;br /&gt;
Note that since Windows CE does not have mDNS and cannot be detected using the Windows Control Panel or the OS X Preference Pane.&lt;br /&gt;
&lt;br /&gt;
===Debugging the WebService===&lt;br /&gt;
&lt;br /&gt;
In addition to enabling [[General Phidget Programming#Logging|logging]] in your Phidget code, you can get additional debugging information from the WebService itself.  This additional debugging can be enabled by specifying the {{Code|-v}} option:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=bash&amp;gt;&lt;br /&gt;
 PhidgetWebservice21.exe -v -n &amp;quot;myServer&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The debugging information is shown command line output.&lt;br /&gt;
&lt;br /&gt;
==Advanced Uses==&lt;br /&gt;
&lt;br /&gt;
===Manual File Installation===&lt;br /&gt;
&lt;br /&gt;
The Phidget installer installs the most commonly used files onto your system. However, there may be special cases where you want to install the Phidget libraries without the installers. Please take a look at the [[#Description of Installer files | Description of Installer files]] sections to see which files you will need to install yourself. &lt;br /&gt;
&lt;br /&gt;
Regardless of what language you will be using to program Phidgets, you will need the {{Code|phidget21.dll}} placed in the {{Code|\WINDOWS}} directory. Additional files are needed for the language that you choose. Please refer to the documentation provided by your [[Device List|language]] to determine what files are needed and the steps needed to install them onto your system.&lt;br /&gt;
&lt;br /&gt;
You can find the {{Code|phidget21.dll}} in the link below:&lt;br /&gt;
&lt;br /&gt;
*[http://www.phidgets.com/downloads/libraries/Phidget21-windevel_2.1.8.20110615.zip Phidget21 Libraries] (32-Bit and 64-Bit development files without an installer)&lt;br /&gt;
&lt;br /&gt;
{{Code|PhidgetWebService21.exe}} is also provided in the link above.&lt;br /&gt;
&lt;br /&gt;
===Deploying the Program===&lt;br /&gt;
&lt;br /&gt;
For simple programs in .NET, if the compiled Windows CE program runs on the development machine, then it should behave the same way on the target machine with the exception of the need for Invokes. It is also recommended that the program be debugged over a remote connection to the device. Make sure to include the {{Code|phidget21CE.NET.dll}} with your distribution.&lt;br /&gt;
&lt;br /&gt;
If you receive a {{Code|Can&#039;t find PInvoke DLL}} error on deployment, check to make sure that the Phidget Framework {{Code|.dlls}} are installed to the device (normally in the Windows folder). Running the {{Code|CAB}} installer is the easiest way to ensure the files are installed and registered correctly.  &lt;br /&gt;
&lt;br /&gt;
You can use the Phidget WebService to connect to remote Phidgets if USB ports are not available. Note that Windows CE does not support mDNS and by extension some {{Code|open()}} calls. In .NET, use {{Code|open(serial,&amp;quot;IPAddress&amp;quot;, port, &amp;quot;pass&amp;quot;)}}.&lt;br /&gt;
&lt;br /&gt;
===Deploying the Program on an Emulator===&lt;br /&gt;
&lt;br /&gt;
Your success for running Phidgets on an emulator may vary based on the type of the device being emulated, and whether it supports USB devices or the installation of the Phidget Framework. Here, if you receive a {{Code|Can&#039;t find PInvoke DLL}} error during execution, this means the emulator image does not have the Phidget Framework installed. One approach installing it &lt;br /&gt;
on an emulator is to set up a shared folder (File &amp;amp;rarr; Configure... &amp;amp;rarr; General &amp;amp;rarr; Shared folder) with the ARMV4I or x86 Framework inside, then browse to its location and run the installer. Also, if you’re running the Phidget WebService, you may want to have the network connection shared between the PC and device through ActiveSync.&lt;br /&gt;
&lt;br /&gt;
===Compiling Your Own OS Build===&lt;br /&gt;
&lt;br /&gt;
Often you’ll also find that after power cycling the device, the state of the operating system is reset and the Phidget drivers are lost. As a matter of convenience, it’s possible to include the Phidget drivers into the OS build so that they do not need to be reloaded every time. Building an OS image is often a complicated task and is not covered in detail here. However, if you are going to try this process it will involve using the SDK for the device, including the ARMV4I or x86 .dlls, and inserting entries into the registry for USB detection of Phidgets. The easiest way of getting the .dlls and registry entries is to copy them off the device after installing the {{Code|CAB}} file. The CE kernel source can also be found at the [#Getting Started (Libraries and Drivers) | beginning] of this page&lt;br /&gt;
&lt;br /&gt;
==Common Problems and Solutions==&lt;br /&gt;
&lt;br /&gt;
===Issue: The Phidget Windows CE libraries need to be installed everytime the system restarts===&lt;br /&gt;
This is discussed in the [[#Compiling Your Own OS Build | Compiling Your Own OS Build]] section.&lt;br /&gt;
&lt;br /&gt;
===Issue: The Phidget is not attaching to my Program===&lt;br /&gt;
If the Phidgets are already plugged into the USB port of the Windows CE device, the Phidgets will need to be re-attached to the device once the Phidget libraries are installed. This is so that the drivers can detect that the Phidgets are connected.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Appendix==&lt;br /&gt;
&lt;br /&gt;
===Description of Installer files===&lt;br /&gt;
&lt;br /&gt;
Here is the list of files and their description for each file that is distributed through the iOS drivers.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|phidget21.dll}}&amp;lt;/b&amp;gt; contains the actual Phidget library, which is used at run-time.  It is placed in {{Code|\Windows}}.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|PhidgetWebService21.exe}}&amp;lt;/b&amp;gt; is used to control Phidgets remotely across a network using the [[#WebService | PhidgetWebService]].&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|phidget21.lib}}&amp;lt;/b&amp;gt; is used by your compiler to link to the dll.  Your compiler has to know where this file is.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|phidget21.h}}&amp;lt;/b&amp;gt; lists all the Phidget API function calls available to your code.  Your compiler also has to know where this file is. &lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|phidget.dll}}&amp;lt;/b&amp;gt; is the Phidgets kernel driver. It is placed in {{Code|\Windows}}.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|Phidget21CE.NET.dll}}&amp;lt;/b&amp;gt; is the .NET(Compact Framework) Phidgets library. It is placed in {{Code|\Windows}}.&lt;/div&gt;</summary>
		<author><name>Djrudiak</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=OS_-_Windows_CE&amp;diff=19200</id>
		<title>OS - Windows CE</title>
		<link rel="alternate" type="text/html" href="https://www.phidgets.com/docs21/index.php?title=OS_-_Windows_CE&amp;diff=19200"/>
		<updated>2012-04-20T20:54:21Z</updated>

		<summary type="html">&lt;p&gt;Djrudiak: Undo revision 19199 by Djrudiak (talk)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:OS]]&lt;br /&gt;
{{OSLang|[[File:Icon-Windows CE.png‎|64x64px|link=]]|On Windows CE, Phidgets can be either plugged directly into a USB Port or run over a network using the [[#WebService | WebService]].}}&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
Phidgets are designed to run on &#039;&#039;&#039;Windows CE 5.0 or newer&#039;&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
==Getting Started (Libraries and Drivers)==&lt;br /&gt;
&lt;br /&gt;
If this is your first Phidget, we highly recommend working through the Getting Started guide [[Device List|for your specific Phidget device]]. &lt;br /&gt;
&lt;br /&gt;
In addition to owning a Windows CE system, you will also need a Windows (2000/XP/Vista/7) system for developing and deploying Windows CE applications.&lt;br /&gt;
&lt;br /&gt;
If you are already a pro, and just want the Windows CE installer:&lt;br /&gt;
&lt;br /&gt;
* [http://www.phidgets.com/downloads/libraries/Phidget21ARMV4I_2.1.8.20110615.CAB ARM4VI]&lt;br /&gt;
* [http://www.phidgets.com/downloads/libraries/Phidget21x86_2.1.8.20110615.CAB x86]&lt;br /&gt;
* [http://www.phidgets.com/downloads/libraries/Phidget21MIPSII_2.1.8.20110615.CAB MIPSII]&lt;br /&gt;
&lt;br /&gt;
The above installers are intended for the target Windows CE system. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For special cases where you want to install the Phidget libraries without the installer, please see the [[#Advanced Uses | Advanced Uses]] section. You will also have to download the Windows CE Libraries on your development machine.&lt;br /&gt;
*[http://www.phidgets.com/downloads/libraries/Phidget21-wincedevel_2.1.8.20120216.zip Phidget21 Windows CE Libraries] (All architectures)&lt;br /&gt;
*[http://www.phidgets.com/downloads/libraries/Phidget21CEkernalsource_2.1.8.20120216.zip Kernel Driver Source]&lt;br /&gt;
*[http://www.phidgets.com/Drivers_Info.html#wince Software License]&lt;br /&gt;
&lt;br /&gt;
===Installing===&lt;br /&gt;
&lt;br /&gt;
To install the libraries on the Windows CE machine, follow these steps:&lt;br /&gt;
&lt;br /&gt;
1. Download one of the Phidget installer for your system, depending on whether your system is ARM4VI, x86, or MIPSII.&lt;br /&gt;
* [http://www.phidgets.com/downloads/libraries/Phidget21ARMV4I_2.1.8.20110615.CAB ARM4VI]&lt;br /&gt;
* [http://www.phidgets.com/downloads/libraries/Phidget21x86_2.1.8.20110615.CAB x86]&lt;br /&gt;
* [http://www.phidgets.com/downloads/libraries/Phidget21MIPSII_2.1.8.20110615.CAB MIPSII]&lt;br /&gt;
&lt;br /&gt;
2. Open up the {{Code|CAB}} installer, and proceed through the wizard. If you have installed the Phidgets library before on the same system, it may mention that the Phidget libraries are already installed. This is safe to ignore. Please note that by default, the installer places the [[#Description of Library files | Phidget libraries]] in {{Code|\Program Files\Phidgets}}. &lt;br /&gt;
&lt;br /&gt;
3. Once the installation is complete, you are ready to program with Phidgets.&lt;br /&gt;
&lt;br /&gt;
For a description of what was installed onto your system, please see the [[#Description of Library files | Description of Library Files]] section. &lt;br /&gt;
&lt;br /&gt;
Proceed onto to the [[#Phidget Control Panel | next]] section where an example program will be run to confirm that the libraries were installed correctly.&lt;br /&gt;
&lt;br /&gt;
===Checking===&lt;br /&gt;
&lt;br /&gt;
To confirm the libraries were installed and work correctly, you can check if the software component works.&lt;br /&gt;
&lt;br /&gt;
If you have the Phidgets library installed on your system, you can verify that the software component is working by running the {{Code|\Program Files\Phidgets\HelloWorld.exe}} application and seeing if the Phidget device is listed in the output. You can run the application by simply double clicking on it in Windows Explorer. Note that if the Phidget is already plugged into the system, you will have to re-attach it after the Phidget libraries are installed.&lt;br /&gt;
&lt;br /&gt;
If the Phidget is plugged into an USB port and you are not able to see that the Phidget is in the list, there may be a hardware issue. &lt;br /&gt;
&lt;br /&gt;
====Troubleshooting====&lt;br /&gt;
&lt;br /&gt;
If the examples &#039;&#039;&#039;do not&#039;&#039;&#039; work but USB &#039;&#039;&#039;does&#039;&#039;&#039; work (i.e. your computer can consistently see the device in the [[#Hardware|hardware]]), take a moment to check the basics:&lt;br /&gt;
* You are using Windows CE 5.0 or greater.&lt;br /&gt;
* You have the correct package installed according to your system&#039;s architecture.&lt;br /&gt;
* No other programs, drivers, or processes are using that USB port in software&lt;br /&gt;
* The Phidget libraries are the latest version (visit the [[#Getting Started (Libraries and Drivers)| getting started section]] to download them)&lt;br /&gt;
&lt;br /&gt;
* Check the [[#Common Problems and Solutions|common problems]] section below, some specific combinations can cause problems&lt;br /&gt;
&lt;br /&gt;
If your problem doesn&#039;t seem to be fixed by these steps, make sure that the Phidget is seen &#039;&#039;&#039;consistently&#039;&#039;&#039; by USB (if it is erratic, try our [[General Troubleshooting|general troubleshooting guide]]).  If you are still having problems after using the troubleshooting guide, please [[Contact Information|ask us]]!&lt;br /&gt;
&lt;br /&gt;
==Programming Languages==&lt;br /&gt;
&lt;br /&gt;
Phidgets’ philosophy is that you do not have to be an electrical engineer in order to do projects that use devices like sensors, motors, motor controllers, and interface boards. All you need to know is how to program.&lt;br /&gt;
&lt;br /&gt;
After you have installed the drivers above, you should pick a programming language, install libraries, and run the examples for that specific language. You can learn more about what is needed to program in a particular language by choosing the language of your preference below. If you need help choosing a language, please look at the [[Software Overview#Language Support |language comparison table]]. &lt;br /&gt;
&lt;br /&gt;
Phidgets’ philosophy is that you do not have to be an electrical engineer in order to do projects that use devices like sensors, motors, motor controllers, and interface boards. All you need to know is how to program. &lt;br /&gt;
&lt;br /&gt;
On Windows CE, we recommend the following languages:&lt;br /&gt;
&lt;br /&gt;
*[[Language - C Sharp (.NET Compact Framework)|C Sharp (.NET Compact Framework)]]&lt;br /&gt;
*[[Language - C/C++|C/C++]]&lt;br /&gt;
*[[Language - Visual Basic (.NET Compact Framework)|Visual Basic (.NET Compact Framework)]]&lt;br /&gt;
&lt;br /&gt;
==WebService==&lt;br /&gt;
&lt;br /&gt;
The Phidget WebService allows you to remotely control a Phidget over a network.&lt;br /&gt;
&lt;br /&gt;
Drivers for the Phidget WebService on Windows CE are already included in the [[#Getting Started (Libraries and Drivers) | Drivers]] above. The WebService is started with the {{Code|PhidgetWebservice21.exe}} application. &lt;br /&gt;
&lt;br /&gt;
You can connect to a Phidget hosted on another computer if you know the IP address/host name of the host computer. &lt;br /&gt;
&lt;br /&gt;
This section helps you install, check, and use the WebService on Windows CE, but we also have an overview of the [[Phidget WebService]] in general.&lt;br /&gt;
&lt;br /&gt;
===Turning the WebService On and Off===&lt;br /&gt;
&lt;br /&gt;
The WebService can be turned on and off using command line.  If you used our installer, the WebService utility is automatically installed in {{Code|\Program Files\Phidgets}}. &lt;br /&gt;
&lt;br /&gt;
You can get command line help with {{Code|PhidgetWebservice21.exe}} using the -h option:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=bash&amp;gt;&lt;br /&gt;
 PhidgetWebservice21 -h&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=text&amp;gt;&lt;br /&gt;
&#039;phidgetwebservice21&#039; is a Phidget and Dictionary server from Phidgets Inc. See www.phidgets.com for more information.&lt;br /&gt;
Usage: phidgetwebservice21 [OPTION]&lt;br /&gt;
All parameters are optional. The default parameters are: port=5001, ServerName=(Computer Name) and no password&lt;br /&gt;
&lt;br /&gt;
Options:&lt;br /&gt;
  -p      Port&lt;br /&gt;
  -n      Server Name&lt;br /&gt;
  -P      Password&lt;br /&gt;
  -v      Debug mode&lt;br /&gt;
  -h      Display this help&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please note that as Windows CE does not support the use of mDNS, the -n option cannot be used. &lt;br /&gt;
&lt;br /&gt;
To find the defaults used by {{Code|phidget21webservice}}, the command line is the fastest way to learn the IP address of your computer:&lt;br /&gt;
*For your IP address, type {{Code|ipconfig}} in the command line.&lt;br /&gt;
**A line in the return text, will say something like {{Code|IP Address ........ 192.168.2.198}}, which is your IP.&lt;br /&gt;
&lt;br /&gt;
Here are some usage examples. The Windows command line is used. Traverse to the Phidget installation directory(By default, it is located in {{Code|\Program Files\Phidgets}}).&lt;br /&gt;
&lt;br /&gt;
To start the WebService with default parameters:&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=bash&amp;gt;&lt;br /&gt;
 PhidgetWebservice21.exe&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To start the WebService on port 5002:&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=bash&amp;gt;&lt;br /&gt;
 PhidgetWebservice21.exe -p 5002&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To stop the WebService, simply close the command line window or press {{Code|Ctrl}} and {{Code|c}} at the same time in the command line window.&lt;br /&gt;
&lt;br /&gt;
===Using the WebService===&lt;br /&gt;
&lt;br /&gt;
To use a Phidget over the WebService, you&#039;ll want to:&lt;br /&gt;
&lt;br /&gt;
* Start the WebService on the computer that directly connects to the Phidget&lt;br /&gt;
* Run your program on the remote computer that will control the Phidget over the network&lt;br /&gt;
&lt;br /&gt;
The easiest way to test these steps on Windows CE is simply to start the WebService and run the Phidget program on the same computer.  Later, you can replace one of the two ends with a different computer and/or operating system.&lt;br /&gt;
&lt;br /&gt;
To quickly create code to run remotely, we will need to modify the example code. We will go over how to modify the C#(.NET Compact Framework) in Visual Studio. Please go ahead and download the [http://www.phidgets.com/downloads/examples/CE_2.1.8.20120216.zip example code]. Extract it, and open up the {{Code|\CE\HelloWorld\HelloWorld.sln}} in Visual Studio. &lt;br /&gt;
&lt;br /&gt;
Find the line in our {{Code|HelloWorld}} example that says:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=bash&amp;gt;&lt;br /&gt;
 manager.open();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and change it to be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=bash&amp;gt;&lt;br /&gt;
 manager.open(&amp;quot;127.0.0.1&amp;quot;, 5001);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IP address &amp;quot;127.0.0.1&amp;quot; simply loops back to the same computer, and 5001 is the default port as found from using {{Code|phidget21webservice -h}} in [[#Setting Up the WebService|the Setting Up the WebService]] section. &lt;br /&gt;
&lt;br /&gt;
Build the project in Visual Studio. This will create an executable in the {{Code|Project Folder\bin\Debug}}(if you are running in debug mode).&lt;br /&gt;
&lt;br /&gt;
1. Start a command line window to run this test.  First, traverse to the {{Code|\Program Files\Phidgets}} directory and start the Webservice.&lt;br /&gt;
&lt;br /&gt;
This will broadcast any Phidget events, and receive any Phidget requests, both over the network.&lt;br /&gt;
&lt;br /&gt;
2. Transfer the newly created executable onto the Windows CE system. Double click on the application to run it. &lt;br /&gt;
&lt;br /&gt;
3. Now, plug in the Phidget to the Windows CE system!  The {{Code|Phidget21webservice}} program captures the {{Code|Attach}} event and other events and sends them out over the network and the example application will receive them:&lt;br /&gt;
&lt;br /&gt;
4. You can confirm that the Webservice was indeed behind this exchange by killing the Webservice process while still allowing the remote program to run. Simply, in the command line window, press {{Code|Ctrl}} and {{Code|c}} at the same time.&lt;br /&gt;
&lt;br /&gt;
Note that since Windows CE does not have mDNS and cannot be detected using the Windows Control Panel or the OS X Preference Pane.&lt;br /&gt;
&lt;br /&gt;
===Debugging the WebService===&lt;br /&gt;
&lt;br /&gt;
In addition to enabling [[General Phidget Programming#Logging|logging]] in your Phidget code, you can get additional debugging information from the WebService itself.  This additional debugging can be enabled by specifying the {{Code|-v}} option:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=bash&amp;gt;&lt;br /&gt;
 PhidgetWebservice21.exe -v -n &amp;quot;myServer&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The debugging information is shown command line output.&lt;br /&gt;
&lt;br /&gt;
==Advanced Uses==&lt;br /&gt;
&lt;br /&gt;
===Manual File Installation===&lt;br /&gt;
&lt;br /&gt;
The Phidget installer installs the most commonly used files onto your system. However, there may be special cases where you want to install the Phidget libraries without the installers. Please take a look at the [[#Description of Installer files | Description of Installer files]] sections to see which files you will need to install yourself. &lt;br /&gt;
&lt;br /&gt;
Regardless of what language you will be using to program Phidgets, you will need the {{Code|phidget21.dll}} placed in the {{Code|\WINDOWS}} directory. Additional files are needed for the language that you choose. Please refer to the documentation provided by your [[Device List|language]] to determine what files are needed and the steps needed to install them onto your system.&lt;br /&gt;
&lt;br /&gt;
You can find the {{Code|phidget21.dll}} in the link below:&lt;br /&gt;
&lt;br /&gt;
*[http://www.phidgets.com/downloads/libraries/Phidget21-windevel_2.1.8.20110615.zip Phidget21 Libraries] (32-Bit and 64-Bit development files without an installer)&lt;br /&gt;
&lt;br /&gt;
{{Code|PhidgetWebService21.exe}} is also provided in the link above.&lt;br /&gt;
&lt;br /&gt;
===Deploying the Program===&lt;br /&gt;
&lt;br /&gt;
For simple programs in .NET, if the compiled Windows CE program runs on the development machine, then it should behave the same way on the target machine with the exception of the need for Invokes. It is also recommended that the program be debugged over a remote connection to the device. Make sure to include the {{Code|phidget21CE.NET.dll}} with your distribution.&lt;br /&gt;
&lt;br /&gt;
If you receive a {{Code|Can&#039;t find PInvoke DLL}} error on deployment, check to make sure that the Phidget Framework {{Code|.dlls}} are installed to the device (normally in the Windows folder). Running the {{Code|CAB}} installer is the easiest way to ensure the files are installed and registered correctly.  &lt;br /&gt;
&lt;br /&gt;
You can use the Phidget WebService to connect to remote Phidgets if USB ports are not available. Note that Windows CE does not support mDNS and by extension some {{Code|open()}} calls. In .NET, use {{Code|open(serial,&amp;quot;IPAddress&amp;quot;, port, &amp;quot;pass&amp;quot;)}}.&lt;br /&gt;
&lt;br /&gt;
===Deploying the Program on an Emulator===&lt;br /&gt;
&lt;br /&gt;
Your success for running Phidgets on an emulator may vary based on the type of the device being emulated, and whether it supports USB devices or the installation of the Phidget Framework. Here, if you receive a {{Code|Can&#039;t find PInvoke DLL}} error during execution, this means the emulator image does not have the Phidget Framework installed. One approach installing it &lt;br /&gt;
on an emulator is to set up a shared folder (File &amp;amp;rarr; Configure... &amp;amp;rarr; General &amp;amp;rarr; Shared folder) with the ARMV4I or x86 Framework inside, then browse to its location and run the installer. Also, if you’re running the Phidget WebService, you may want to have the network connection shared between the PC and device through ActiveSync.&lt;br /&gt;
&lt;br /&gt;
===Compiling Your Own OS Build===&lt;br /&gt;
&lt;br /&gt;
Often you’ll also find that after power cycling the device, the state of the operating system is reset and the Phidget drivers are lost. As a matter of convenience, it’s possible to include the Phidget drivers into the OS build so that they do not need to be reloaded every time. Building an OS image is often a complicated task and is not covered in detail here. However, if you are going to try this process it will involve using the SDK for the device, including the ARMV4I or x86 .dlls, and inserting entries into the registry for USB detection of Phidgets. The easiest way of getting the .dlls and registry entries is to copy them off the device after installing the {{Code|CAB}} file. The CE kernel source can also be found at the [#Getting Started (Libraries and Drivers) | beginning] of this page&lt;br /&gt;
&lt;br /&gt;
==Common Problems and Solutions==&lt;br /&gt;
&lt;br /&gt;
===Issue: The Phidget Windows CE libraries need to be installed everytime the system restarts===&lt;br /&gt;
This is discussed in the [[#Compiling Your Own OS Build | Compiling Your Own OS Build]] section.&lt;br /&gt;
&lt;br /&gt;
===Issue: The Phidget is not attaching to my Program===&lt;br /&gt;
If the Phidgets are already plugged into the USB port of the Windows CE device, the Phidgets will need to be re-attached to the device once the Phidget libraries are installed. This is so that the drivers can detect that the Phidgets are connected.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Appendix==&lt;br /&gt;
&lt;br /&gt;
===Description of Installer files===&lt;br /&gt;
&lt;br /&gt;
Here is the list of files and their description for each file that is distributed through the iOS drivers.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|phidget21.dll}}&amp;lt;/b&amp;gt; contains the actual Phidget library, which is used at run-time.  It is placed in {{Code|\Windows}}.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|PhidgetWebService21.exe}}&amp;lt;/b&amp;gt; is used to control Phidgets remotely across a network using the [[#WebService | PhidgetWebService]].&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|phidget21.lib}}&amp;lt;/b&amp;gt; is used by your compiler to link to the dll.  Your compiler has to know where this file is.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|phidget21.h}}&amp;lt;/b&amp;gt; lists all the Phidget API function calls available to your code.  Your compiler also has to know where this file is. &lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|phidget.dll}}&amp;lt;/b&amp;gt; is the Phidgets kernel driver. It is placed in {{Code|\Windows}}.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|Phidget21CE.NET.dll}}&amp;lt;/b&amp;gt; is the .NET(Compact Framework) Phidgets library. It is placed in {{Code|\Windows}}.&lt;/div&gt;</summary>
		<author><name>Djrudiak</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=OS_-_Windows_CE&amp;diff=19199</id>
		<title>OS - Windows CE</title>
		<link rel="alternate" type="text/html" href="https://www.phidgets.com/docs21/index.php?title=OS_-_Windows_CE&amp;diff=19199"/>
		<updated>2012-04-20T20:53:42Z</updated>

		<summary type="html">&lt;p&gt;Djrudiak: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:OS]]&lt;br /&gt;
{{OSLang|[[File:Icon-Windows CE.png?|64x64px|link=]]|On Windows CE, Phidgets can be either plugged directly into a USB Port or run over a network using the [[#WebService | WebService]].}}&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
Phidgets are designed to run on &#039;&#039;&#039;Windows CE 5.0 or newer&#039;&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
==Getting Started (Libraries and Drivers)==&lt;br /&gt;
&lt;br /&gt;
If this is your first Phidget, we highly recommend working through the Getting Started guide [[Device List|for your specific Phidget device]]. &lt;br /&gt;
&lt;br /&gt;
In addition to owning a Windows CE system, you will also need a Windows (2000/XP/Vista/7) system for developing and deploying Windows CE applications.&lt;br /&gt;
&lt;br /&gt;
If you are already a pro, and just want the Windows CE installer:&lt;br /&gt;
&lt;br /&gt;
* [http://www.phidgets.com/downloads/libraries/Phidget21ARMV4I_2.1.8.20110615.CAB ARM4VI]&lt;br /&gt;
* [http://www.phidgets.com/downloads/libraries/Phidget21x86_2.1.8.20110615.CAB x86]&lt;br /&gt;
* [http://www.phidgets.com/downloads/libraries/Phidget21MIPSII_2.1.8.20110615.CAB MIPSII]&lt;br /&gt;
&lt;br /&gt;
The above installers are intended for the target Windows CE system. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For special cases where you want to install the Phidget libraries without the installer, please see the [[#Advanced Uses | Advanced Uses]] section. You will also have to download the Windows CE Libraries on your development machine.&lt;br /&gt;
*[http://www.phidgets.com/downloads/libraries/Phidget21-wincedevel_2.1.8.20120216.zip Phidget21 Windows CE Libraries] (All architectures)&lt;br /&gt;
*[http://www.phidgets.com/downloads/libraries/Phidget21CEkernalsource_2.1.8.20120216.zip Kernel Driver Source]&lt;br /&gt;
*[http://www.phidgets.com/Drivers_Info.html#wince Software License]&lt;br /&gt;
&lt;br /&gt;
===Installing===&lt;br /&gt;
&lt;br /&gt;
To install the libraries on the Windows CE machine, follow these steps:&lt;br /&gt;
&lt;br /&gt;
1. Download one of the Phidget installer for your system, depending on whether your system is ARM4VI, x86, or MIPSII.&lt;br /&gt;
* [http://www.phidgets.com/downloads/libraries/Phidget21ARMV4I_2.1.8.20110615.CAB ARM4VI]&lt;br /&gt;
* [http://www.phidgets.com/downloads/libraries/Phidget21x86_2.1.8.20110615.CAB x86]&lt;br /&gt;
* [http://www.phidgets.com/downloads/libraries/Phidget21MIPSII_2.1.8.20110615.CAB MIPSII]&lt;br /&gt;
&lt;br /&gt;
2. Open up the {{Code|CAB}} installer, and proceed through the wizard. If you have installed the Phidgets library before on the same system, it may mention that the Phidget libraries are already installed. This is safe to ignore. Please note that by default, the installer places the [[#Description of Library files | Phidget libraries]] in {{Code|\Program Files\Phidgets}}. &lt;br /&gt;
&lt;br /&gt;
3. Once the installation is complete, you are ready to program with Phidgets.&lt;br /&gt;
&lt;br /&gt;
For a description of what was installed onto your system, please see the [[#Description of Library files | Description of Library Files]] section. &lt;br /&gt;
&lt;br /&gt;
Proceed onto to the [[#Phidget Control Panel | next]] section where an example program will be run to confirm that the libraries were installed correctly.&lt;br /&gt;
&lt;br /&gt;
===Checking===&lt;br /&gt;
&lt;br /&gt;
To confirm the libraries were installed and work correctly, you can check if the software component works.&lt;br /&gt;
&lt;br /&gt;
If you have the Phidgets library installed on your system, you can verify that the software component is working by running the {{Code|\Program Files\Phidgets\HelloWorld.exe}} application and seeing if the Phidget device is listed in the output. You can run the application by simply double clicking on it in Windows Explorer. Note that if the Phidget is already plugged into the system, you will have to re-attach it after the Phidget libraries are installed.&lt;br /&gt;
&lt;br /&gt;
If the Phidget is plugged into an USB port and you are not able to see that the Phidget is in the list, there may be a hardware issue. &lt;br /&gt;
&lt;br /&gt;
====Troubleshooting====&lt;br /&gt;
&lt;br /&gt;
If the examples &#039;&#039;&#039;do not&#039;&#039;&#039; work but USB &#039;&#039;&#039;does&#039;&#039;&#039; work (i.e. your computer can consistently see the device in the [[#Hardware|hardware]]), take a moment to check the basics:&lt;br /&gt;
* You are using Windows CE 5.0 or greater.&lt;br /&gt;
* You have the correct package installed according to your system&#039;s architecture.&lt;br /&gt;
* No other programs, drivers, or processes are using that USB port in software&lt;br /&gt;
* The Phidget libraries are the latest version (visit the [[#Getting Started (Libraries and Drivers)| getting started section]] to download them)&lt;br /&gt;
&lt;br /&gt;
* Check the [[#Common Problems and Solutions|common problems]] section below, some specific combinations can cause problems&lt;br /&gt;
&lt;br /&gt;
If your problem doesn&#039;t seem to be fixed by these steps, make sure that the Phidget is seen &#039;&#039;&#039;consistently&#039;&#039;&#039; by USB (if it is erratic, try our [[General Troubleshooting|general troubleshooting guide]]).  If you are still having problems after using the troubleshooting guide, please [[Contact Information|ask us]]!&lt;br /&gt;
&lt;br /&gt;
==Programming Languages==&lt;br /&gt;
&lt;br /&gt;
Phidgets’ philosophy is that you do not have to be an electrical engineer in order to do projects that use devices like sensors, motors, motor controllers, and interface boards. All you need to know is how to program.&lt;br /&gt;
&lt;br /&gt;
After you have installed the drivers above, you should pick a programming language, install libraries, and run the examples for that specific language. You can learn more about what is needed to program in a particular language by choosing the language of your preference below. If you need help choosing a language, please look at the [[Software Overview#Language Support |language comparison table]]. &lt;br /&gt;
&lt;br /&gt;
Phidgets’ philosophy is that you do not have to be an electrical engineer in order to do projects that use devices like sensors, motors, motor controllers, and interface boards. All you need to know is how to program. &lt;br /&gt;
&lt;br /&gt;
On Windows CE, we recommend the following languages:&lt;br /&gt;
&lt;br /&gt;
*[[Language - C Sharp (.NET Compact Framework)|C Sharp (.NET Compact Framework)]]&lt;br /&gt;
*[[Language - C/C++|C/C++]]&lt;br /&gt;
*[[Language - Visual Basic (.NET Compact Framework)|Visual Basic (.NET Compact Framework)]]&lt;br /&gt;
&lt;br /&gt;
==WebService==&lt;br /&gt;
&lt;br /&gt;
The Phidget WebService allows you to remotely control a Phidget over a network.&lt;br /&gt;
&lt;br /&gt;
Drivers for the Phidget WebService on Windows CE are already included in the [[#Getting Started (Libraries and Drivers) | Drivers]] above. The WebService is started with the {{Code|PhidgetWebService21.exe}} application. &lt;br /&gt;
&lt;br /&gt;
You can connect to a Phidget hosted on another computer if you know the IP address/host name of the host computer. &lt;br /&gt;
&lt;br /&gt;
This section helps you install, check, and use the WebService on Windows CE, but we also have an overview of the [[Phidget WebService]] in general.&lt;br /&gt;
&lt;br /&gt;
===Turning the WebService On and Off===&lt;br /&gt;
&lt;br /&gt;
The WebService can be turned on and off using command line.  If you used our installer, the WebService utility is automatically installed in {{Code|\Program Files\Phidgets}}. &lt;br /&gt;
&lt;br /&gt;
You can get command line help with {{Code|PhidgetWebService21.exe}} using the -h option:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=bash&amp;gt;&lt;br /&gt;
 PhidgetWebService21 -h&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=text&amp;gt;&lt;br /&gt;
&#039;phidgetWebService21&#039; is a Phidget and Dictionary server from Phidgets Inc. See www.phidgets.com for more information.&lt;br /&gt;
Usage: phidgetWebService21 [OPTION]&lt;br /&gt;
All parameters are optional. The default parameters are: port=5001, ServerName=(Computer Name) and no password&lt;br /&gt;
&lt;br /&gt;
Options:&lt;br /&gt;
  -p      Port&lt;br /&gt;
  -n      Server Name&lt;br /&gt;
  -P      Password&lt;br /&gt;
  -v      Debug mode&lt;br /&gt;
  -h      Display this help&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please note that as Windows CE does not support the use of mDNS, the -n option cannot be used. &lt;br /&gt;
&lt;br /&gt;
To find the defaults used by {{Code|phidget21WebService}}, the command line is the fastest way to learn the IP address of your computer:&lt;br /&gt;
*For your IP address, type {{Code|ipconfig}} in the command line.&lt;br /&gt;
**A line in the return text, will say something like {{Code|IP Address ........ 192.168.2.198}}, which is your IP.&lt;br /&gt;
&lt;br /&gt;
Here are some usage examples. The Windows command line is used. Traverse to the Phidget installation directory(By default, it is located in {{Code|\Program Files\Phidgets}}).&lt;br /&gt;
&lt;br /&gt;
To start the WebService with default parameters:&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=bash&amp;gt;&lt;br /&gt;
 PhidgetWebService21.exe&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To start the WebService on port 5002:&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=bash&amp;gt;&lt;br /&gt;
 PhidgetWebService21.exe -p 5002&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To stop the WebService, simply close the command line window or press {{Code|Ctrl}} and {{Code|c}} at the same time in the command line window.&lt;br /&gt;
&lt;br /&gt;
===Using the WebService===&lt;br /&gt;
&lt;br /&gt;
To use a Phidget over the WebService, you&#039;ll want to:&lt;br /&gt;
&lt;br /&gt;
* Start the WebService on the computer that directly connects to the Phidget&lt;br /&gt;
* Run your program on the remote computer that will control the Phidget over the network&lt;br /&gt;
&lt;br /&gt;
The easiest way to test these steps on Windows CE is simply to start the WebService and run the Phidget program on the same computer.  Later, you can replace one of the two ends with a different computer and/or operating system.&lt;br /&gt;
&lt;br /&gt;
To quickly create code to run remotely, we will need to modify the example code. We will go over how to modify the C#(.NET Compact Framework) in Visual Studio. Please go ahead and download the [http://www.phidgets.com/downloads/examples/CE_2.1.8.20120216.zip example code]. Extract it, and open up the {{Code|\CE\HelloWorld\HelloWorld.sln}} in Visual Studio. &lt;br /&gt;
&lt;br /&gt;
Find the line in our {{Code|HelloWorld}} example that says:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=bash&amp;gt;&lt;br /&gt;
 manager.open();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and change it to be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=bash&amp;gt;&lt;br /&gt;
 manager.open(&amp;quot;127.0.0.1&amp;quot;, 5001);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IP address &amp;quot;127.0.0.1&amp;quot; simply loops back to the same computer, and 5001 is the default port as found from using {{Code|phidget21WebService -h}} in [[#Setting Up the WebService|the Setting Up the WebService]] section. &lt;br /&gt;
&lt;br /&gt;
Build the project in Visual Studio. This will create an executable in the {{Code|Project Folder\bin\Debug}}(if you are running in debug mode).&lt;br /&gt;
&lt;br /&gt;
1. Start a command line window to run this test.  First, traverse to the {{Code|\Program Files\Phidgets}} directory and start the WebService.&lt;br /&gt;
&lt;br /&gt;
This will broadcast any Phidget events, and receive any Phidget requests, both over the network.&lt;br /&gt;
&lt;br /&gt;
2. Transfer the newly created executable onto the Windows CE system. Double click on the application to run it. &lt;br /&gt;
&lt;br /&gt;
3. Now, plug in the Phidget to the Windows CE system!  The {{Code|Phidget21WebService}} program captures the {{Code|Attach}} event and other events and sends them out over the network and the example application will receive them:&lt;br /&gt;
&lt;br /&gt;
4. You can confirm that the WebService was indeed behind this exchange by killing the WebService process while still allowing the remote program to run. Simply, in the command line window, press {{Code|Ctrl}} and {{Code|c}} at the same time.&lt;br /&gt;
&lt;br /&gt;
Note that since Windows CE does not have mDNS and cannot be detected using the Windows Control Panel or the OS X Preference Pane.&lt;br /&gt;
&lt;br /&gt;
===Debugging the WebService===&lt;br /&gt;
&lt;br /&gt;
In addition to enabling [[General Phidget Programming#Logging|logging]] in your Phidget code, you can get additional debugging information from the WebService itself.  This additional debugging can be enabled by specifying the {{Code|-v}} option:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=bash&amp;gt;&lt;br /&gt;
 PhidgetWebService21.exe -v -n &amp;quot;myServer&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The debugging information is shown command line output.&lt;br /&gt;
&lt;br /&gt;
==Advanced Uses==&lt;br /&gt;
&lt;br /&gt;
===Manual File Installation===&lt;br /&gt;
&lt;br /&gt;
The Phidget installer installs the most commonly used files onto your system. However, there may be special cases where you want to install the Phidget libraries without the installers. Please take a look at the [[#Description of Installer files | Description of Installer files]] sections to see which files you will need to install yourself. &lt;br /&gt;
&lt;br /&gt;
Regardless of what language you will be using to program Phidgets, you will need the {{Code|phidget21.dll}} placed in the {{Code|\WINDOWS}} directory. Additional files are needed for the language that you choose. Please refer to the documentation provided by your [[Device List|language]] to determine what files are needed and the steps needed to install them onto your system.&lt;br /&gt;
&lt;br /&gt;
You can find the {{Code|phidget21.dll}} in the link below:&lt;br /&gt;
&lt;br /&gt;
*[http://www.phidgets.com/downloads/libraries/Phidget21-windevel_2.1.8.20110615.zip Phidget21 Libraries] (32-Bit and 64-Bit development files without an installer)&lt;br /&gt;
&lt;br /&gt;
{{Code|PhidgetWebService21.exe}} is also provided in the link above.&lt;br /&gt;
&lt;br /&gt;
===Deploying the Program===&lt;br /&gt;
&lt;br /&gt;
For simple programs in .NET, if the compiled Windows CE program runs on the development machine, then it should behave the same way on the target machine with the exception of the need for Invokes. It is also recommended that the program be debugged over a remote connection to the device. Make sure to include the {{Code|phidget21CE.NET.dll}} with your distribution.&lt;br /&gt;
&lt;br /&gt;
If you receive a {{Code|Can&#039;t find PInvoke DLL}} error on deployment, check to make sure that the Phidget Framework {{Code|.dlls}} are installed to the device (normally in the Windows folder). Running the {{Code|CAB}} installer is the easiest way to ensure the files are installed and registered correctly.  &lt;br /&gt;
&lt;br /&gt;
You can use the Phidget WebService to connect to remote Phidgets if USB ports are not available. Note that Windows CE does not support mDNS and by extension some {{Code|open()}} calls. In .NET, use {{Code|open(serial,&amp;quot;IPAddress&amp;quot;, port, &amp;quot;pass&amp;quot;)}}.&lt;br /&gt;
&lt;br /&gt;
===Deploying the Program on an Emulator===&lt;br /&gt;
&lt;br /&gt;
Your success for running Phidgets on an emulator may vary based on the type of the device being emulated, and whether it supports USB devices or the installation of the Phidget Framework. Here, if you receive a {{Code|Can&#039;t find PInvoke DLL}} error during execution, this means the emulator image does not have the Phidget Framework installed. One approach installing it &lt;br /&gt;
on an emulator is to set up a shared folder (File &amp;amp;rarr; Configure... &amp;amp;rarr; General &amp;amp;rarr; Shared folder) with the ARMV4I or x86 Framework inside, then browse to its location and run the installer. Also, if you’re running the Phidget WebService, you may want to have the network connection shared between the PC and device through ActiveSync.&lt;br /&gt;
&lt;br /&gt;
===Compiling Your Own OS Build===&lt;br /&gt;
&lt;br /&gt;
Often you’ll also find that after power cycling the device, the state of the operating system is reset and the Phidget drivers are lost. As a matter of convenience, it’s possible to include the Phidget drivers into the OS build so that they do not need to be reloaded every time. Building an OS image is often a complicated task and is not covered in detail here. However, if you are going to try this process it will involve using the SDK for the device, including the ARMV4I or x86 .dlls, and inserting entries into the registry for USB detection of Phidgets. The easiest way of getting the .dlls and registry entries is to copy them off the device after installing the {{Code|CAB}} file. The CE kernel source can also be found at the [#Getting Started (Libraries and Drivers) | beginning] of this page&lt;br /&gt;
&lt;br /&gt;
==Common Problems and Solutions==&lt;br /&gt;
&lt;br /&gt;
===Issue: The Phidget Windows CE libraries need to be installed everytime the system restarts===&lt;br /&gt;
This is discussed in the [[#Compiling Your Own OS Build | Compiling Your Own OS Build]] section.&lt;br /&gt;
&lt;br /&gt;
===Issue: The Phidget is not attaching to my Program===&lt;br /&gt;
If the Phidgets are already plugged into the USB port of the Windows CE device, the Phidgets will need to be re-attached to the device once the Phidget libraries are installed. This is so that the drivers can detect that the Phidgets are connected.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Appendix==&lt;br /&gt;
&lt;br /&gt;
===Description of Installer files===&lt;br /&gt;
&lt;br /&gt;
Here is the list of files and their description for each file that is distributed through the iOS drivers.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|phidget21.dll}}&amp;lt;/b&amp;gt; contains the actual Phidget library, which is used at run-time.  It is placed in {{Code|\Windows}}.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|PhidgetWebService21.exe}}&amp;lt;/b&amp;gt; is used to control Phidgets remotely across a network using the [[#WebService | PhidgetWebService]].&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|phidget21.lib}}&amp;lt;/b&amp;gt; is used by your compiler to link to the dll.  Your compiler has to know where this file is.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|phidget21.h}}&amp;lt;/b&amp;gt; lists all the Phidget API function calls available to your code.  Your compiler also has to know where this file is. &lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|phidget.dll}}&amp;lt;/b&amp;gt; is the Phidgets kernel driver. It is placed in {{Code|\Windows}}.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|Phidget21CE.NET.dll}}&amp;lt;/b&amp;gt; is the .NET(Compact Framework) Phidgets library. It is placed in {{Code|\Windows}}.&lt;/div&gt;</summary>
		<author><name>Djrudiak</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=OS_-_Windows_CE&amp;diff=19198</id>
		<title>OS - Windows CE</title>
		<link rel="alternate" type="text/html" href="https://www.phidgets.com/docs21/index.php?title=OS_-_Windows_CE&amp;diff=19198"/>
		<updated>2012-04-20T20:52:54Z</updated>

		<summary type="html">&lt;p&gt;Djrudiak: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:OS]]&lt;br /&gt;
{{OSLang|[[File:Icon-Windows CE.png‎|64x64px|link=]]|On Windows CE, Phidgets can be either plugged directly into a USB Port or run over a network using the [[#WebService | WebService]].}}&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
Phidgets are designed to run on &#039;&#039;&#039;Windows CE 5.0 or newer&#039;&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
==Getting Started (Libraries and Drivers)==&lt;br /&gt;
&lt;br /&gt;
If this is your first Phidget, we highly recommend working through the Getting Started guide [[Device List|for your specific Phidget device]]. &lt;br /&gt;
&lt;br /&gt;
In addition to owning a Windows CE system, you will also need a Windows (2000/XP/Vista/7) system for developing and deploying Windows CE applications.&lt;br /&gt;
&lt;br /&gt;
If you are already a pro, and just want the Windows CE installer:&lt;br /&gt;
&lt;br /&gt;
* [http://www.phidgets.com/downloads/libraries/Phidget21ARMV4I_2.1.8.20110615.CAB ARM4VI]&lt;br /&gt;
* [http://www.phidgets.com/downloads/libraries/Phidget21x86_2.1.8.20110615.CAB x86]&lt;br /&gt;
* [http://www.phidgets.com/downloads/libraries/Phidget21MIPSII_2.1.8.20110615.CAB MIPSII]&lt;br /&gt;
&lt;br /&gt;
The above installers are intended for the target Windows CE system. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For special cases where you want to install the Phidget libraries without the installer, please see the [[#Advanced Uses | Advanced Uses]] section. You will also have to download the Windows CE Libraries on your development machine.&lt;br /&gt;
*[http://www.phidgets.com/downloads/libraries/Phidget21-wincedevel_2.1.8.20120216.zip Phidget21 Windows CE Libraries] (All architectures)&lt;br /&gt;
*[http://www.phidgets.com/downloads/libraries/Phidget21CEkernalsource_2.1.8.20120216.zip Kernel Driver Source]&lt;br /&gt;
*[http://www.phidgets.com/Drivers_Info.html#wince Software License]&lt;br /&gt;
&lt;br /&gt;
===Installing===&lt;br /&gt;
&lt;br /&gt;
To install the libraries on the Windows CE machine, follow these steps:&lt;br /&gt;
&lt;br /&gt;
1. Download one of the Phidget installer for your system, depending on whether your system is ARM4VI, x86, or MIPSII.&lt;br /&gt;
* [http://www.phidgets.com/downloads/libraries/Phidget21ARMV4I_2.1.8.20110615.CAB ARM4VI]&lt;br /&gt;
* [http://www.phidgets.com/downloads/libraries/Phidget21x86_2.1.8.20110615.CAB x86]&lt;br /&gt;
* [http://www.phidgets.com/downloads/libraries/Phidget21MIPSII_2.1.8.20110615.CAB MIPSII]&lt;br /&gt;
&lt;br /&gt;
2. Open up the {{Code|CAB}} installer, and proceed through the wizard. If you have installed the Phidgets library before on the same system, it may mention that the Phidget libraries are already installed. This is safe to ignore. Please note that by default, the installer places the [[#Description of Library files | Phidget libraries]] in {{Code|\Program Files\Phidgets}}. &lt;br /&gt;
&lt;br /&gt;
3. Once the installation is complete, you are ready to program with Phidgets.&lt;br /&gt;
&lt;br /&gt;
For a description of what was installed onto your system, please see the [[#Description of Library files | Description of Library Files]] section. &lt;br /&gt;
&lt;br /&gt;
Proceed onto to the [[#Phidget Control Panel | next]] section where an example program will be run to confirm that the libraries were installed correctly.&lt;br /&gt;
&lt;br /&gt;
===Checking===&lt;br /&gt;
&lt;br /&gt;
To confirm the libraries were installed and work correctly, you can check if the software component works.&lt;br /&gt;
&lt;br /&gt;
If you have the Phidgets library installed on your system, you can verify that the software component is working by running the {{Code|\Program Files\Phidgets\HelloWorld.exe}} application and seeing if the Phidget device is listed in the output. You can run the application by simply double clicking on it in Windows Explorer. Note that if the Phidget is already plugged into the system, you will have to re-attach it after the Phidget libraries are installed.&lt;br /&gt;
&lt;br /&gt;
If the Phidget is plugged into an USB port and you are not able to see that the Phidget is in the list, there may be a hardware issue. &lt;br /&gt;
&lt;br /&gt;
====Troubleshooting====&lt;br /&gt;
&lt;br /&gt;
If the examples &#039;&#039;&#039;do not&#039;&#039;&#039; work but USB &#039;&#039;&#039;does&#039;&#039;&#039; work (i.e. your computer can consistently see the device in the [[#Hardware|hardware]]), take a moment to check the basics:&lt;br /&gt;
* You are using Windows CE 5.0 or greater.&lt;br /&gt;
* You have the correct package installed according to your system&#039;s architecture.&lt;br /&gt;
* No other programs, drivers, or processes are using that USB port in software&lt;br /&gt;
* The Phidget libraries are the latest version (visit the [[#Getting Started (Libraries and Drivers)| getting started section]] to download them)&lt;br /&gt;
&lt;br /&gt;
* Check the [[#Common Problems and Solutions|common problems]] section below, some specific combinations can cause problems&lt;br /&gt;
&lt;br /&gt;
If your problem doesn&#039;t seem to be fixed by these steps, make sure that the Phidget is seen &#039;&#039;&#039;consistently&#039;&#039;&#039; by USB (if it is erratic, try our [[General Troubleshooting|general troubleshooting guide]]).  If you are still having problems after using the troubleshooting guide, please [[Contact Information|ask us]]!&lt;br /&gt;
&lt;br /&gt;
==Programming Languages==&lt;br /&gt;
&lt;br /&gt;
Phidgets’ philosophy is that you do not have to be an electrical engineer in order to do projects that use devices like sensors, motors, motor controllers, and interface boards. All you need to know is how to program.&lt;br /&gt;
&lt;br /&gt;
After you have installed the drivers above, you should pick a programming language, install libraries, and run the examples for that specific language. You can learn more about what is needed to program in a particular language by choosing the language of your preference below. If you need help choosing a language, please look at the [[Software Overview#Language Support |language comparison table]]. &lt;br /&gt;
&lt;br /&gt;
Phidgets’ philosophy is that you do not have to be an electrical engineer in order to do projects that use devices like sensors, motors, motor controllers, and interface boards. All you need to know is how to program. &lt;br /&gt;
&lt;br /&gt;
On Windows CE, we recommend the following languages:&lt;br /&gt;
&lt;br /&gt;
*[[Language - C Sharp (.NET Compact Framework)|C Sharp (.NET Compact Framework)]]&lt;br /&gt;
*[[Language - C/C++|C/C++]]&lt;br /&gt;
*[[Language - Visual Basic (.NET Compact Framework)|Visual Basic (.NET Compact Framework)]]&lt;br /&gt;
&lt;br /&gt;
==WebService==&lt;br /&gt;
&lt;br /&gt;
The Phidget WebService allows you to remotely control a Phidget over a network.&lt;br /&gt;
&lt;br /&gt;
Drivers for the Phidget WebService on Windows CE are already included in the [[#Getting Started (Libraries and Drivers) | Drivers]] above. The WebService is started with the {{Code|PhidgetWebservice21.exe}} application. &lt;br /&gt;
&lt;br /&gt;
You can connect to a Phidget hosted on another computer if you know the IP address/host name of the host computer. &lt;br /&gt;
&lt;br /&gt;
This section helps you install, check, and use the WebService on Windows CE, but we also have an overview of the [[Phidget WebService]] in general.&lt;br /&gt;
&lt;br /&gt;
===Turning the WebService On and Off===&lt;br /&gt;
&lt;br /&gt;
The WebService can be turned on and off using command line.  If you used our installer, the WebService utility is automatically installed in {{Code|\Program Files\Phidgets}}. &lt;br /&gt;
&lt;br /&gt;
You can get command line help with {{Code|PhidgetWebservice21.exe}} using the -h option:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=bash&amp;gt;&lt;br /&gt;
 PhidgetWebservice21 -h&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=text&amp;gt;&lt;br /&gt;
&#039;phidgetwebservice21&#039; is a Phidget and Dictionary server from Phidgets Inc. See www.phidgets.com for more information.&lt;br /&gt;
Usage: phidgetwebservice21 [OPTION]&lt;br /&gt;
All parameters are optional. The default parameters are: port=5001, ServerName=(Computer Name) and no password&lt;br /&gt;
&lt;br /&gt;
Options:&lt;br /&gt;
  -p      Port&lt;br /&gt;
  -n      Server Name&lt;br /&gt;
  -P      Password&lt;br /&gt;
  -v      Debug mode&lt;br /&gt;
  -h      Display this help&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please note that as Windows CE does not support the use of mDNS, the -n option cannot be used. &lt;br /&gt;
&lt;br /&gt;
To find the defaults used by {{Code|phidget21webservice}}, the command line is the fastest way to learn the IP address of your computer:&lt;br /&gt;
*For your IP address, type {{Code|ipconfig}} in the command line.&lt;br /&gt;
**A line in the return text, will say something like {{Code|IP Address ........ 192.168.2.198}}, which is your IP.&lt;br /&gt;
&lt;br /&gt;
Here are some usage examples. The Windows command line is used. Traverse to the Phidget installation directory(By default, it is located in {{Code|\Program Files\Phidgets}}).&lt;br /&gt;
&lt;br /&gt;
To start the WebService with default parameters:&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=bash&amp;gt;&lt;br /&gt;
 PhidgetWebservice21.exe&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To start the WebService on port 5002:&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=bash&amp;gt;&lt;br /&gt;
 PhidgetWebservice21.exe -p 5002&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To stop the WebService, simply close the command line window or press {{Code|Ctrl}} and {{Code|c}} at the same time in the command line window.&lt;br /&gt;
&lt;br /&gt;
===Using the WebService===&lt;br /&gt;
&lt;br /&gt;
To use a Phidget over the WebService, you&#039;ll want to:&lt;br /&gt;
&lt;br /&gt;
* Start the WebService on the computer that directly connects to the Phidget&lt;br /&gt;
* Run your program on the remote computer that will control the Phidget over the network&lt;br /&gt;
&lt;br /&gt;
The easiest way to test these steps on Windows CE is simply to start the WebService and run the Phidget program on the same computer.  Later, you can replace one of the two ends with a different computer and/or operating system.&lt;br /&gt;
&lt;br /&gt;
To quickly create code to run remotely, we will need to modify the example code. We will go over how to modify the C#(.NET Compact Framework) in Visual Studio. Please go ahead and download the [http://www.phidgets.com/downloads/examples/CE_2.1.8.20120216.zip example code]. Extract it, and open up the {{Code|\CE\HelloWorld\HelloWorld.sln}} in Visual Studio. &lt;br /&gt;
&lt;br /&gt;
Find the line in our {{Code|HelloWorld}} example that says:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=bash&amp;gt;&lt;br /&gt;
 manager.open();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and change it to be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=bash&amp;gt;&lt;br /&gt;
 manager.open(&amp;quot;127.0.0.1&amp;quot;, 5001);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IP address &amp;quot;127.0.0.1&amp;quot; simply loops back to the same computer, and 5001 is the default port as found from using {{Code|phidget21webservice -h}} in [[#Setting Up the WebService|the Setting Up the WebService]] section. &lt;br /&gt;
&lt;br /&gt;
Build the project in Visual Studio. This will create an executable in the {{Code|Project Folder\bin\Debug}}(if you are running in debug mode).&lt;br /&gt;
&lt;br /&gt;
1. Start a command line window to run this test.  First, traverse to the {{Code|\Program Files\Phidgets}} directory and start the Webservice.&lt;br /&gt;
&lt;br /&gt;
This will broadcast any Phidget events, and receive any Phidget requests, both over the network.&lt;br /&gt;
&lt;br /&gt;
2. Transfer the newly created executable onto the Windows CE system. Double click on the application to run it. &lt;br /&gt;
&lt;br /&gt;
3. Now, plug in the Phidget to the Windows CE system!  The {{Code|Phidget21webservice}} program captures the {{Code|Attach}} event and other events and sends them out over the network and the example application will receive them:&lt;br /&gt;
&lt;br /&gt;
4. You can confirm that the Webservice was indeed behind this exchange by killing the Webservice process while still allowing the remote program to run. Simply, in the command line window, press {{Code|Ctrl}} and {{Code|c}} at the same time.&lt;br /&gt;
&lt;br /&gt;
Note that since Windows CE does not have mDNS and cannot be detected using the Windows Control Panel or the OS X Preference Pane.&lt;br /&gt;
&lt;br /&gt;
===Debugging the WebService===&lt;br /&gt;
&lt;br /&gt;
In addition to enabling [[General Phidget Programming#Logging|logging]] in your Phidget code, you can get additional debugging information from the WebService itself.  This additional debugging can be enabled by specifying the {{Code|-v}} option:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=bash&amp;gt;&lt;br /&gt;
 PhidgetWebservice21.exe -v -n &amp;quot;myServer&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The debugging information is shown command line output.&lt;br /&gt;
&lt;br /&gt;
==Advanced Uses==&lt;br /&gt;
&lt;br /&gt;
===Manual File Installation===&lt;br /&gt;
&lt;br /&gt;
The Phidget installer installs the most commonly used files onto your system. However, there may be special cases where you want to install the Phidget libraries without the installers. Please take a look at the [[#Description of Installer files | Description of Installer files]] sections to see which files you will need to install yourself. &lt;br /&gt;
&lt;br /&gt;
Regardless of what language you will be using to program Phidgets, you will need the {{Code|phidget21.dll}} placed in the {{Code|\WINDOWS}} directory. Additional files are needed for the language that you choose. Please refer to the documentation provided by your [[Device List|language]] to determine what files are needed and the steps needed to install them onto your system.&lt;br /&gt;
&lt;br /&gt;
You can find the {{Code|phidget21.dll}} in the link below:&lt;br /&gt;
&lt;br /&gt;
*[http://www.phidgets.com/downloads/libraries/Phidget21-windevel_2.1.8.20110615.zip Phidget21 Libraries] (32-Bit and 64-Bit development files without an installer)&lt;br /&gt;
&lt;br /&gt;
{{Code|PhidgetWebService21.exe}} is also provided in the link above.&lt;br /&gt;
&lt;br /&gt;
===Deploying the Program===&lt;br /&gt;
&lt;br /&gt;
For simple programs in .NET, if the compiled Windows CE program runs on the development machine, then it should behave the same way on the target machine with the exception of the need for Invokes. It is also recommended that the program be debugged over a remote connection to the device. Make sure to include the {{Code|phidget21CE.NET.dll}} with your distribution.&lt;br /&gt;
&lt;br /&gt;
If you receive a {{Code|Can&#039;t find PInvoke DLL}} error on deployment, check to make sure that the Phidget Framework {{Code|.dlls}} are installed to the device (normally in the Windows folder). Running the {{Code|CAB}} installer is the easiest way to ensure the files are installed and registered correctly.  &lt;br /&gt;
&lt;br /&gt;
You can use the Phidget WebService to connect to remote Phidgets if USB ports are not available. Note that Windows CE does not support mDNS and by extension some {{Code|open()}} calls. In .NET, use {{Code|open(serial,&amp;quot;IPAddress&amp;quot;, port, &amp;quot;pass&amp;quot;)}}.&lt;br /&gt;
&lt;br /&gt;
===Deploying the Program on an Emulator===&lt;br /&gt;
&lt;br /&gt;
Your success for running Phidgets on an emulator may vary based on the type of the device being emulated, and whether it supports USB devices or the installation of the Phidget Framework. Here, if you receive a {{Code|Can&#039;t find PInvoke DLL}} error during execution, this means the emulator image does not have the Phidget Framework installed. One approach installing it &lt;br /&gt;
on an emulator is to set up a shared folder (File &amp;amp;rarr; Configure... &amp;amp;rarr; General &amp;amp;rarr; Shared folder) with the ARMV4I or x86 Framework inside, then browse to its location and run the installer. Also, if you’re running the Phidget WebService, you may want to have the network connection shared between the PC and device through ActiveSync.&lt;br /&gt;
&lt;br /&gt;
===Compiling Your Own OS Build===&lt;br /&gt;
&lt;br /&gt;
Often you’ll also find that after power cycling the device, the state of the operating system is reset and the Phidget drivers are lost. As a matter of convenience, it’s possible to include the Phidget drivers into the OS build so that they do not need to be reloaded every time. Building an OS image is often a complicated task and is not covered in detail here. However, if you are going to try this process it will involve using the SDK for the device, including the ARMV4I or x86 .dlls, and inserting entries into the registry for USB detection of Phidgets. The easiest way of getting the .dlls and registry entries is to copy them off the device after installing the {{Code|CAB}} file. The CE kernel source can also be found at the [#Getting Started (Libraries and Drivers) | beginning] of this page&lt;br /&gt;
&lt;br /&gt;
==Common Problems and Solutions==&lt;br /&gt;
&lt;br /&gt;
===Issue: The Phidget Windows CE libraries need to be installed everytime the system restarts===&lt;br /&gt;
This is discussed in the [[#Compiling Your Own OS Build | Compiling Your Own OS Build]] section.&lt;br /&gt;
&lt;br /&gt;
===Issue: The Phidget is not attaching to my Program===&lt;br /&gt;
If the Phidgets are already plugged into the USB port of the Windows CE device, the Phidgets will need to be re-attached to the device once the Phidget libraries are installed. This is so that the drivers can detect that the Phidgets are connected.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Appendix==&lt;br /&gt;
&lt;br /&gt;
===Description of Installer files===&lt;br /&gt;
&lt;br /&gt;
Here is the list of files and their description for each file that is distributed through the iOS drivers.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|phidget21.dll}}&amp;lt;/b&amp;gt; contains the actual Phidget library, which is used at run-time.  It is placed in {{Code|\Windows}}.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|PhidgetWebService21.exe}}&amp;lt;/b&amp;gt; is used to control Phidgets remotely across a network using the [[#WebService | PhidgetWebService]].&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|phidget21.lib}}&amp;lt;/b&amp;gt; is used by your compiler to link to the dll.  Your compiler has to know where this file is.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|phidget21.h}}&amp;lt;/b&amp;gt; lists all the Phidget API function calls available to your code.  Your compiler also has to know where this file is. &lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|phidget.dll}}&amp;lt;/b&amp;gt; is the Phidgets kernel driver. It is placed in {{Code|\Windows}}.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|Phidget21CE.NET.dll}}&amp;lt;/b&amp;gt; is the .NET(Compact Framework) Phidgets library. It is placed in {{Code|\Windows}}.&lt;/div&gt;</summary>
		<author><name>Djrudiak</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=OS_-_iOS&amp;diff=19195</id>
		<title>OS - iOS</title>
		<link rel="alternate" type="text/html" href="https://www.phidgets.com/docs21/index.php?title=OS_-_iOS&amp;diff=19195"/>
		<updated>2012-04-20T20:14:51Z</updated>

		<summary type="html">&lt;p&gt;Djrudiak: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:OS]]&lt;br /&gt;
{{OSLang|[[File:Icon-iOS.png|64x64px|link=OS - iOS]]|iOS is the operating system used on iOS devices such as the iPad, iPhone, and iPod touch.}}&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
Phidgets are designed to run on devices with an iOS version of 3.0 or later. It is strongly recommended that your device have the latest iOS version available to the device installed. As iOS devices do not have USB ports, the Phidgets will have to be connected on a computer with USB ports, and the iOS device will be able to interact with the Phidget over the [[Phidget_WebService|WebService]]. If you are looking for a compact and an inexpensive way to host Phidgets over a network, take a look at our [[1072 0 - PhidgetSBC2|Single Board Computer]].&lt;br /&gt;
&lt;br /&gt;
==Getting Started (Libraries and Drivers)==&lt;br /&gt;
&lt;br /&gt;
If this is your first Phidget, we highly recommend working through the Getting Started guide [[Device List|for your specific Phidget device]]. &lt;br /&gt;
&lt;br /&gt;
If you are already a pro, and just want the iOS drivers:&lt;br /&gt;
&lt;br /&gt;
*[http://www.phidgets.com/downloads/libraries/Phidget-iPhone_2.1.8.20120216.zip iOS Libraries]&lt;br /&gt;
&lt;br /&gt;
===Installing===&lt;br /&gt;
&lt;br /&gt;
iOS code is developed on an OS X machine, and so getting your Phidget to work locally on the OS X machine first will help you distinguish any issues from network ones later. The OS X machine will need the Phidget drivers installed, please see the [[OS - OS X | OS X]] page for more information. &lt;br /&gt;
&lt;br /&gt;
You will also need to [http://www.phidgets.com/downloads/libraries/Phidget-iPhone_2.1.8.20120216.zip iOS drivers] to code your program against. &lt;br /&gt;
The &amp;quot;installation&amp;quot; of the Phidget iOS libraries is simply linking and distributing the libraries with your project. As the most common platform to do this is through Xcode, we provide brief instructions on how to easily follow along with our already-linked examples later.&lt;br /&gt;
&lt;br /&gt;
To install the libraries, follow these steps on the development computer:&lt;br /&gt;
&lt;br /&gt;
1. Download the Phidget [http://www.phidgets.com/downloads/libraries/Phidget-iPhone_2.1.8.20120216.zip drivers for iOS].&lt;br /&gt;
&lt;br /&gt;
2. Unzip the file, and you will find three things:&lt;br /&gt;
&lt;br /&gt;
# Libraries for the iOS device and iOS simulator.&lt;br /&gt;
# Example Xcode project for the PhidgetInterfaceKit and PhidgetManager.&lt;br /&gt;
# Skeleton Xcode project - contains the minimal project settings already filled in for Phidgets development. &lt;br /&gt;
&lt;br /&gt;
Feel free to browse around within the folders to get a sense of what will be going on the iOS side.  We describe how to link and use these library files later on the [[Language - iOS#Write Your Own Code | Write your own iOS code]] section of the iOS Cocoa Touch page.  For now, having found them means you can copy and install them to any project directory you want.&lt;br /&gt;
&lt;br /&gt;
First, though, it will be useful to check to make sure Phidgets work with your iOS system.&lt;br /&gt;
&lt;br /&gt;
===Checking===&lt;br /&gt;
&lt;br /&gt;
When you run a Phidgets iOS example, you transfer and link the libraries and code all at the same time.  This should &amp;lt;i&amp;gt;just work&amp;lt;/i&amp;gt; with our examples, but if problems arise this section gives more detail on pinpointing the source of the problem.  We recommend starting with running the software examples right away - if the software works, you know the hardware works too.&lt;br /&gt;
&lt;br /&gt;
====Software====&lt;br /&gt;
&lt;br /&gt;
The easiest way to see whether your libraries are set up correctly within our examples or your own project is just to download them to the iOS device and run them.  Detailed instructions for this (including choosing the right {{Code|HelloWorld}} project to run) are on the [[Language - iOS]] page.  That page will be your next step - but if the examples do not run using the instructions, return here to debug your hardware.&lt;br /&gt;
&lt;br /&gt;
====Hardware====&lt;br /&gt;
&lt;br /&gt;
If you are having problems running the examples, you should check the hardware of the host computer.&lt;br /&gt;
&lt;br /&gt;
When using the [[#WebService|WebService]] to control a Phidget, the problem may be with the USB connection on the remote computer.  Make sure both the server-side of (a) the webservice and (b) the USB connection are working by using the instructions on the [[OS - OS X|OS X page]]&lt;br /&gt;
&lt;br /&gt;
====Troubleshooting====&lt;br /&gt;
&lt;br /&gt;
If the examples &#039;&#039;&#039;do not&#039;&#039;&#039; work but USB &#039;&#039;&#039;does&#039;&#039;&#039; work (i.e. your remote computer or iOS device can consistently see the device in the [[#Hardware|hardware]]), take a moment to check the basics:&lt;br /&gt;
* No other programs, drivers, or processes are using the Phidget on the host computer.&lt;br /&gt;
* You have copied and linked the Phidget iOS libraries (as described on the [[Language - iOS]] page)&lt;br /&gt;
* The Phidget libraries are the latest version (visit the [[#Getting Started (Libraries and Drivers)| getting started section]] to download them)&lt;br /&gt;
* Ensure that the webservice drivers and the iOS libraries are both the latest version&lt;br /&gt;
* Ensure that you have the most up to date iOS version installed for your device.&lt;br /&gt;
* Check the [[#Common Problems and Solutions|common problems]] section below, some specific combinations can cause problems&lt;br /&gt;
&lt;br /&gt;
If your problem doesn&#039;t seem to be fixed by these steps, make sure that the Phidget is seen &#039;&#039;&#039;consistently&#039;&#039;&#039; by USB in [[#Hardware|hardware]] (if it is erratic, try our [[General Troubleshooting|general troubleshooting guide]]).  If you are still having problems after using the troubleshooting guide, please [[Contact Information|ask us]]!&lt;br /&gt;
&lt;br /&gt;
==Programming Languages==&lt;br /&gt;
&lt;br /&gt;
iOS programs are written in [[Language - iOS|Objective C]] using the Cocoa Touch framework. You can read on within this page to learn how to use iOS with the Webservice, or you can jump ahead right now to the [[Language - iOS|iOS]] page and start writing code!&lt;br /&gt;
&lt;br /&gt;
==WebService==&lt;br /&gt;
&lt;br /&gt;
The Phidget WebService allows you to remotely control a Phidget over a network.&amp;lt;br&amp;gt;This section helps you use the WebService on iOS, but we also have an overview of the [[Phidget WebService]] in general.&lt;br /&gt;
&lt;br /&gt;
Currently, iOS devices cannot &#039;&#039;host&#039;&#039; the WebService, but they can use data streaming from another computer over the WebService.&lt;br /&gt;
&lt;br /&gt;
===Setting Up the WebService===&lt;br /&gt;
&lt;br /&gt;
Using an iOS device, your network-controlled Phidget system will probably look something like this:&lt;br /&gt;
&lt;br /&gt;
[[Image:webservice_general_pctoios.png|600px|link=|alt=]]&lt;br /&gt;
&lt;br /&gt;
To begin, &lt;br /&gt;
&lt;br /&gt;
1. Start the WebService on the host computer&lt;br /&gt;
* How to do this [[OS - Windows#WebService|on Windows]]&lt;br /&gt;
* How to do this [[OS - OS X#WebService|on Mac OS]]&lt;br /&gt;
* How to do this [[OS - Linux#WebService|on Linux]]&lt;br /&gt;
* How to do this [[OS - Phidget SBC#WebService|on the Phidget Single Board Computer]]&lt;br /&gt;
&lt;br /&gt;
2. Download and unzip the [http://www.phidgets.com/downloads/libraries/Phidget-iPhone_2.1.8.20120216.zip iOS Examples] anywhere on the development computer.&lt;br /&gt;
&lt;br /&gt;
3. Open up the {{Code|HelloWorld.xcodeproj}} into Xcode. Select either an iOS device or iOS simulator as the destination. For more information, please see the [[Language - iOS#Use OurExamples|Use Our Examples]] section of the iOS language page.&lt;br /&gt;
&lt;br /&gt;
4. In Xcode, hit the {{Code|Run}} button to transfer the application to the device or simulator as well as run it.&lt;br /&gt;
&lt;br /&gt;
===Using the WebService===&lt;br /&gt;
&lt;br /&gt;
After performing the steps above, you will be using the WebService already.  Plugging in the Phidget to the host computer will give you a screen like this:&lt;br /&gt;
&lt;br /&gt;
[[File:iOS Webservice Example HelloWorld Output.png|link=|alt=HelloWorld Output]]&lt;br /&gt;
&lt;br /&gt;
The above screenshot shows that a number of Phidgets are attached to the USB ports of computer connected to the network. Go ahead and detach the Phidgets from the USB port of the host computer, and see what happens.&lt;br /&gt;
&lt;br /&gt;
===Debugging the WebService===&lt;br /&gt;
&lt;br /&gt;
Since an iOS device can only be a user and not a host of the WebService, you should use debugging server side.  Refer to the webservice sections for each operating system:&lt;br /&gt;
* [[OS - Windows#WebService|Windows]]&lt;br /&gt;
* [[OS - OS X#WebService|Mac OS]]&lt;br /&gt;
* [[OS - Linux#WebService|Linux]]&lt;br /&gt;
* [[OS - Phidget SBC#WebService|Phidget Single Board Computer]]&lt;br /&gt;
In addition, if you are having WebService problems, you will probably find the webservice section of our [[General Troubleshooting#WebService Troubleshooting|General Troubleshooting Guide]] helpful as well.&lt;br /&gt;
&lt;br /&gt;
==Advanced Uses==&lt;br /&gt;
&lt;br /&gt;
==Common Problems and Solutions==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Appendix==&lt;br /&gt;
&lt;br /&gt;
===Description of Installer files===&lt;br /&gt;
&lt;br /&gt;
Here is the list of files and their description for each file that is distributed through the iOS drivers.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|iphoneos/libPhidget21.a}}&amp;lt;/b&amp;gt; contains the actual Phidget library, which is used at run-time.  This library is used when you are testing the example on the actual iOS device.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|iphonesimulator/libPhidget21.a}}&amp;lt;/b&amp;gt; contains the actual Phidget library, which is used at run-time.  This library is used when you are testing the example an iOS simulator.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|phidget21.h}}&amp;lt;/b&amp;gt; lists all the Phidget API function calls available to your code.  Your compiler also has to know where this file is.  &lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|SkeletonProject}}&amp;lt;/b&amp;gt; is a Xcode project containing the bare minimum project settings already filled in to code with the Phidget library.&lt;/div&gt;</summary>
		<author><name>Djrudiak</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=OS_-_iOS&amp;diff=19194</id>
		<title>OS - iOS</title>
		<link rel="alternate" type="text/html" href="https://www.phidgets.com/docs21/index.php?title=OS_-_iOS&amp;diff=19194"/>
		<updated>2012-04-20T20:14:22Z</updated>

		<summary type="html">&lt;p&gt;Djrudiak: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:OS]]&lt;br /&gt;
{{OSLang|[[File:Icon-iOS.png|64x64px|link=OS - iOS]]|iOS is the operating system used on iOS devices such as the iPad, iPhone, and iPod touch.}}&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
Phidgets are designed to run on devices with an iOS version of 3.0 or later. It is strongly recommended that your device have the latest iOS version available to the device installed. As iOS devices do not have USB ports, the Phidgets will have to be connected on a computer with USB ports, and the iOS device will be able to interact with the Phidget over the [[WebService]]. If you are looking for a compact and an inexpensive way to host Phidgets over a network, take a look at our [[1072 0 - PhidgetSBC2|Single Board Computer]].&lt;br /&gt;
&lt;br /&gt;
==Getting Started (Libraries and Drivers)==&lt;br /&gt;
&lt;br /&gt;
If this is your first Phidget, we highly recommend working through the Getting Started guide [[Device List|for your specific Phidget device]]. &lt;br /&gt;
&lt;br /&gt;
If you are already a pro, and just want the iOS drivers:&lt;br /&gt;
&lt;br /&gt;
*[http://www.phidgets.com/downloads/libraries/Phidget-iPhone_2.1.8.20120216.zip iOS Libraries]&lt;br /&gt;
&lt;br /&gt;
===Installing===&lt;br /&gt;
&lt;br /&gt;
iOS code is developed on an OS X machine, and so getting your Phidget to work locally on the OS X machine first will help you distinguish any issues from network ones later. The OS X machine will need the Phidget drivers installed, please see the [[OS - OS X | OS X]] page for more information. &lt;br /&gt;
&lt;br /&gt;
You will also need to [http://www.phidgets.com/downloads/libraries/Phidget-iPhone_2.1.8.20120216.zip iOS drivers] to code your program against. &lt;br /&gt;
The &amp;quot;installation&amp;quot; of the Phidget iOS libraries is simply linking and distributing the libraries with your project. As the most common platform to do this is through Xcode, we provide brief instructions on how to easily follow along with our already-linked examples later.&lt;br /&gt;
&lt;br /&gt;
To install the libraries, follow these steps on the development computer:&lt;br /&gt;
&lt;br /&gt;
1. Download the Phidget [http://www.phidgets.com/downloads/libraries/Phidget-iPhone_2.1.8.20120216.zip drivers for iOS].&lt;br /&gt;
&lt;br /&gt;
2. Unzip the file, and you will find three things:&lt;br /&gt;
&lt;br /&gt;
# Libraries for the iOS device and iOS simulator.&lt;br /&gt;
# Example Xcode project for the PhidgetInterfaceKit and PhidgetManager.&lt;br /&gt;
# Skeleton Xcode project - contains the minimal project settings already filled in for Phidgets development. &lt;br /&gt;
&lt;br /&gt;
Feel free to browse around within the folders to get a sense of what will be going on the iOS side.  We describe how to link and use these library files later on the [[Language - iOS#Write Your Own Code | Write your own iOS code]] section of the iOS Cocoa Touch page.  For now, having found them means you can copy and install them to any project directory you want.&lt;br /&gt;
&lt;br /&gt;
First, though, it will be useful to check to make sure Phidgets work with your iOS system.&lt;br /&gt;
&lt;br /&gt;
===Checking===&lt;br /&gt;
&lt;br /&gt;
When you run a Phidgets iOS example, you transfer and link the libraries and code all at the same time.  This should &amp;lt;i&amp;gt;just work&amp;lt;/i&amp;gt; with our examples, but if problems arise this section gives more detail on pinpointing the source of the problem.  We recommend starting with running the software examples right away - if the software works, you know the hardware works too.&lt;br /&gt;
&lt;br /&gt;
====Software====&lt;br /&gt;
&lt;br /&gt;
The easiest way to see whether your libraries are set up correctly within our examples or your own project is just to download them to the iOS device and run them.  Detailed instructions for this (including choosing the right {{Code|HelloWorld}} project to run) are on the [[Language - iOS]] page.  That page will be your next step - but if the examples do not run using the instructions, return here to debug your hardware.&lt;br /&gt;
&lt;br /&gt;
====Hardware====&lt;br /&gt;
&lt;br /&gt;
If you are having problems running the examples, you should check the hardware of the host computer.&lt;br /&gt;
&lt;br /&gt;
When using the [[#WebService|WebService]] to control a Phidget, the problem may be with the USB connection on the remote computer.  Make sure both the server-side of (a) the webservice and (b) the USB connection are working by using the instructions on the [[OS - OS X|OS X page]]&lt;br /&gt;
&lt;br /&gt;
====Troubleshooting====&lt;br /&gt;
&lt;br /&gt;
If the examples &#039;&#039;&#039;do not&#039;&#039;&#039; work but USB &#039;&#039;&#039;does&#039;&#039;&#039; work (i.e. your remote computer or iOS device can consistently see the device in the [[#Hardware|hardware]]), take a moment to check the basics:&lt;br /&gt;
* No other programs, drivers, or processes are using the Phidget on the host computer.&lt;br /&gt;
* You have copied and linked the Phidget iOS libraries (as described on the [[Language - iOS]] page)&lt;br /&gt;
* The Phidget libraries are the latest version (visit the [[#Getting Started (Libraries and Drivers)| getting started section]] to download them)&lt;br /&gt;
* Ensure that the webservice drivers and the iOS libraries are both the latest version&lt;br /&gt;
* Ensure that you have the most up to date iOS version installed for your device.&lt;br /&gt;
* Check the [[#Common Problems and Solutions|common problems]] section below, some specific combinations can cause problems&lt;br /&gt;
&lt;br /&gt;
If your problem doesn&#039;t seem to be fixed by these steps, make sure that the Phidget is seen &#039;&#039;&#039;consistently&#039;&#039;&#039; by USB in [[#Hardware|hardware]] (if it is erratic, try our [[General Troubleshooting|general troubleshooting guide]]).  If you are still having problems after using the troubleshooting guide, please [[Contact Information|ask us]]!&lt;br /&gt;
&lt;br /&gt;
==Programming Languages==&lt;br /&gt;
&lt;br /&gt;
iOS programs are written in [[Language - iOS|Objective C]] using the Cocoa Touch framework. You can read on within this page to learn how to use iOS with the Webservice, or you can jump ahead right now to the [[Language - iOS|iOS]] page and start writing code!&lt;br /&gt;
&lt;br /&gt;
==WebService==&lt;br /&gt;
&lt;br /&gt;
The Phidget WebService allows you to remotely control a Phidget over a network.&amp;lt;br&amp;gt;This section helps you use the WebService on iOS, but we also have an overview of the [[Phidget WebService]] in general.&lt;br /&gt;
&lt;br /&gt;
Currently, iOS devices cannot &#039;&#039;host&#039;&#039; the WebService, but they can use data streaming from another computer over the WebService.&lt;br /&gt;
&lt;br /&gt;
===Setting Up the WebService===&lt;br /&gt;
&lt;br /&gt;
Using an iOS device, your network-controlled Phidget system will probably look something like this:&lt;br /&gt;
&lt;br /&gt;
[[Image:webservice_general_pctoios.png|600px|link=|alt=]]&lt;br /&gt;
&lt;br /&gt;
To begin, &lt;br /&gt;
&lt;br /&gt;
1. Start the WebService on the host computer&lt;br /&gt;
* How to do this [[OS - Windows#WebService|on Windows]]&lt;br /&gt;
* How to do this [[OS - OS X#WebService|on Mac OS]]&lt;br /&gt;
* How to do this [[OS - Linux#WebService|on Linux]]&lt;br /&gt;
* How to do this [[OS - Phidget SBC#WebService|on the Phidget Single Board Computer]]&lt;br /&gt;
&lt;br /&gt;
2. Download and unzip the [http://www.phidgets.com/downloads/libraries/Phidget-iPhone_2.1.8.20120216.zip iOS Examples] anywhere on the development computer.&lt;br /&gt;
&lt;br /&gt;
3. Open up the {{Code|HelloWorld.xcodeproj}} into Xcode. Select either an iOS device or iOS simulator as the destination. For more information, please see the [[Language - iOS#Use OurExamples|Use Our Examples]] section of the iOS language page.&lt;br /&gt;
&lt;br /&gt;
4. In Xcode, hit the {{Code|Run}} button to transfer the application to the device or simulator as well as run it.&lt;br /&gt;
&lt;br /&gt;
===Using the WebService===&lt;br /&gt;
&lt;br /&gt;
After performing the steps above, you will be using the WebService already.  Plugging in the Phidget to the host computer will give you a screen like this:&lt;br /&gt;
&lt;br /&gt;
[[File:iOS Webservice Example HelloWorld Output.png|link=|alt=HelloWorld Output]]&lt;br /&gt;
&lt;br /&gt;
The above screenshot shows that a number of Phidgets are attached to the USB ports of computer connected to the network. Go ahead and detach the Phidgets from the USB port of the host computer, and see what happens.&lt;br /&gt;
&lt;br /&gt;
===Debugging the WebService===&lt;br /&gt;
&lt;br /&gt;
Since an iOS device can only be a user and not a host of the WebService, you should use debugging server side.  Refer to the webservice sections for each operating system:&lt;br /&gt;
* [[OS - Windows#WebService|Windows]]&lt;br /&gt;
* [[OS - OS X#WebService|Mac OS]]&lt;br /&gt;
* [[OS - Linux#WebService|Linux]]&lt;br /&gt;
* [[OS - Phidget SBC#WebService|Phidget Single Board Computer]]&lt;br /&gt;
In addition, if you are having WebService problems, you will probably find the webservice section of our [[General Troubleshooting#WebService Troubleshooting|General Troubleshooting Guide]] helpful as well.&lt;br /&gt;
&lt;br /&gt;
==Advanced Uses==&lt;br /&gt;
&lt;br /&gt;
==Common Problems and Solutions==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Appendix==&lt;br /&gt;
&lt;br /&gt;
===Description of Installer files===&lt;br /&gt;
&lt;br /&gt;
Here is the list of files and their description for each file that is distributed through the iOS drivers.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|iphoneos/libPhidget21.a}}&amp;lt;/b&amp;gt; contains the actual Phidget library, which is used at run-time.  This library is used when you are testing the example on the actual iOS device.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|iphonesimulator/libPhidget21.a}}&amp;lt;/b&amp;gt; contains the actual Phidget library, which is used at run-time.  This library is used when you are testing the example an iOS simulator.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|phidget21.h}}&amp;lt;/b&amp;gt; lists all the Phidget API function calls available to your code.  Your compiler also has to know where this file is.  &lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|SkeletonProject}}&amp;lt;/b&amp;gt; is a Xcode project containing the bare minimum project settings already filled in to code with the Phidget library.&lt;/div&gt;</summary>
		<author><name>Djrudiak</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=OS_-_OS_X&amp;diff=19193</id>
		<title>OS - OS X</title>
		<link rel="alternate" type="text/html" href="https://www.phidgets.com/docs21/index.php?title=OS_-_OS_X&amp;diff=19193"/>
		<updated>2012-04-20T20:08:36Z</updated>

		<summary type="html">&lt;p&gt;Djrudiak: /* WebService */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:OS]]&lt;br /&gt;
&lt;br /&gt;
{{OSLang|[[File:Icon-Mac-OS.png‎|64x64px|link=]]|On OS X, Phidgets can be either plugged directly into a USB Port or run over a network using the [[#WebService|WebService]].}}&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
Phidgets are designed to run on &#039;&#039;&#039;OS X 10.4 Tiger or newer&#039;&#039;&#039;, and can run on PPC, 32-bit, and 64-bit systems.&lt;br /&gt;
&lt;br /&gt;
==Getting Started (Libraries and Drivers)==&lt;br /&gt;
&lt;br /&gt;
If this is your first Phidget, we highly recommend working through the Getting Started guide [[Device List|for your specific Phidget device]].  If you already have the Preference Pane Installed and know how to use it, then you&#039;ve already followed the guide and are ready to learn more about the workings behind the Preference Pane, the Phidget WebService, and more - all specific to OS X.&lt;br /&gt;
&lt;br /&gt;
If you are already a pro, and just want the drivers:&lt;br /&gt;
&lt;br /&gt;
*[http://www.phidgets.com/downloads/libraries/Phidget_2.1.8.20120216.dmg OS X Installer]&lt;br /&gt;
*[http://www.phidgets.com/Drivers_Info.html#osx Software License]&lt;br /&gt;
&lt;br /&gt;
===Installing===&lt;br /&gt;
&lt;br /&gt;
The Phidget installer will install the core Phidget files onto your system.&lt;br /&gt;
&lt;br /&gt;
To install the libraries, follow these steps:&lt;br /&gt;
&lt;br /&gt;
1. Download the Phidget installer for your system:&lt;br /&gt;
*[http://www.phidgets.com/downloads/libraries/Phidget_2.1.8.20120216.dmg OS X Installer]&lt;br /&gt;
&lt;br /&gt;
2. Open up the installer, and double click on {{Code|Phidgets.mpkg}} to install the libraries.&lt;br /&gt;
&lt;br /&gt;
[[File:OSX Install 1.png|link=|alt=OS X Install]]&lt;br /&gt;
&lt;br /&gt;
3. Proceed through the wizard. &lt;br /&gt;
&lt;br /&gt;
[[File:OSX Install 2.png|link=|alt=OS X Install]]&lt;br /&gt;
&lt;br /&gt;
4. Once the installation is complete, you are ready to program with Phidgets. To find out what files got installed, please see [[#Description of Installer files | Description of Installer files]] in the Appendix section.&lt;br /&gt;
&lt;br /&gt;
Proceed onto to the [[#Phidget Preference Pane | next]] section where the Phidget Preference Pane will be discussed.&lt;br /&gt;
&lt;br /&gt;
====Phidget Preference Pane====&lt;br /&gt;
&lt;br /&gt;
The Phidget Preference Pane is a tool to quickly determine whether your system is able to communicate with Phidgets, and also act as a debugging tool. &lt;br /&gt;
&lt;br /&gt;
Once the Phidget libraries are installed using the installer, open up the {{Code|System Preferences}} window.&lt;br /&gt;
&lt;br /&gt;
[[File:OSX System Preferences.png|link=|alt=OS X System Preferences]]&lt;br /&gt;
&lt;br /&gt;
Click on the {{Code|Phidgets}} icon in the {{Code|Other}} section to bring up the Phidgets Preference Pane.&lt;br /&gt;
&lt;br /&gt;
[[File:OSX PreferencePane General.png|link=|alt=OS X PreferencePane General]]&lt;br /&gt;
&lt;br /&gt;
The {{Code|general}} tab shows the list of Phidgets currently physically attached to the computer. You can also view the currently installed Phidget library version. You can double click on a Phidget device to open up an example program for the device.&lt;br /&gt;
&lt;br /&gt;
[[File:OSX PreferencePane Example.png|link=|alt=OS X PreferencePane Example]]&lt;br /&gt;
&lt;br /&gt;
In the above screenshot, the RFID example was opened. These examples are intended for demonstration and debugging purposes. If you have not yet already, please see the &#039;&#039;&#039;Getting Started&#039;&#039;&#039; guide [[Device List|for your device]]. It is important to keep in mind that when an example Phidget application is opened from the Phidget Preference Pane or opened from any of your Phidget applications that you develop, it holds a lock on the Phidget. This prevents any other program from accessing the Phidget. Please ensure that this example application is closed(the Phidget Preference Pane can still be running) when you are running your own applications. &lt;br /&gt;
&lt;br /&gt;
The next tab is the {{Code|Web Service}} tab, which allows you to control Phidgets over a network. &lt;br /&gt;
&lt;br /&gt;
[[File:OSX PreferencePane Webservice Stopped.png|link=|alt=OS X PreferencePane WebService Stopped]]&lt;br /&gt;
&lt;br /&gt;
Here, you can start and stop the WebService. Details are provided in the [[#WebService | WebService]] section. This screen also tells you whether the Phidget WebService is currently running. &lt;br /&gt;
&lt;br /&gt;
The next tab is the {{Code|Labels}} tab. In this section, you can view the currently assigned labels of any Phidget attached to your computer. It is also possible to set the labels of Phidgets here too. You might want to set a label to a Phidget device because you can refer to it by its label as opposed to its serial number. &lt;br /&gt;
&lt;br /&gt;
[[File:OSX PreferencePane Labels Local.png|link=|alt=OS X PreferencePane WebService Labels Local]]&lt;br /&gt;
&lt;br /&gt;
You can also view the labels of any Phidget connected through the WebService&lt;br /&gt;
&lt;br /&gt;
[[File:OSX PreferencePane Labels Remote.png|link=|alt=OS X PreferencePane WebService Labels Remote]]&lt;br /&gt;
&lt;br /&gt;
The {{Code|Bonjour}} tab gives a list of all currently attached Phidgets that are connected to the WebService. You can also double click on the Phidget to connect to it over the network using one or more computers, but still use the Phidget on the computer it is directly connected to.&lt;br /&gt;
&lt;br /&gt;
[[File:OSX PreferencePane Bonjour.png|link=|alt=OS X PreferencePane Bonjour]]&lt;br /&gt;
&lt;br /&gt;
The last tab is the {{Code|PhidgetSBC}} tab, which displays the complete list of PhidgetSBCs connected to the network. &lt;br /&gt;
&lt;br /&gt;
[[File:OSX PreferencePane PhidgetSBC.png|link=|alt=OS X PreferencePane PhidgetSBC]]&lt;br /&gt;
&lt;br /&gt;
You can double click on the PhidgetSBC to bring up the PhidgetSBC Administration Console log-in page in your default browser.&lt;br /&gt;
&lt;br /&gt;
[[File:PhidgetSBCAdminConsole.PNG|link=|alt=PhidgetSBC Admin Console]]&lt;br /&gt;
&lt;br /&gt;
The PhidgetSBC Administration Console is where you can go to configure the PhidgetSBC. For more details, please see the [[1072 0 - Getting Started | PhidgetSBC]] section.&lt;br /&gt;
&lt;br /&gt;
===Checking===&lt;br /&gt;
&lt;br /&gt;
To confirm the libraries were installed and work correctly, you can check both the hardware and software components of the interface. It is worth checking the software side first, because if it works then you know the hardware side is also okay.&lt;br /&gt;
&lt;br /&gt;
====Software====&lt;br /&gt;
&lt;br /&gt;
If you have the Phidgets library installed on your system, you can verify that the software component is working by seeing if the Phidget device is listed in the General tab of the Phidget Preference Pane.&lt;br /&gt;
&lt;br /&gt;
[[File:OSX PreferencePane General.png ‎|link=|alt=OS X Preference Pane General]]&lt;br /&gt;
&lt;br /&gt;
The above screenshot shows that a PhidgetRFID and a PhidgetInterfaceKit are attached to the computer. If you see your Phidget in the list, you can continue to the [[#Programming Languages | programming languages]] section to learn more. If you are not able to see that the Phidget is in the list, there may be a hardware issue. Please see the [[#Hardware| hardware]] section for more details.&lt;br /&gt;
&lt;br /&gt;
====Hardware====&lt;br /&gt;
&lt;br /&gt;
You can verify that your computer detects that the Phidget is plugged in through a USB connection by going to the OS X System Profiler. You can access the System Profiler by selecting {{Code|About This Mac}} under the Apple icon. &lt;br /&gt;
&lt;br /&gt;
[[File:OSX About This Mac.png‎|link=|alt=OS X About This Mac]]&lt;br /&gt;
&lt;br /&gt;
The new window will open up.&lt;br /&gt;
&lt;br /&gt;
[[File:OSX More Info.png|link=|alt=OS X More Info]]&lt;br /&gt;
&lt;br /&gt;
Select {{Code|More Info}}. The System Profiler will show up. In the USB section, you will be able to find all connected USB devices. &lt;br /&gt;
&lt;br /&gt;
[[File:OSX USB Devices.png ‎|link=|alt=OS X Attached USB Devices]]&lt;br /&gt;
&lt;br /&gt;
In the above screenshot, The PhidgetInterfaceKit and PhidgetRFID are connected to the USB ports. &lt;br /&gt;
&lt;br /&gt;
If you don&#039;t see the Phidget in the list, then take a look at the [[#Troubleshooting|troubleshooting]] section below, as well as the &#039;&#039;&#039;Communications&#039;&#039;&#039; section of our [[General Troubleshooting#Communications Troubleshooting|general troubleshooting page]].&lt;br /&gt;
&lt;br /&gt;
====Troubleshooting====&lt;br /&gt;
&lt;br /&gt;
If the example programs &#039;&#039;&#039;do not&#039;&#039;&#039; work but USB &#039;&#039;&#039;does&#039;&#039;&#039; work (i.e. your computer can consistently see the device in the [[#Hardware|hardware]]), take a moment to check the basics:&lt;br /&gt;
* You are using OS X 10.4 or newer. &lt;br /&gt;
* No other programs, drivers, or processes are using that USB port in software&lt;br /&gt;
* The Phidget libraries are the latest version (visit the [[#Getting Started (Libraries and Drivers)| getting started section]] to download them)&lt;br /&gt;
&lt;br /&gt;
* Check the [[#Common Problems and Solutions|common problems]] section below, some specific combinations can cause problems&lt;br /&gt;
&lt;br /&gt;
If your problem doesn&#039;t seem to be fixed by these steps, make sure that the Phidget is seen &#039;&#039;&#039;consistently&#039;&#039;&#039; by USB (if it is erratic, try our [[General Troubleshooting|general troubleshooting guide]]).  If you are still having problems after using the troubleshooting guide, please [[Contact Information|ask us]]!&lt;br /&gt;
&lt;br /&gt;
==Programming Languages==&lt;br /&gt;
Phidgets’ philosophy is that you do not have to be an electrical engineer in order to do projects that use devices like sensors, motors, motor controllers, and interface boards. All you need to know is how to program.&lt;br /&gt;
&lt;br /&gt;
After you have installed the drivers above, you should pick a programming language, install libraries, and run the examples for that specific language. You can learn more about what is needed to program in a particular language by choosing the language of your preference below. If you need help choosing a language, please look at the [[Software Overview#Language Support |language comparison table]]. &lt;br /&gt;
&lt;br /&gt;
We recommend the following languages for OS X:&lt;br /&gt;
* [[Language - Applescript|AppleScript]]&lt;br /&gt;
* [[Language - C/C++|C/C++]]&lt;br /&gt;
* [[Language - C#|C#(Using Mono)]]&lt;br /&gt;
* [[Language - Cocoa | Cocoa]]&lt;br /&gt;
* [[Language - Flash AS3 | Flash AS3]]&lt;br /&gt;
* [[Language - Flex AS3 | Flex AS3]]&lt;br /&gt;
* [[Language - LiveCode | LiveCode]]&lt;br /&gt;
* [[Language - Java | Java]]&lt;br /&gt;
* [[Language - Max/MSP|Max/MSP]]&lt;br /&gt;
* [[Language - Python | Python]]&lt;br /&gt;
* [[Language - Ruby|Ruby]]&lt;br /&gt;
&lt;br /&gt;
You can also use these languages, but they do not support [[General Phidget Programming#Event Driven Code | event driven code]], and must use [[General Phidget Programming#Logic Code | logic code]] only:&lt;br /&gt;
&lt;br /&gt;
*[[Language - MATLAB|MATLAB]]&lt;br /&gt;
*[[Language - Simulink|Simulink]]&lt;br /&gt;
&lt;br /&gt;
==WebService==&lt;br /&gt;
&lt;br /&gt;
The Phidget WebService allows you to remotely control a Phidget over a network.&lt;br /&gt;
&lt;br /&gt;
Drivers for the Phidget WebService on OS X are already included in the [[#Getting Started (Libraries and Drivers) | Drivers]] above. If you see the Phidget Preference Pane in System Preferences, then you already have the WebService drivers installed.&lt;br /&gt;
&lt;br /&gt;
There are two ways that you can connect to a Phidget hosted on another computer. The first method is by using the IP address/host name and port of the host computer. The second method makes the use of [http://en.wikipedia.org/wiki/Multicast_DNS mDNS], which allows Phidgets to be found and opened on the network by a server id instead of an IP address/host name. When using a server id, both the client and server will need to be running an implementation of zero configuration networking. The Phidget WebService takes advantage of [http://www.apple.com/support/downloads/bonjourforwindows.html Bonjour] software, which is built-in to OS X. It is a tool developed by Apple to locate devices, such as Phidgets,  on a network.&lt;br /&gt;
&lt;br /&gt;
This section helps you install, check, and use the WebService on Windows, but we also have an overview of the [[Phidget WebService]] in general.&lt;br /&gt;
&lt;br /&gt;
===Turning the WebService On and Off===&lt;br /&gt;
&lt;br /&gt;
There are two methods that can be used to turn the WebService on and off. The first method is through the Phidget Preference Pane. In the {{Code|WebService}} tab, you can start or stop the WebService. You can also choose to have the WebService start up automatically upon system boot up by selecting the {{Code|Start Automatically}} checkbox. &lt;br /&gt;
&lt;br /&gt;
[[File:OSX PreferencePane Webservice Stopped.png|link=|alt=OS X PreferencePane WebService]]&lt;br /&gt;
&lt;br /&gt;
The second method of turning the WebService on and off is through command line. After using our installer, the WebService utility is automatically installed in {{Code|/usr/bin/phidget21webservice}}. &lt;br /&gt;
&lt;br /&gt;
You can get command line help with {{Code|phidgetwebservice21}} using the -h option:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=bash&amp;gt;&lt;br /&gt;
 phidgetwebservice21 -h&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=text&amp;gt;&lt;br /&gt;
&#039;phidgetwebservice21&#039; is a Phidget and Dictionary server from Phidgets Inc. See www.phidgets.com for more information.&lt;br /&gt;
Usage: phidgetwebservice21 [OPTION]&lt;br /&gt;
All parameters are optional. The default parameters are: port=5001, ServerName=(Computer Name) and no password&lt;br /&gt;
&lt;br /&gt;
Options:&lt;br /&gt;
  -p      Port&lt;br /&gt;
  -n      Server Name&lt;br /&gt;
  -P      Password&lt;br /&gt;
  -v      Debug mode&lt;br /&gt;
  -h      Display this help&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Mapping out which command line options to which Phidget Preference Pane option is as follows:&lt;br /&gt;
&lt;br /&gt;
-p: {{Code|Port}} field&lt;br /&gt;
&lt;br /&gt;
-n: {{Code|ServerID}} field&lt;br /&gt;
&lt;br /&gt;
-P: {{Code|Password}} field&lt;br /&gt;
&lt;br /&gt;
-v: Not supported under the Phidget Preference Pane&lt;br /&gt;
&lt;br /&gt;
To find the defaults used by {{Code|phidget21webservice}}, the command line is the fastest way to learn the default server name and IP address of your computer:&lt;br /&gt;
*For the default server name, use {{Code|hostname}} on the command line.&lt;br /&gt;
*For your IP address, use {{Code|ifconfig -a}} on the command line.&lt;br /&gt;
**A line in the return text, under your main internet connection (usually {{Code|eth0}}) will say something like {{Code|inet addr:192.168.3.178}}, which is your IP.&lt;br /&gt;
&lt;br /&gt;
Here are some usage examples:&lt;br /&gt;
&lt;br /&gt;
To start the WebService with default parameters:&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=bash&amp;gt;&lt;br /&gt;
 phidgetwebservice21&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To start the WebService with a server name of {{Code|myServer}}:&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=bash&amp;gt;&lt;br /&gt;
 phidgetwebservice21-n myServer&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To stop the WebService, simply close the command line window or press {{Code|Control}} and {{Code|c}} at the same time in the command line window.&lt;br /&gt;
&lt;br /&gt;
===Using the WebService===&lt;br /&gt;
&lt;br /&gt;
To use a Phidget over the WebService, you&#039;ll want to:&lt;br /&gt;
* Have two different computers connected to the same network. We will call the computer that has the Phidget directly connected to the USB port the host. The client will be the computer that runs a Phidget application to connect to the Phidget attached to the host. Please note that if you only have a single computer, you can also connect to the Phidget over the WebService. The computer will simply act as both a host and client. This will allow you to bypass the [[General Phidget Programming # Details for Open() | one application per Phidget limitation]]. &lt;br /&gt;
&lt;br /&gt;
* Start the WebService on the computer that directly connects to the Phidget&lt;br /&gt;
* Run your program on the remote computer that will control the Phidget over the network&lt;br /&gt;
&lt;br /&gt;
The easiest way to test these steps on OS X is to set up the WebService and run the Phidget program on the client. Please follow these steps:&lt;br /&gt;
&lt;br /&gt;
1. On the host, open up the Phidget Preference Pane and traverse to the {{Code|Web Service}} tab.&lt;br /&gt;
&lt;br /&gt;
[[File:OSX PreferencePane Webservice Stopped.png |link=|alt=OS X Preference Pane WebService]]&lt;br /&gt;
&lt;br /&gt;
2. Leave all fields the way they are, and click on {{Code|Start WebService}} to run the WebService.&lt;br /&gt;
&lt;br /&gt;
3. You can determine that the WebService is running by looking at the status on the right side.&lt;br /&gt;
&lt;br /&gt;
[[File:OSX PreferencePane Webservice Running.png|link=|alt=OS X PreferencePane WebService Running]]&lt;br /&gt;
&lt;br /&gt;
4. Ensure that the Phidget is plugged in to the host. &lt;br /&gt;
&lt;br /&gt;
5. On the client&#039;s Phidget Preference Pane, open up the {{Code|Bonjour}} tab. You will see the Phidget that is plugged into the host as one of the entries listed. Double click it to open the example application.&lt;br /&gt;
&lt;br /&gt;
[[File:OSX PreferencePane Bonjour.png ‎‎ |link=|alt=OS X PreferencePane Bonjour.png ‎]]&lt;br /&gt;
&lt;br /&gt;
6. The example application will open up, and you will be able to communicate with the Phidget over the WebService.&lt;br /&gt;
&lt;br /&gt;
[[File:OSX PreferencePane Example.png ‎ |link=|alt=OS X PreferencePane Example]]&lt;br /&gt;
&lt;br /&gt;
7. You can confirm that the WebService was indeed behind this exchange by terminating the WebService process while still allowing the remote program to run. On the host&#039;s Phidget Preference Pane, traverse to the {{Code|WebService}} tab. Hit {{Code|Stop WebService}} to terminate the WebService. &lt;br /&gt;
&lt;br /&gt;
[[File:OSX PreferencePane Webservice Running.png|link=|alt=OS X PreferencePane WebService Running]]&lt;br /&gt;
&lt;br /&gt;
8. Take a look at the example application on the client. Since the application can no longer connect to the WebService, there is nothing attached. &lt;br /&gt;
&lt;br /&gt;
[[File:OSX PreferencePane Example Stopped.png |link=|alt=OS X PreferencePane Example Stopped]]&lt;br /&gt;
&lt;br /&gt;
===Debugging the WebService===&lt;br /&gt;
&lt;br /&gt;
In addition to enabling [[General Phidget Programming#Logging|logging]] in your Phidget code, you can get additional debugging information from the WebService itself.  This additional debugging can only be enabled from the command line approach to start the WebService. Debug information is enabled by specifying the {{Code|-v}} option:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=bash&amp;gt;&lt;br /&gt;
 phidgetwebservice21 -v -n &amp;quot;myServer&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The debugging information will be shown as output in the command line console.&lt;br /&gt;
&lt;br /&gt;
==Advanced Uses==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Appendix==&lt;br /&gt;
&lt;br /&gt;
===Description of Installer files===&lt;br /&gt;
&lt;br /&gt;
Here is the list of files and their description for each file the installer puts onto your system. &lt;br /&gt;
===Description of Library files===&lt;br /&gt;
&lt;br /&gt;
This section will explain the files that were placed onto your system as part of the installation process.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|Phidget21.framework}}&amp;lt;/b&amp;gt; contains the actual Phidget library, which is used at run-time.  It is placed into {{Code|/Library/Frameworks}}.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|Phidget.kext}}&amp;lt;/b&amp;gt; is the kernel extension.  It is placed into {{Code|/System/Library/Extensions}}.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|libphidget21.jnilib}}&amp;lt;/b&amp;gt; is the JNI library for Java.  It is placed into {{Code|/Library/Java/Extensions}}.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|Phidgets.prefpane}}&amp;lt;/b&amp;gt; is the Phidgets Preference Pane.  It is placed into {{Code|/Library/PreferencePanes}}.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|phidgetwebservice21}}&amp;lt;/b&amp;gt; is the Phidget WebService.  It is placed into {{Code|/usr/bin}}.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|PhidgetsOSA.app}}&amp;lt;/b&amp;gt; is the the Phidgets agent for AppleScript.  It is placed into {{Code|/Library/ScriptingAdditions}}.&lt;br /&gt;
&lt;br /&gt;
==Common Problems and Solutions==&lt;br /&gt;
&lt;br /&gt;
None, yet.&lt;/div&gt;</summary>
		<author><name>Djrudiak</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=OS_-_OS_X&amp;diff=19192</id>
		<title>OS - OS X</title>
		<link rel="alternate" type="text/html" href="https://www.phidgets.com/docs21/index.php?title=OS_-_OS_X&amp;diff=19192"/>
		<updated>2012-04-20T20:08:07Z</updated>

		<summary type="html">&lt;p&gt;Djrudiak: /* WebService */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:OS]]&lt;br /&gt;
&lt;br /&gt;
{{OSLang|[[File:Icon-Mac-OS.png‎|64x64px|link=]]|On OS X, Phidgets can be either plugged directly into a USB Port or run over a network using the [[#WebService|WebService]].}}&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
Phidgets are designed to run on &#039;&#039;&#039;OS X 10.4 Tiger or newer&#039;&#039;&#039;, and can run on PPC, 32-bit, and 64-bit systems.&lt;br /&gt;
&lt;br /&gt;
==Getting Started (Libraries and Drivers)==&lt;br /&gt;
&lt;br /&gt;
If this is your first Phidget, we highly recommend working through the Getting Started guide [[Device List|for your specific Phidget device]].  If you already have the Preference Pane Installed and know how to use it, then you&#039;ve already followed the guide and are ready to learn more about the workings behind the Preference Pane, the Phidget WebService, and more - all specific to OS X.&lt;br /&gt;
&lt;br /&gt;
If you are already a pro, and just want the drivers:&lt;br /&gt;
&lt;br /&gt;
*[http://www.phidgets.com/downloads/libraries/Phidget_2.1.8.20120216.dmg OS X Installer]&lt;br /&gt;
*[http://www.phidgets.com/Drivers_Info.html#osx Software License]&lt;br /&gt;
&lt;br /&gt;
===Installing===&lt;br /&gt;
&lt;br /&gt;
The Phidget installer will install the core Phidget files onto your system.&lt;br /&gt;
&lt;br /&gt;
To install the libraries, follow these steps:&lt;br /&gt;
&lt;br /&gt;
1. Download the Phidget installer for your system:&lt;br /&gt;
*[http://www.phidgets.com/downloads/libraries/Phidget_2.1.8.20120216.dmg OS X Installer]&lt;br /&gt;
&lt;br /&gt;
2. Open up the installer, and double click on {{Code|Phidgets.mpkg}} to install the libraries.&lt;br /&gt;
&lt;br /&gt;
[[File:OSX Install 1.png|link=|alt=OS X Install]]&lt;br /&gt;
&lt;br /&gt;
3. Proceed through the wizard. &lt;br /&gt;
&lt;br /&gt;
[[File:OSX Install 2.png|link=|alt=OS X Install]]&lt;br /&gt;
&lt;br /&gt;
4. Once the installation is complete, you are ready to program with Phidgets. To find out what files got installed, please see [[#Description of Installer files | Description of Installer files]] in the Appendix section.&lt;br /&gt;
&lt;br /&gt;
Proceed onto to the [[#Phidget Preference Pane | next]] section where the Phidget Preference Pane will be discussed.&lt;br /&gt;
&lt;br /&gt;
====Phidget Preference Pane====&lt;br /&gt;
&lt;br /&gt;
The Phidget Preference Pane is a tool to quickly determine whether your system is able to communicate with Phidgets, and also act as a debugging tool. &lt;br /&gt;
&lt;br /&gt;
Once the Phidget libraries are installed using the installer, open up the {{Code|System Preferences}} window.&lt;br /&gt;
&lt;br /&gt;
[[File:OSX System Preferences.png|link=|alt=OS X System Preferences]]&lt;br /&gt;
&lt;br /&gt;
Click on the {{Code|Phidgets}} icon in the {{Code|Other}} section to bring up the Phidgets Preference Pane.&lt;br /&gt;
&lt;br /&gt;
[[File:OSX PreferencePane General.png|link=|alt=OS X PreferencePane General]]&lt;br /&gt;
&lt;br /&gt;
The {{Code|general}} tab shows the list of Phidgets currently physically attached to the computer. You can also view the currently installed Phidget library version. You can double click on a Phidget device to open up an example program for the device.&lt;br /&gt;
&lt;br /&gt;
[[File:OSX PreferencePane Example.png|link=|alt=OS X PreferencePane Example]]&lt;br /&gt;
&lt;br /&gt;
In the above screenshot, the RFID example was opened. These examples are intended for demonstration and debugging purposes. If you have not yet already, please see the &#039;&#039;&#039;Getting Started&#039;&#039;&#039; guide [[Device List|for your device]]. It is important to keep in mind that when an example Phidget application is opened from the Phidget Preference Pane or opened from any of your Phidget applications that you develop, it holds a lock on the Phidget. This prevents any other program from accessing the Phidget. Please ensure that this example application is closed(the Phidget Preference Pane can still be running) when you are running your own applications. &lt;br /&gt;
&lt;br /&gt;
The next tab is the {{Code|Web Service}} tab, which allows you to control Phidgets over a network. &lt;br /&gt;
&lt;br /&gt;
[[File:OSX PreferencePane Webservice Stopped.png|link=|alt=OS X PreferencePane WebService Stopped]]&lt;br /&gt;
&lt;br /&gt;
Here, you can start and stop the WebService. Details are provided in the [[#WebService | WebService]] section. This screen also tells you whether the Phidget WebService is currently running. &lt;br /&gt;
&lt;br /&gt;
The next tab is the {{Code|Labels}} tab. In this section, you can view the currently assigned labels of any Phidget attached to your computer. It is also possible to set the labels of Phidgets here too. You might want to set a label to a Phidget device because you can refer to it by its label as opposed to its serial number. &lt;br /&gt;
&lt;br /&gt;
[[File:OSX PreferencePane Labels Local.png|link=|alt=OS X PreferencePane WebService Labels Local]]&lt;br /&gt;
&lt;br /&gt;
You can also view the labels of any Phidget connected through the WebService&lt;br /&gt;
&lt;br /&gt;
[[File:OSX PreferencePane Labels Remote.png|link=|alt=OS X PreferencePane WebService Labels Remote]]&lt;br /&gt;
&lt;br /&gt;
The {{Code|Bonjour}} tab gives a list of all currently attached Phidgets that are connected to the WebService. You can also double click on the Phidget to connect to it over the network using one or more computers, but still use the Phidget on the computer it is directly connected to.&lt;br /&gt;
&lt;br /&gt;
[[File:OSX PreferencePane Bonjour.png|link=|alt=OS X PreferencePane Bonjour]]&lt;br /&gt;
&lt;br /&gt;
The last tab is the {{Code|PhidgetSBC}} tab, which displays the complete list of PhidgetSBCs connected to the network. &lt;br /&gt;
&lt;br /&gt;
[[File:OSX PreferencePane PhidgetSBC.png|link=|alt=OS X PreferencePane PhidgetSBC]]&lt;br /&gt;
&lt;br /&gt;
You can double click on the PhidgetSBC to bring up the PhidgetSBC Administration Console log-in page in your default browser.&lt;br /&gt;
&lt;br /&gt;
[[File:PhidgetSBCAdminConsole.PNG|link=|alt=PhidgetSBC Admin Console]]&lt;br /&gt;
&lt;br /&gt;
The PhidgetSBC Administration Console is where you can go to configure the PhidgetSBC. For more details, please see the [[1072 0 - Getting Started | PhidgetSBC]] section.&lt;br /&gt;
&lt;br /&gt;
===Checking===&lt;br /&gt;
&lt;br /&gt;
To confirm the libraries were installed and work correctly, you can check both the hardware and software components of the interface. It is worth checking the software side first, because if it works then you know the hardware side is also okay.&lt;br /&gt;
&lt;br /&gt;
====Software====&lt;br /&gt;
&lt;br /&gt;
If you have the Phidgets library installed on your system, you can verify that the software component is working by seeing if the Phidget device is listed in the General tab of the Phidget Preference Pane.&lt;br /&gt;
&lt;br /&gt;
[[File:OSX PreferencePane General.png ‎|link=|alt=OS X Preference Pane General]]&lt;br /&gt;
&lt;br /&gt;
The above screenshot shows that a PhidgetRFID and a PhidgetInterfaceKit are attached to the computer. If you see your Phidget in the list, you can continue to the [[#Programming Languages | programming languages]] section to learn more. If you are not able to see that the Phidget is in the list, there may be a hardware issue. Please see the [[#Hardware| hardware]] section for more details.&lt;br /&gt;
&lt;br /&gt;
====Hardware====&lt;br /&gt;
&lt;br /&gt;
You can verify that your computer detects that the Phidget is plugged in through a USB connection by going to the OS X System Profiler. You can access the System Profiler by selecting {{Code|About This Mac}} under the Apple icon. &lt;br /&gt;
&lt;br /&gt;
[[File:OSX About This Mac.png‎|link=|alt=OS X About This Mac]]&lt;br /&gt;
&lt;br /&gt;
The new window will open up.&lt;br /&gt;
&lt;br /&gt;
[[File:OSX More Info.png|link=|alt=OS X More Info]]&lt;br /&gt;
&lt;br /&gt;
Select {{Code|More Info}}. The System Profiler will show up. In the USB section, you will be able to find all connected USB devices. &lt;br /&gt;
&lt;br /&gt;
[[File:OSX USB Devices.png ‎|link=|alt=OS X Attached USB Devices]]&lt;br /&gt;
&lt;br /&gt;
In the above screenshot, The PhidgetInterfaceKit and PhidgetRFID are connected to the USB ports. &lt;br /&gt;
&lt;br /&gt;
If you don&#039;t see the Phidget in the list, then take a look at the [[#Troubleshooting|troubleshooting]] section below, as well as the &#039;&#039;&#039;Communications&#039;&#039;&#039; section of our [[General Troubleshooting#Communications Troubleshooting|general troubleshooting page]].&lt;br /&gt;
&lt;br /&gt;
====Troubleshooting====&lt;br /&gt;
&lt;br /&gt;
If the example programs &#039;&#039;&#039;do not&#039;&#039;&#039; work but USB &#039;&#039;&#039;does&#039;&#039;&#039; work (i.e. your computer can consistently see the device in the [[#Hardware|hardware]]), take a moment to check the basics:&lt;br /&gt;
* You are using OS X 10.4 or newer. &lt;br /&gt;
* No other programs, drivers, or processes are using that USB port in software&lt;br /&gt;
* The Phidget libraries are the latest version (visit the [[#Getting Started (Libraries and Drivers)| getting started section]] to download them)&lt;br /&gt;
&lt;br /&gt;
* Check the [[#Common Problems and Solutions|common problems]] section below, some specific combinations can cause problems&lt;br /&gt;
&lt;br /&gt;
If your problem doesn&#039;t seem to be fixed by these steps, make sure that the Phidget is seen &#039;&#039;&#039;consistently&#039;&#039;&#039; by USB (if it is erratic, try our [[General Troubleshooting|general troubleshooting guide]]).  If you are still having problems after using the troubleshooting guide, please [[Contact Information|ask us]]!&lt;br /&gt;
&lt;br /&gt;
==Programming Languages==&lt;br /&gt;
Phidgets’ philosophy is that you do not have to be an electrical engineer in order to do projects that use devices like sensors, motors, motor controllers, and interface boards. All you need to know is how to program.&lt;br /&gt;
&lt;br /&gt;
After you have installed the drivers above, you should pick a programming language, install libraries, and run the examples for that specific language. You can learn more about what is needed to program in a particular language by choosing the language of your preference below. If you need help choosing a language, please look at the [[Software Overview#Language Support |language comparison table]]. &lt;br /&gt;
&lt;br /&gt;
We recommend the following languages for OS X:&lt;br /&gt;
* [[Language - Applescript|AppleScript]]&lt;br /&gt;
* [[Language - C/C++|C/C++]]&lt;br /&gt;
* [[Language - C#|C#(Using Mono)]]&lt;br /&gt;
* [[Language - Cocoa | Cocoa]]&lt;br /&gt;
* [[Language - Flash AS3 | Flash AS3]]&lt;br /&gt;
* [[Language - Flex AS3 | Flex AS3]]&lt;br /&gt;
* [[Language - LiveCode | LiveCode]]&lt;br /&gt;
* [[Language - Java | Java]]&lt;br /&gt;
* [[Language - Max/MSP|Max/MSP]]&lt;br /&gt;
* [[Language - Python | Python]]&lt;br /&gt;
* [[Language - Ruby|Ruby]]&lt;br /&gt;
&lt;br /&gt;
You can also use these languages, but they do not support [[General Phidget Programming#Event Driven Code | event driven code]], and must use [[General Phidget Programming#Logic Code | logic code]] only:&lt;br /&gt;
&lt;br /&gt;
*[[Language - MATLAB|MATLAB]]&lt;br /&gt;
*[[Language - Simulink|Simulink]]&lt;br /&gt;
&lt;br /&gt;
==WebService==&lt;br /&gt;
&lt;br /&gt;
The Phidget WebService allows you to remotely control a Phidget over a network.&lt;br /&gt;
&lt;br /&gt;
Drivers for the Phidget WebService on OS X are already included in the [[#Getting Started (Libraries and Drivers) | Drivers]] above. If you see the Phidget Preference Pane in System Preferences, then you already have the WebService drivers installed.&lt;br /&gt;
&lt;br /&gt;
There are two ways that you can connect to a Phidget hosted on another computer. The first method is by using the IP address/host name and port of the host computer. The second method makes the use of [http://en.wikipedia.org/wiki/Multicast_DNS mDNS], which allows Phidgets to be found and opened on the network by a server id instead of an IP address/host name. When using a server id, both the client and server will need to be running an implementation of zero configuration networking. The Phidget WebService takes advantage of [http://www.apple.com/support/downloads/bonjourforwindows.html Bonjour] software, which is built-in to OS X. It is a tool, developed by Apple to locate devices, such as Phidgets,  on a network.&lt;br /&gt;
&lt;br /&gt;
This section helps you install, check, and use the WebService on Windows, but we also have an overview of the [[Phidget WebService]] in general.&lt;br /&gt;
&lt;br /&gt;
===Turning the WebService On and Off===&lt;br /&gt;
&lt;br /&gt;
There are two methods that can be used to turn the WebService on and off. The first method is through the Phidget Preference Pane. In the {{Code|WebService}} tab, you can start or stop the WebService. You can also choose to have the WebService start up automatically upon system boot up by selecting the {{Code|Start Automatically}} checkbox. &lt;br /&gt;
&lt;br /&gt;
[[File:OSX PreferencePane Webservice Stopped.png|link=|alt=OS X PreferencePane WebService]]&lt;br /&gt;
&lt;br /&gt;
The second method of turning the WebService on and off is through command line. After using our installer, the WebService utility is automatically installed in {{Code|/usr/bin/phidget21webservice}}. &lt;br /&gt;
&lt;br /&gt;
You can get command line help with {{Code|phidgetwebservice21}} using the -h option:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=bash&amp;gt;&lt;br /&gt;
 phidgetwebservice21 -h&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=text&amp;gt;&lt;br /&gt;
&#039;phidgetwebservice21&#039; is a Phidget and Dictionary server from Phidgets Inc. See www.phidgets.com for more information.&lt;br /&gt;
Usage: phidgetwebservice21 [OPTION]&lt;br /&gt;
All parameters are optional. The default parameters are: port=5001, ServerName=(Computer Name) and no password&lt;br /&gt;
&lt;br /&gt;
Options:&lt;br /&gt;
  -p      Port&lt;br /&gt;
  -n      Server Name&lt;br /&gt;
  -P      Password&lt;br /&gt;
  -v      Debug mode&lt;br /&gt;
  -h      Display this help&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Mapping out which command line options to which Phidget Preference Pane option is as follows:&lt;br /&gt;
&lt;br /&gt;
-p: {{Code|Port}} field&lt;br /&gt;
&lt;br /&gt;
-n: {{Code|ServerID}} field&lt;br /&gt;
&lt;br /&gt;
-P: {{Code|Password}} field&lt;br /&gt;
&lt;br /&gt;
-v: Not supported under the Phidget Preference Pane&lt;br /&gt;
&lt;br /&gt;
To find the defaults used by {{Code|phidget21webservice}}, the command line is the fastest way to learn the default server name and IP address of your computer:&lt;br /&gt;
*For the default server name, use {{Code|hostname}} on the command line.&lt;br /&gt;
*For your IP address, use {{Code|ifconfig -a}} on the command line.&lt;br /&gt;
**A line in the return text, under your main internet connection (usually {{Code|eth0}}) will say something like {{Code|inet addr:192.168.3.178}}, which is your IP.&lt;br /&gt;
&lt;br /&gt;
Here are some usage examples:&lt;br /&gt;
&lt;br /&gt;
To start the WebService with default parameters:&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=bash&amp;gt;&lt;br /&gt;
 phidgetwebservice21&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To start the WebService with a server name of {{Code|myServer}}:&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=bash&amp;gt;&lt;br /&gt;
 phidgetwebservice21-n myServer&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To stop the WebService, simply close the command line window or press {{Code|Control}} and {{Code|c}} at the same time in the command line window.&lt;br /&gt;
&lt;br /&gt;
===Using the WebService===&lt;br /&gt;
&lt;br /&gt;
To use a Phidget over the WebService, you&#039;ll want to:&lt;br /&gt;
* Have two different computers connected to the same network. We will call the computer that has the Phidget directly connected to the USB port the host. The client will be the computer that runs a Phidget application to connect to the Phidget attached to the host. Please note that if you only have a single computer, you can also connect to the Phidget over the WebService. The computer will simply act as both a host and client. This will allow you to bypass the [[General Phidget Programming # Details for Open() | one application per Phidget limitation]]. &lt;br /&gt;
&lt;br /&gt;
* Start the WebService on the computer that directly connects to the Phidget&lt;br /&gt;
* Run your program on the remote computer that will control the Phidget over the network&lt;br /&gt;
&lt;br /&gt;
The easiest way to test these steps on OS X is to set up the WebService and run the Phidget program on the client. Please follow these steps:&lt;br /&gt;
&lt;br /&gt;
1. On the host, open up the Phidget Preference Pane and traverse to the {{Code|Web Service}} tab.&lt;br /&gt;
&lt;br /&gt;
[[File:OSX PreferencePane Webservice Stopped.png |link=|alt=OS X Preference Pane WebService]]&lt;br /&gt;
&lt;br /&gt;
2. Leave all fields the way they are, and click on {{Code|Start WebService}} to run the WebService.&lt;br /&gt;
&lt;br /&gt;
3. You can determine that the WebService is running by looking at the status on the right side.&lt;br /&gt;
&lt;br /&gt;
[[File:OSX PreferencePane Webservice Running.png|link=|alt=OS X PreferencePane WebService Running]]&lt;br /&gt;
&lt;br /&gt;
4. Ensure that the Phidget is plugged in to the host. &lt;br /&gt;
&lt;br /&gt;
5. On the client&#039;s Phidget Preference Pane, open up the {{Code|Bonjour}} tab. You will see the Phidget that is plugged into the host as one of the entries listed. Double click it to open the example application.&lt;br /&gt;
&lt;br /&gt;
[[File:OSX PreferencePane Bonjour.png ‎‎ |link=|alt=OS X PreferencePane Bonjour.png ‎]]&lt;br /&gt;
&lt;br /&gt;
6. The example application will open up, and you will be able to communicate with the Phidget over the WebService.&lt;br /&gt;
&lt;br /&gt;
[[File:OSX PreferencePane Example.png ‎ |link=|alt=OS X PreferencePane Example]]&lt;br /&gt;
&lt;br /&gt;
7. You can confirm that the WebService was indeed behind this exchange by terminating the WebService process while still allowing the remote program to run. On the host&#039;s Phidget Preference Pane, traverse to the {{Code|WebService}} tab. Hit {{Code|Stop WebService}} to terminate the WebService. &lt;br /&gt;
&lt;br /&gt;
[[File:OSX PreferencePane Webservice Running.png|link=|alt=OS X PreferencePane WebService Running]]&lt;br /&gt;
&lt;br /&gt;
8. Take a look at the example application on the client. Since the application can no longer connect to the WebService, there is nothing attached. &lt;br /&gt;
&lt;br /&gt;
[[File:OSX PreferencePane Example Stopped.png |link=|alt=OS X PreferencePane Example Stopped]]&lt;br /&gt;
&lt;br /&gt;
===Debugging the WebService===&lt;br /&gt;
&lt;br /&gt;
In addition to enabling [[General Phidget Programming#Logging|logging]] in your Phidget code, you can get additional debugging information from the WebService itself.  This additional debugging can only be enabled from the command line approach to start the WebService. Debug information is enabled by specifying the {{Code|-v}} option:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=bash&amp;gt;&lt;br /&gt;
 phidgetwebservice21 -v -n &amp;quot;myServer&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The debugging information will be shown as output in the command line console.&lt;br /&gt;
&lt;br /&gt;
==Advanced Uses==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Appendix==&lt;br /&gt;
&lt;br /&gt;
===Description of Installer files===&lt;br /&gt;
&lt;br /&gt;
Here is the list of files and their description for each file the installer puts onto your system. &lt;br /&gt;
===Description of Library files===&lt;br /&gt;
&lt;br /&gt;
This section will explain the files that were placed onto your system as part of the installation process.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|Phidget21.framework}}&amp;lt;/b&amp;gt; contains the actual Phidget library, which is used at run-time.  It is placed into {{Code|/Library/Frameworks}}.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|Phidget.kext}}&amp;lt;/b&amp;gt; is the kernel extension.  It is placed into {{Code|/System/Library/Extensions}}.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|libphidget21.jnilib}}&amp;lt;/b&amp;gt; is the JNI library for Java.  It is placed into {{Code|/Library/Java/Extensions}}.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|Phidgets.prefpane}}&amp;lt;/b&amp;gt; is the Phidgets Preference Pane.  It is placed into {{Code|/Library/PreferencePanes}}.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|phidgetwebservice21}}&amp;lt;/b&amp;gt; is the Phidget WebService.  It is placed into {{Code|/usr/bin}}.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|PhidgetsOSA.app}}&amp;lt;/b&amp;gt; is the the Phidgets agent for AppleScript.  It is placed into {{Code|/Library/ScriptingAdditions}}.&lt;br /&gt;
&lt;br /&gt;
==Common Problems and Solutions==&lt;br /&gt;
&lt;br /&gt;
None, yet.&lt;/div&gt;</summary>
		<author><name>Djrudiak</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=OS_-_OS_X&amp;diff=19191</id>
		<title>OS - OS X</title>
		<link rel="alternate" type="text/html" href="https://www.phidgets.com/docs21/index.php?title=OS_-_OS_X&amp;diff=19191"/>
		<updated>2012-04-20T20:03:02Z</updated>

		<summary type="html">&lt;p&gt;Djrudiak: /* Software */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:OS]]&lt;br /&gt;
&lt;br /&gt;
{{OSLang|[[File:Icon-Mac-OS.png‎|64x64px|link=]]|On OS X, Phidgets can be either plugged directly into a USB Port or run over a network using the [[#WebService|WebService]].}}&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
Phidgets are designed to run on &#039;&#039;&#039;OS X 10.4 Tiger or newer&#039;&#039;&#039;, and can run on PPC, 32-bit, and 64-bit systems.&lt;br /&gt;
&lt;br /&gt;
==Getting Started (Libraries and Drivers)==&lt;br /&gt;
&lt;br /&gt;
If this is your first Phidget, we highly recommend working through the Getting Started guide [[Device List|for your specific Phidget device]].  If you already have the Preference Pane Installed and know how to use it, then you&#039;ve already followed the guide and are ready to learn more about the workings behind the Preference Pane, the Phidget WebService, and more - all specific to OS X.&lt;br /&gt;
&lt;br /&gt;
If you are already a pro, and just want the drivers:&lt;br /&gt;
&lt;br /&gt;
*[http://www.phidgets.com/downloads/libraries/Phidget_2.1.8.20120216.dmg OS X Installer]&lt;br /&gt;
*[http://www.phidgets.com/Drivers_Info.html#osx Software License]&lt;br /&gt;
&lt;br /&gt;
===Installing===&lt;br /&gt;
&lt;br /&gt;
The Phidget installer will install the core Phidget files onto your system.&lt;br /&gt;
&lt;br /&gt;
To install the libraries, follow these steps:&lt;br /&gt;
&lt;br /&gt;
1. Download the Phidget installer for your system:&lt;br /&gt;
*[http://www.phidgets.com/downloads/libraries/Phidget_2.1.8.20120216.dmg OS X Installer]&lt;br /&gt;
&lt;br /&gt;
2. Open up the installer, and double click on {{Code|Phidgets.mpkg}} to install the libraries.&lt;br /&gt;
&lt;br /&gt;
[[File:OSX Install 1.png|link=|alt=OS X Install]]&lt;br /&gt;
&lt;br /&gt;
3. Proceed through the wizard. &lt;br /&gt;
&lt;br /&gt;
[[File:OSX Install 2.png|link=|alt=OS X Install]]&lt;br /&gt;
&lt;br /&gt;
4. Once the installation is complete, you are ready to program with Phidgets. To find out what files got installed, please see [[#Description of Installer files | Description of Installer files]] in the Appendix section.&lt;br /&gt;
&lt;br /&gt;
Proceed onto to the [[#Phidget Preference Pane | next]] section where the Phidget Preference Pane will be discussed.&lt;br /&gt;
&lt;br /&gt;
====Phidget Preference Pane====&lt;br /&gt;
&lt;br /&gt;
The Phidget Preference Pane is a tool to quickly determine whether your system is able to communicate with Phidgets, and also act as a debugging tool. &lt;br /&gt;
&lt;br /&gt;
Once the Phidget libraries are installed using the installer, open up the {{Code|System Preferences}} window.&lt;br /&gt;
&lt;br /&gt;
[[File:OSX System Preferences.png|link=|alt=OS X System Preferences]]&lt;br /&gt;
&lt;br /&gt;
Click on the {{Code|Phidgets}} icon in the {{Code|Other}} section to bring up the Phidgets Preference Pane.&lt;br /&gt;
&lt;br /&gt;
[[File:OSX PreferencePane General.png|link=|alt=OS X PreferencePane General]]&lt;br /&gt;
&lt;br /&gt;
The {{Code|general}} tab shows the list of Phidgets currently physically attached to the computer. You can also view the currently installed Phidget library version. You can double click on a Phidget device to open up an example program for the device.&lt;br /&gt;
&lt;br /&gt;
[[File:OSX PreferencePane Example.png|link=|alt=OS X PreferencePane Example]]&lt;br /&gt;
&lt;br /&gt;
In the above screenshot, the RFID example was opened. These examples are intended for demonstration and debugging purposes. If you have not yet already, please see the &#039;&#039;&#039;Getting Started&#039;&#039;&#039; guide [[Device List|for your device]]. It is important to keep in mind that when an example Phidget application is opened from the Phidget Preference Pane or opened from any of your Phidget applications that you develop, it holds a lock on the Phidget. This prevents any other program from accessing the Phidget. Please ensure that this example application is closed(the Phidget Preference Pane can still be running) when you are running your own applications. &lt;br /&gt;
&lt;br /&gt;
The next tab is the {{Code|Web Service}} tab, which allows you to control Phidgets over a network. &lt;br /&gt;
&lt;br /&gt;
[[File:OSX PreferencePane Webservice Stopped.png|link=|alt=OS X PreferencePane WebService Stopped]]&lt;br /&gt;
&lt;br /&gt;
Here, you can start and stop the WebService. Details are provided in the [[#WebService | WebService]] section. This screen also tells you whether the Phidget WebService is currently running. &lt;br /&gt;
&lt;br /&gt;
The next tab is the {{Code|Labels}} tab. In this section, you can view the currently assigned labels of any Phidget attached to your computer. It is also possible to set the labels of Phidgets here too. You might want to set a label to a Phidget device because you can refer to it by its label as opposed to its serial number. &lt;br /&gt;
&lt;br /&gt;
[[File:OSX PreferencePane Labels Local.png|link=|alt=OS X PreferencePane WebService Labels Local]]&lt;br /&gt;
&lt;br /&gt;
You can also view the labels of any Phidget connected through the WebService&lt;br /&gt;
&lt;br /&gt;
[[File:OSX PreferencePane Labels Remote.png|link=|alt=OS X PreferencePane WebService Labels Remote]]&lt;br /&gt;
&lt;br /&gt;
The {{Code|Bonjour}} tab gives a list of all currently attached Phidgets that are connected to the WebService. You can also double click on the Phidget to connect to it over the network using one or more computers, but still use the Phidget on the computer it is directly connected to.&lt;br /&gt;
&lt;br /&gt;
[[File:OSX PreferencePane Bonjour.png|link=|alt=OS X PreferencePane Bonjour]]&lt;br /&gt;
&lt;br /&gt;
The last tab is the {{Code|PhidgetSBC}} tab, which displays the complete list of PhidgetSBCs connected to the network. &lt;br /&gt;
&lt;br /&gt;
[[File:OSX PreferencePane PhidgetSBC.png|link=|alt=OS X PreferencePane PhidgetSBC]]&lt;br /&gt;
&lt;br /&gt;
You can double click on the PhidgetSBC to bring up the PhidgetSBC Administration Console log-in page in your default browser.&lt;br /&gt;
&lt;br /&gt;
[[File:PhidgetSBCAdminConsole.PNG|link=|alt=PhidgetSBC Admin Console]]&lt;br /&gt;
&lt;br /&gt;
The PhidgetSBC Administration Console is where you can go to configure the PhidgetSBC. For more details, please see the [[1072 0 - Getting Started | PhidgetSBC]] section.&lt;br /&gt;
&lt;br /&gt;
===Checking===&lt;br /&gt;
&lt;br /&gt;
To confirm the libraries were installed and work correctly, you can check both the hardware and software components of the interface. It is worth checking the software side first, because if it works then you know the hardware side is also okay.&lt;br /&gt;
&lt;br /&gt;
====Software====&lt;br /&gt;
&lt;br /&gt;
If you have the Phidgets library installed on your system, you can verify that the software component is working by seeing if the Phidget device is listed in the General tab of the Phidget Preference Pane.&lt;br /&gt;
&lt;br /&gt;
[[File:OSX PreferencePane General.png ‎|link=|alt=OS X Preference Pane General]]&lt;br /&gt;
&lt;br /&gt;
The above screenshot shows that a PhidgetRFID and a PhidgetInterfaceKit are attached to the computer. If you see your Phidget in the list, you can continue to the [[#Programming Languages | programming languages]] section to learn more. If you are not able to see that the Phidget is in the list, there may be a hardware issue. Please see the [[#Hardware| hardware]] section for more details.&lt;br /&gt;
&lt;br /&gt;
====Hardware====&lt;br /&gt;
&lt;br /&gt;
You can verify that your computer detects that the Phidget is plugged in through a USB connection by going to the OS X System Profiler. You can access the System Profiler by selecting {{Code|About This Mac}} under the Apple icon. &lt;br /&gt;
&lt;br /&gt;
[[File:OSX About This Mac.png‎|link=|alt=OS X About This Mac]]&lt;br /&gt;
&lt;br /&gt;
The new window will open up.&lt;br /&gt;
&lt;br /&gt;
[[File:OSX More Info.png|link=|alt=OS X More Info]]&lt;br /&gt;
&lt;br /&gt;
Select {{Code|More Info}}. The System Profiler will show up. In the USB section, you will be able to find all connected USB devices. &lt;br /&gt;
&lt;br /&gt;
[[File:OSX USB Devices.png ‎|link=|alt=OS X Attached USB Devices]]&lt;br /&gt;
&lt;br /&gt;
In the above screenshot, The PhidgetInterfaceKit and PhidgetRFID are connected to the USB ports. &lt;br /&gt;
&lt;br /&gt;
If you don&#039;t see the Phidget in the list, then take a look at the [[#Troubleshooting|troubleshooting]] section below, as well as the &#039;&#039;&#039;Communications&#039;&#039;&#039; section of our [[General Troubleshooting#Communications Troubleshooting|general troubleshooting page]].&lt;br /&gt;
&lt;br /&gt;
====Troubleshooting====&lt;br /&gt;
&lt;br /&gt;
If the example programs &#039;&#039;&#039;do not&#039;&#039;&#039; work but USB &#039;&#039;&#039;does&#039;&#039;&#039; work (i.e. your computer can consistently see the device in the [[#Hardware|hardware]]), take a moment to check the basics:&lt;br /&gt;
* You are using OS X 10.4 or newer. &lt;br /&gt;
* No other programs, drivers, or processes are using that USB port in software&lt;br /&gt;
* The Phidget libraries are the latest version (visit the [[#Getting Started (Libraries and Drivers)| getting started section]] to download them)&lt;br /&gt;
&lt;br /&gt;
* Check the [[#Common Problems and Solutions|common problems]] section below, some specific combinations can cause problems&lt;br /&gt;
&lt;br /&gt;
If your problem doesn&#039;t seem to be fixed by these steps, make sure that the Phidget is seen &#039;&#039;&#039;consistently&#039;&#039;&#039; by USB (if it is erratic, try our [[General Troubleshooting|general troubleshooting guide]]).  If you are still having problems after using the troubleshooting guide, please [[Contact Information|ask us]]!&lt;br /&gt;
&lt;br /&gt;
==Programming Languages==&lt;br /&gt;
Phidgets’ philosophy is that you do not have to be an electrical engineer in order to do projects that use devices like sensors, motors, motor controllers, and interface boards. All you need to know is how to program.&lt;br /&gt;
&lt;br /&gt;
After you have installed the drivers above, you should pick a programming language, install libraries, and run the examples for that specific language. You can learn more about what is needed to program in a particular language by choosing the language of your preference below. If you need help choosing a language, please look at the [[Software Overview#Language Support |language comparison table]]. &lt;br /&gt;
&lt;br /&gt;
We recommend the following languages for OS X:&lt;br /&gt;
* [[Language - Applescript|AppleScript]]&lt;br /&gt;
* [[Language - C/C++|C/C++]]&lt;br /&gt;
* [[Language - C#|C#(Using Mono)]]&lt;br /&gt;
* [[Language - Cocoa | Cocoa]]&lt;br /&gt;
* [[Language - Flash AS3 | Flash AS3]]&lt;br /&gt;
* [[Language - Flex AS3 | Flex AS3]]&lt;br /&gt;
* [[Language - LiveCode | LiveCode]]&lt;br /&gt;
* [[Language - Java | Java]]&lt;br /&gt;
* [[Language - Max/MSP|Max/MSP]]&lt;br /&gt;
* [[Language - Python | Python]]&lt;br /&gt;
* [[Language - Ruby|Ruby]]&lt;br /&gt;
&lt;br /&gt;
You can also use these languages, but they do not support [[General Phidget Programming#Event Driven Code | event driven code]], and must use [[General Phidget Programming#Logic Code | logic code]] only:&lt;br /&gt;
&lt;br /&gt;
*[[Language - MATLAB|MATLAB]]&lt;br /&gt;
*[[Language - Simulink|Simulink]]&lt;br /&gt;
&lt;br /&gt;
==WebService==&lt;br /&gt;
&lt;br /&gt;
The Phidget WebService allows you to remotely control a Phidget over a network.&lt;br /&gt;
&lt;br /&gt;
Drivers for the Phidget WebService on OS X are already included in the [[#Getting Started (Libraries and Drivers) | Drivers]] above. If you see the Phidget Preference Pane in System Preferences, then you already have the WebService drivers installed.&lt;br /&gt;
&lt;br /&gt;
There are two ways that you can connect to a Phidget hosted on another computer. The first method is by using the IP address/host name and port of the host computer. The second method makes the use of [http://en.wikipedia.org/wiki/Multicast_DNS mDNS], which allows Phidgets to be found and opened on the network by a server id instead of an IP address/host name. When using a server id, both the client and server will need to be running an implementation of zero configuration networking. The Phidget WebService takes advantage [http://www.apple.com/support/downloads/bonjourforwindows.html Bonjour] software, which is built-in to OS X. It is a tool, developed by Apple to locate devices such as Phidgets, and printers.&lt;br /&gt;
&lt;br /&gt;
This section helps you install, check, and use the WebService on Windows, but we also have an overview of the [[Phidget WebService]] in general.&lt;br /&gt;
&lt;br /&gt;
===Turning the WebService On and Off===&lt;br /&gt;
&lt;br /&gt;
There are two methods that can be used to turn the WebService on and off. The first method is through the Phidget Preference Pane. In the {{Code|WebService}} tab, you can start or stop the WebService. You can also choose to have the WebService start up automatically upon system boot up by selecting the {{Code|Start Automatically}} checkbox. &lt;br /&gt;
&lt;br /&gt;
[[File:OSX PreferencePane Webservice Stopped.png|link=|alt=OS X PreferencePane WebService]]&lt;br /&gt;
&lt;br /&gt;
The second method of turning the WebService on and off is through command line. After using our installer, the WebService utility is automatically installed in {{Code|/usr/bin/phidget21webservice}}. &lt;br /&gt;
&lt;br /&gt;
You can get command line help with {{Code|phidgetwebservice21}} using the -h option:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=bash&amp;gt;&lt;br /&gt;
 phidgetwebservice21 -h&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=text&amp;gt;&lt;br /&gt;
&#039;phidgetwebservice21&#039; is a Phidget and Dictionary server from Phidgets Inc. See www.phidgets.com for more information.&lt;br /&gt;
Usage: phidgetwebservice21 [OPTION]&lt;br /&gt;
All parameters are optional. The default parameters are: port=5001, ServerName=(Computer Name) and no password&lt;br /&gt;
&lt;br /&gt;
Options:&lt;br /&gt;
  -p      Port&lt;br /&gt;
  -n      Server Name&lt;br /&gt;
  -P      Password&lt;br /&gt;
  -v      Debug mode&lt;br /&gt;
  -h      Display this help&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Mapping out which command line options to which Phidget Preference Pane option is as follows:&lt;br /&gt;
&lt;br /&gt;
-p: {{Code|Port}} field&lt;br /&gt;
&lt;br /&gt;
-n: {{Code|ServerID}} field&lt;br /&gt;
&lt;br /&gt;
-P: {{Code|Password}} field&lt;br /&gt;
&lt;br /&gt;
-v: Not supported under the Phidget Preference Pane&lt;br /&gt;
&lt;br /&gt;
To find the defaults used by {{Code|phidget21webservice}}, the command line is the fastest way to learn the default server name and IP address of your computer:&lt;br /&gt;
*For the default server name, use {{Code|hostname}} on the command line.&lt;br /&gt;
*For your IP address, use {{Code|ifconfig -a}} on the command line.&lt;br /&gt;
**A line in the return text, under your main internet connection (usually {{Code|eth0}}) will say something like {{Code|inet addr:192.168.3.178}}, which is your IP.&lt;br /&gt;
&lt;br /&gt;
Here are some usage examples:&lt;br /&gt;
&lt;br /&gt;
To start the WebService with default parameters:&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=bash&amp;gt;&lt;br /&gt;
 phidgetwebservice21&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To start the WebService with a server name of {{Code|myServer}}:&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=bash&amp;gt;&lt;br /&gt;
 phidgetwebservice21-n myServer&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To stop the WebService, simply close the command line window or press {{Code|Control}} and {{Code|c}} at the same time in the command line window.&lt;br /&gt;
&lt;br /&gt;
===Using the WebService===&lt;br /&gt;
&lt;br /&gt;
To use a Phidget over the WebService, you&#039;ll want to:&lt;br /&gt;
* Have two different computers connected to the same network. We will call the computer that has the Phidget directly connected to the USB port the host. The client will be the computer that runs a Phidget application to connect to the Phidget attached to the host. Please note that if you only have a single computer, you can also connect to the Phidget over the WebService. The computer will simply act as both a host and client. This will allow you to bypass the [[General Phidget Programming # Details for Open() | one application per Phidget limitation]]. &lt;br /&gt;
&lt;br /&gt;
* Start the WebService on the computer that directly connects to the Phidget&lt;br /&gt;
* Run your program on the remote computer that will control the Phidget over the network&lt;br /&gt;
&lt;br /&gt;
The easiest way to test these steps on OS X is to set up the WebService and run the Phidget program on the client. Please follow these steps:&lt;br /&gt;
&lt;br /&gt;
1. On the host, open up the Phidget Preference Pane and traverse to the {{Code|Web Service}} tab.&lt;br /&gt;
&lt;br /&gt;
[[File:OSX PreferencePane Webservice Stopped.png |link=|alt=OS X Preference Pane WebService]]&lt;br /&gt;
&lt;br /&gt;
2. Leave all fields the way they are, and click on {{Code|Start WebService}} to run the WebService.&lt;br /&gt;
&lt;br /&gt;
3. You can determine that the WebService is running by looking at the status on the right side.&lt;br /&gt;
&lt;br /&gt;
[[File:OSX PreferencePane Webservice Running.png|link=|alt=OS X PreferencePane WebService Running]]&lt;br /&gt;
&lt;br /&gt;
4. Ensure that the Phidget is plugged in to the host. &lt;br /&gt;
&lt;br /&gt;
5. On the client&#039;s Phidget Preference Pane, open up the {{Code|Bonjour}} tab. You will see the Phidget that is plugged into the host as one of the entries listed. Double click it to open the example application.&lt;br /&gt;
&lt;br /&gt;
[[File:OSX PreferencePane Bonjour.png ‎‎ |link=|alt=OS X PreferencePane Bonjour.png ‎]]&lt;br /&gt;
&lt;br /&gt;
6. The example application will open up, and you will be able to communicate with the Phidget over the WebService.&lt;br /&gt;
&lt;br /&gt;
[[File:OSX PreferencePane Example.png ‎ |link=|alt=OS X PreferencePane Example]]&lt;br /&gt;
&lt;br /&gt;
7. You can confirm that the WebService was indeed behind this exchange by terminating the WebService process while still allowing the remote program to run. On the host&#039;s Phidget Preference Pane, traverse to the {{Code|WebService}} tab. Hit {{Code|Stop WebService}} to terminate the WebService. &lt;br /&gt;
&lt;br /&gt;
[[File:OSX PreferencePane Webservice Running.png|link=|alt=OS X PreferencePane WebService Running]]&lt;br /&gt;
&lt;br /&gt;
8. Take a look at the example application on the client. Since the application can no longer connect to the WebService, there is nothing attached. &lt;br /&gt;
&lt;br /&gt;
[[File:OSX PreferencePane Example Stopped.png |link=|alt=OS X PreferencePane Example Stopped]]&lt;br /&gt;
&lt;br /&gt;
===Debugging the WebService===&lt;br /&gt;
&lt;br /&gt;
In addition to enabling [[General Phidget Programming#Logging|logging]] in your Phidget code, you can get additional debugging information from the WebService itself.  This additional debugging can only be enabled from the command line approach to start the WebService. Debug information is enabled by specifying the {{Code|-v}} option:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=bash&amp;gt;&lt;br /&gt;
 phidgetwebservice21 -v -n &amp;quot;myServer&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The debugging information will be shown as output in the command line console.&lt;br /&gt;
&lt;br /&gt;
==Advanced Uses==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Appendix==&lt;br /&gt;
&lt;br /&gt;
===Description of Installer files===&lt;br /&gt;
&lt;br /&gt;
Here is the list of files and their description for each file the installer puts onto your system. &lt;br /&gt;
===Description of Library files===&lt;br /&gt;
&lt;br /&gt;
This section will explain the files that were placed onto your system as part of the installation process.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|Phidget21.framework}}&amp;lt;/b&amp;gt; contains the actual Phidget library, which is used at run-time.  It is placed into {{Code|/Library/Frameworks}}.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|Phidget.kext}}&amp;lt;/b&amp;gt; is the kernel extension.  It is placed into {{Code|/System/Library/Extensions}}.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|libphidget21.jnilib}}&amp;lt;/b&amp;gt; is the JNI library for Java.  It is placed into {{Code|/Library/Java/Extensions}}.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|Phidgets.prefpane}}&amp;lt;/b&amp;gt; is the Phidgets Preference Pane.  It is placed into {{Code|/Library/PreferencePanes}}.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|phidgetwebservice21}}&amp;lt;/b&amp;gt; is the Phidget WebService.  It is placed into {{Code|/usr/bin}}.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|PhidgetsOSA.app}}&amp;lt;/b&amp;gt; is the the Phidgets agent for AppleScript.  It is placed into {{Code|/Library/ScriptingAdditions}}.&lt;br /&gt;
&lt;br /&gt;
==Common Problems and Solutions==&lt;br /&gt;
&lt;br /&gt;
None, yet.&lt;/div&gt;</summary>
		<author><name>Djrudiak</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=Language_-_Delphi&amp;diff=19189</id>
		<title>Language - Delphi</title>
		<link rel="alternate" type="text/html" href="https://www.phidgets.com/docs21/index.php?title=Language_-_Delphi&amp;diff=19189"/>
		<updated>2012-04-20T19:45:43Z</updated>

		<summary type="html">&lt;p&gt;Djrudiak: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Language]]&lt;br /&gt;
{{OSLang|[[File:Icon-Delphi.png|64px|alt=|link=]]|&#039;&#039;&#039;[http://www.embarcadero.com/products/delphi Embarcadero Delphi]&#039;&#039;&#039; is an integrated development environment for console, desktop graphical, web application, and mobile applications.}}&lt;br /&gt;
==Support==&lt;br /&gt;
Delphi has a complete API for all Phidgets devices, and code samples for AdvancedServo, Servo, PhidgetInterfaceKit, and RFID.&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;
* 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;
* 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 Phidget Programming]] 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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&amp;lt;/div&amp;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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&amp;lt;/div&amp;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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight lang=delphi&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  PhidgetInterfaceKit1.OutputState[0] := true;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/div&amp;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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&amp;lt;/div&amp;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>Djrudiak</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=Language_-_Objective_C&amp;diff=19188</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=19188"/>
		<updated>2012-04-20T19:23:03Z</updated>

		<summary type="html">&lt;p&gt;Djrudiak: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Language]]&lt;br /&gt;
{{OSLang|[[File:icon-Cocoa.png|64x64px|alt=|link=]]|Cocoa is Apple&#039;s native object-oriented application programming interface (API) for the [http://www.apple.com/macosx/mountain-lion/ Mac OS X] [[OS - OS X|operating system]].}}&lt;br /&gt;
__TOC__&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;
* 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;
* 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 Phidget Programming]] 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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight lang=objc&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
  CPhidgetInterfaceKitHandle ifkit&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;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>Djrudiak</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=Language_-_Visual_Basic_Script&amp;diff=19187</id>
		<title>Language - Visual Basic Script</title>
		<link rel="alternate" type="text/html" href="https://www.phidgets.com/docs21/index.php?title=Language_-_Visual_Basic_Script&amp;diff=19187"/>
		<updated>2012-04-20T19:17:46Z</updated>

		<summary type="html">&lt;p&gt;Djrudiak: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Language]]&lt;br /&gt;
{{OSLang|[[File:icon-Visual Basic Script.png|64x64px|alt=|link=]]|&#039;&#039;&#039;VBScript&#039;&#039;&#039; (&#039;&#039;&#039;V&#039;&#039;&#039;isual &#039;&#039;&#039;B&#039;&#039;&#039;asic &#039;&#039;&#039;Script&#039;&#039;&#039;ing Edition) is an [http://en.wikipedia.org/wiki/Active_Scripting Active Scripting] language developed by [http://msdn.microsoft.com/en-us/library/t0aew7h6 Microsoft] that is modeled on [[Language_-_Visual_Basic_6.0|Visual Basic]].}}&lt;br /&gt;
==Support==&lt;br /&gt;
Visual Basic Script has a complete API for all Phidgets devices, and code samples for Encoder, InterfaceKit and RFID.&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;
* 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;
* 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;
&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/VBScript_2.1.8.20110615.zip VBS 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 ClassID List from the VBScript examples above to program with Phidgets, and the Phidget Framework to use them. &lt;br /&gt;
The Phidget examples were written using Visual Basic Script for Internet Explorer and this tutorial assumes its use. &lt;br /&gt;
To begin, load the HTML editor of your choice and create a new document. &lt;br /&gt;
Add a table to body of the code for the purpose of displaying simple output.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight lang=html4strict&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
  &amp;lt;html&amp;gt;&lt;br /&gt;
  &amp;lt;head&amp;gt; &lt;br /&gt;
  &amp;lt;body&amp;gt;&lt;br /&gt;
  &amp;lt;form action=”html_interfacekit.htm”&amp;gt;&lt;br /&gt;
  &amp;lt;table id=”mytable”&amp;gt;&lt;br /&gt;
       &amp;lt;thead&amp;gt;&lt;br /&gt;
     &amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Analog Input&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
       &amp;lt;/thead&amp;gt;&lt;br /&gt;
  &amp;lt;tr id=”tr0”&amp;gt;&amp;lt;td&amp;gt;0&amp;lt;/td&amp;gt; &amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;tr id=”tr1”&amp;gt;&amp;lt;td&amp;gt;0&amp;lt;/td&amp;gt; &amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;tr id=”tr2”&amp;gt;&amp;lt;td&amp;gt;0&amp;lt;/td&amp;gt; &amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;tr id=”tr3”&amp;gt;&amp;lt;td&amp;gt;0&amp;lt;/td&amp;gt; &amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;tr id=”tr4”&amp;gt;&amp;lt;td&amp;gt;0&amp;lt;/td&amp;gt; &amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;tr id=”tr5”&amp;gt;&amp;lt;td&amp;gt;0&amp;lt;/td&amp;gt; &amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;tr id=”tr6”&amp;gt;&amp;lt;td&amp;gt;0&amp;lt;/td&amp;gt; &amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;tr id=”tr7”&amp;gt;&amp;lt;td&amp;gt;0&amp;lt;/td&amp;gt; &amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;/table&amp;gt;&lt;br /&gt;
  &amp;lt;/form&amp;gt;&lt;br /&gt;
  &amp;lt;/body&amp;gt;&lt;br /&gt;
  &amp;lt;/html&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;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 include its Class ID on object creation in your code. &lt;br /&gt;
This will let the browser know which library to try and load for the Phidget definitions. &lt;br /&gt;
Each type of Phidget has its ClassID listed inside the ClassID_List.txt document from the VBScript examples. &lt;br /&gt;
For example, we can declare and create a PhidgetInterfaceKit for vbscript with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight lang=html4strict&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
  &amp;lt;object classid=&amp;quot;clsid:50484945-4745-5453-3000-000000000003&amp;quot; id=&amp;quot;phid&amp;quot;&amp;gt;&amp;lt;/object&amp;gt;&lt;br /&gt;
  &amp;lt;script type=&amp;quot;text/vbscript&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;!--Your Code goes here--&amp;gt;&lt;br /&gt;
  &amp;lt;/script&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;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 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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight lang=vb&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
  phid.Open()&lt;br /&gt;
  phid.WaitForAttachment (3000)&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;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;
In VBScript, we hook an event handler with the following code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight lang=vb&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  Sub phid_OnSensorChange(ByVal Index, ByVal SensorValue)&lt;br /&gt;
     mytable.rows(&amp;quot;str&amp;quot;+CStr(Index)).cells(0).innerText = Cstr(InterfaceKit1.sensorValue(Index))&lt;br /&gt;
  End Sub&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;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;
&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 phid.SensorChangeTrigger(Index) for PhidgetInterfaceKits.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight lang=vb&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  phid.SensorChangeTrigger(0) = 1&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;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 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;
&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 use the class ID for a PhidgetRFID 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;
&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;
&lt;br /&gt;
===Issue: Cannot control Phidgets with certain web browsers===&lt;br /&gt;
Affected Operating Systems: &#039;&#039;&#039;Windows&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Certain web browsers such as Firefox and Chrome cannot control Phidgets in Visual Basic Script.&lt;br /&gt;
&lt;br /&gt;
Solution: Only Internet Explorer can control Phidgets with Visual Basic Script.&lt;/div&gt;</summary>
		<author><name>Djrudiak</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=Language_-_Visual_Basic_for_Applications&amp;diff=19183</id>
		<title>Language - Visual Basic for Applications</title>
		<link rel="alternate" type="text/html" href="https://www.phidgets.com/docs21/index.php?title=Language_-_Visual_Basic_for_Applications&amp;diff=19183"/>
		<updated>2012-04-20T18:57:02Z</updated>

		<summary type="html">&lt;p&gt;Djrudiak: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Language]]&lt;br /&gt;
{{OSLang|[[File:Icon-Visual Basic for Applications.png|64x64px|alt=|link=]]|&#039;&#039;&#039;Visual Basic for Applications&#039;&#039;&#039; (&#039;&#039;&#039;VBA&#039;&#039;&#039;) is an implementation of [http://msdn.microsoft.com/en-ca/office Microsoft]&#039;s event-driven programming language [[Language_-_Visual_Basic_6.0|Visual Basic 6.0]] and its associated integrated development environment (IDE), which are built into most [http://office.microsoft.com Microsoft Office] applications.}}&lt;br /&gt;
==Support==&lt;br /&gt;
VBA has a complete API for all Phidgets devices, and code samples for Accelerometer, Encoder, InterfaceKit, RFID, TemperatureSensor and Servo.&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;
* 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;
* 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/VBA_2.1.8.20110615.zip VBA 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 Microsoft Excel 2000 and this tutorial assumes its use. &lt;br /&gt;
Other environments such as Microsoft Office should work provided they support VBA, and each would be set up in a similar manner.&lt;br /&gt;
&lt;br /&gt;
To begin, launch Excel with a new workbook for our project. Launch the VBA editor (Tools | Macro | Visual Basic Editor) and open “ThisWorkbook” in the navigator.&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 the library in your project. &lt;br /&gt;
This can be accomplished from the references screen (Tools | References...) by checking the box beside “Phidget Library 2.1”, or by browsing to the location the framework was installed and choosing the Phidget21COM.dll.&lt;br /&gt;
&lt;br /&gt;
Afterwards, the Phidget object will need to be declared and then initialized inside the workbook item. &lt;br /&gt;
For example, we can declare and create a PhidgetInterfaceKit at the top of the code with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight lang=vb&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  Public WithEvents phid As PhidgetInterfaceKit&lt;br /&gt;
  Private Sub Workbook_Open()&lt;br /&gt;
      Set phid = New PhidgetInterfaceKit&lt;br /&gt;
  End Sub&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;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 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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight lang=vb&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  phid.Open&lt;br /&gt;
  phid.WaitForAttachment(3000)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;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;
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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight lang=vb&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  Private Sub Workbook_BeforeClose(Cancel As Boolean)&lt;br /&gt;
     phid.Close&lt;br /&gt;
  End Sub&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;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. In Visual Basic, we hook an event handler with the following code:  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight lang=vb&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    Private Sub phid_OnSensorChange(ByVal Index As Long, ByVal SensorValue As Long)&lt;br /&gt;
        Range(&amp;quot;A2&amp;quot;).Select&lt;br /&gt;
        ActiveCell.Offset(Index, 0).Value = SensorValue&lt;br /&gt;
    End Sub&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;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;
You can let the editor generate the procedure declaration for you through the drop down menu at the top of the code window.&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 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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight lang=vb&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  phid.OutputState(4) = True&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;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 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;
&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 a PhidgetRFID 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>Djrudiak</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=Language_-_Delphi&amp;diff=19165</id>
		<title>Language - Delphi</title>
		<link rel="alternate" type="text/html" href="https://www.phidgets.com/docs21/index.php?title=Language_-_Delphi&amp;diff=19165"/>
		<updated>2012-04-20T17:42:00Z</updated>

		<summary type="html">&lt;p&gt;Djrudiak: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Language]]&lt;br /&gt;
{{OSLang|[[File:Icon-Delphi.png|64px|alt=|link=]]|Preamble about the language and its general strengths and weaknesses.&lt;br /&gt;
}}&lt;br /&gt;
==Support==&lt;br /&gt;
Delphi has a complete API for all Phidgets devices, and code samples for AdvancedServo, Servo, PhidgetInterfaceKit, and RFID.&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;
* 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;
* 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 Phidget Programming]] 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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&amp;lt;/div&amp;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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&amp;lt;/div&amp;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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight lang=delphi&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  PhidgetInterfaceKit1.OutputState[0] := true;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/div&amp;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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&amp;lt;/div&amp;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>Djrudiak</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=Language_-_Visual_Basic_Script&amp;diff=19164</id>
		<title>Language - Visual Basic Script</title>
		<link rel="alternate" type="text/html" href="https://www.phidgets.com/docs21/index.php?title=Language_-_Visual_Basic_Script&amp;diff=19164"/>
		<updated>2012-04-20T17:40:27Z</updated>

		<summary type="html">&lt;p&gt;Djrudiak: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Language]]&lt;br /&gt;
{{OSLang|[[File:icon-Visual Basic Script.png|64x64px|alt=|link=]]|Preamble about the language&#039;s origin and its main characteristics.}}&lt;br /&gt;
==Support==&lt;br /&gt;
Visual Basic Script has a complete API for all Phidgets devices, and code samples for Encoder, InterfaceKit and RFID.&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;
* 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;
* 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;
&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/VBScript_2.1.8.20110615.zip VBS 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 ClassID List from the VBScript examples above to program with Phidgets, and the Phidget Framework to use them. &lt;br /&gt;
The Phidget examples were written using Visual Basic Script for Internet Explorer and this tutorial assumes its use. &lt;br /&gt;
To begin, load the HTML editor of your choice and create a new document. &lt;br /&gt;
Add a table to body of the code for the purpose of displaying simple output.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight lang=html4strict&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
  &amp;lt;html&amp;gt;&lt;br /&gt;
  &amp;lt;head&amp;gt; &lt;br /&gt;
  &amp;lt;body&amp;gt;&lt;br /&gt;
  &amp;lt;form action=”html_interfacekit.htm”&amp;gt;&lt;br /&gt;
  &amp;lt;table id=”mytable”&amp;gt;&lt;br /&gt;
       &amp;lt;thead&amp;gt;&lt;br /&gt;
     &amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Analog Input&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
       &amp;lt;/thead&amp;gt;&lt;br /&gt;
  &amp;lt;tr id=”tr0”&amp;gt;&amp;lt;td&amp;gt;0&amp;lt;/td&amp;gt; &amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;tr id=”tr1”&amp;gt;&amp;lt;td&amp;gt;0&amp;lt;/td&amp;gt; &amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;tr id=”tr2”&amp;gt;&amp;lt;td&amp;gt;0&amp;lt;/td&amp;gt; &amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;tr id=”tr3”&amp;gt;&amp;lt;td&amp;gt;0&amp;lt;/td&amp;gt; &amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;tr id=”tr4”&amp;gt;&amp;lt;td&amp;gt;0&amp;lt;/td&amp;gt; &amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;tr id=”tr5”&amp;gt;&amp;lt;td&amp;gt;0&amp;lt;/td&amp;gt; &amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;tr id=”tr6”&amp;gt;&amp;lt;td&amp;gt;0&amp;lt;/td&amp;gt; &amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;tr id=”tr7”&amp;gt;&amp;lt;td&amp;gt;0&amp;lt;/td&amp;gt; &amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;/table&amp;gt;&lt;br /&gt;
  &amp;lt;/form&amp;gt;&lt;br /&gt;
  &amp;lt;/body&amp;gt;&lt;br /&gt;
  &amp;lt;/html&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;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 include its Class ID on object creation in your code. &lt;br /&gt;
This will let the browser know which library to try and load for the Phidget definitions. &lt;br /&gt;
Each type of Phidget has its ClassID listed inside the ClassID_List.txt document from the VBScript examples. &lt;br /&gt;
For example, we can declare and create a PhidgetInterfaceKit for vbscript with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight lang=html4strict&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
  &amp;lt;object classid=&amp;quot;clsid:50484945-4745-5453-3000-000000000003&amp;quot; id=&amp;quot;phid&amp;quot;&amp;gt;&amp;lt;/object&amp;gt;&lt;br /&gt;
  &amp;lt;script type=&amp;quot;text/vbscript&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;!--Your Code goes here--&amp;gt;&lt;br /&gt;
  &amp;lt;/script&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;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 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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight lang=vb&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
  phid.Open()&lt;br /&gt;
  phid.WaitForAttachment (3000)&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;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;
In VBScript, we hook an event handler with the following code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight lang=vb&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  Sub phid_OnSensorChange(ByVal Index, ByVal SensorValue)&lt;br /&gt;
     mytable.rows(&amp;quot;str&amp;quot;+CStr(Index)).cells(0).innerText = Cstr(InterfaceKit1.sensorValue(Index))&lt;br /&gt;
  End Sub&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;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;
&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 phid.SensorChangeTrigger(Index) for PhidgetInterfaceKits.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight lang=vb&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  phid.SensorChangeTrigger(0) = 1&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;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 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;
&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 use the class ID for a PhidgetRFID 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;
&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;
&lt;br /&gt;
===Issue: Cannot control Phidgets with certain web browsers===&lt;br /&gt;
Affected Operating Systems: &#039;&#039;&#039;Windows&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Certain web browsers such as Firefox and Chrome cannot control Phidgets in Visual Basic Script.&lt;br /&gt;
&lt;br /&gt;
Solution: Only Internet Explorer can control Phidgets with Visual Basic Script.&lt;/div&gt;</summary>
		<author><name>Djrudiak</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=Language_-_Visual_Basic_for_Applications&amp;diff=19163</id>
		<title>Language - Visual Basic for Applications</title>
		<link rel="alternate" type="text/html" href="https://www.phidgets.com/docs21/index.php?title=Language_-_Visual_Basic_for_Applications&amp;diff=19163"/>
		<updated>2012-04-20T17:39:18Z</updated>

		<summary type="html">&lt;p&gt;Djrudiak: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Language]]&lt;br /&gt;
{{OSLang|[[File:Icon-Visual Basic for Applications.png|64x64px|alt=|link=]]|Preamble about the language&#039;s origin and its main characteristics.}}&lt;br /&gt;
==Support==&lt;br /&gt;
VBA has a complete API for all Phidgets devices, and code samples for Accelerometer, Encoder, InterfaceKit, RFID, TemperatureSensor and Servo.&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;
* 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;
* 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/VBA_2.1.8.20110615.zip VBA 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 Microsoft Excel 2000 and this tutorial assumes its use. &lt;br /&gt;
Other environments such as Microsoft Office should work provided they support VBA, and each would be set up in a similar manner.&lt;br /&gt;
&lt;br /&gt;
To begin, launch Excel with a new workbook for our project. Launch the VBA editor (Tools | Macro | Visual Basic Editor) and open “ThisWorkbook” in the navigator.&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 the library in your project. &lt;br /&gt;
This can be accomplished from the references screen (Tools | References...) by checking the box beside “Phidget Library 2.1”, or by browsing to the location the framework was installed and choosing the Phidget21COM.dll.&lt;br /&gt;
&lt;br /&gt;
Afterwards, the Phidget object will need to be declared and then initialized inside the workbook item. &lt;br /&gt;
For example, we can declare and create a PhidgetInterfaceKit at the top of the code with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight lang=vb&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  Public WithEvents phid As PhidgetInterfaceKit&lt;br /&gt;
  Private Sub Workbook_Open()&lt;br /&gt;
      Set phid = New PhidgetInterfaceKit&lt;br /&gt;
  End Sub&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;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 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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight lang=vb&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  phid.Open&lt;br /&gt;
  phid.WaitForAttachment(3000)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;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;
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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight lang=vb&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  Private Sub Workbook_BeforeClose(Cancel As Boolean)&lt;br /&gt;
     phid.Close&lt;br /&gt;
  End Sub&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;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. In Visual Basic, we hook an event handler with the following code:  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight lang=vb&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    Private Sub phid_OnSensorChange(ByVal Index As Long, ByVal SensorValue As Long)&lt;br /&gt;
        Range(&amp;quot;A2&amp;quot;).Select&lt;br /&gt;
        ActiveCell.Offset(Index, 0).Value = SensorValue&lt;br /&gt;
    End Sub&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;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;
You can let the editor generate the procedure declaration for you through the drop down menu at the top of the code window.&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 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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight lang=vb&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  phid.OutputState(4) = True&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;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 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;
&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 a PhidgetRFID 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>Djrudiak</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=Language_-_REALBasic&amp;diff=19162</id>
		<title>Language - REALBasic</title>
		<link rel="alternate" type="text/html" href="https://www.phidgets.com/docs21/index.php?title=Language_-_REALBasic&amp;diff=19162"/>
		<updated>2012-04-20T17:38:11Z</updated>

		<summary type="html">&lt;p&gt;Djrudiak: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Language]]&lt;br /&gt;
{{OSLang|[[File:icon-REALBasic.png|64x64px|alt=|link=]]|REALBasic is no longer maintained by Phidgets.}}&lt;br /&gt;
==Support==&lt;br /&gt;
REALBasic 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;
* 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;
* 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/cdoc/index.html API Reference]&lt;br /&gt;
* We currently do not have any sample code for REALBasic.&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 Phidget can be developed in REALbasic through the C API. &lt;br /&gt;
This tutorial assumes the use of REALbasic 2009, other recent versions should work as well and would be set up in a similar manner. &lt;br /&gt;
Phidgets will not run under REALbasic 2006. Although it’s possible to import Phidgets as ActiveX controls, this is not recommended due to the way REALbasic handles them. &lt;br /&gt;
To begin, launch REALbasic and create a new “Desktop Application”. &lt;br /&gt;
Then, place an EditField “EditField1” in the form designer for the purpose of capturing some simple output.  &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 each of the functions from the C library that the program will use. &lt;br /&gt;
For example, you can declare at initialization (inside Windows1.Open) some C functions for a PhidgetInterfaceKit with the following syntax:&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight lang=vb&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  Declare Function CPhidget_open lib &amp;quot;phidget21&amp;quot; (phid as Ptr, serialNumber as Integer) as integer&lt;br /&gt;
  Declare Function CPhidget_waitForAttachment lib &amp;quot;phidget21&amp;quot; (phid as Ptr, milliseconds asInteger) as Integer&lt;br /&gt;
  Declare Function CPhidgetInterfaceKit_create lib &amp;quot;phidget21&amp;quot; (CPhidgetInterfaceKitHandle as Ptr) as Integer&lt;br /&gt;
  Declare Function CPhidgetInterfaceKit_set_OnSensorChange_Handler lib &amp;quot;phidget21&amp;quot;(CPhidgetInterfaceKitHandle as Ptr, fptr as Ptr, UserPtr as Ptr) as Integer&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The declaration closely follows the C API with a few minor changes. &lt;br /&gt;
Generally, when any type of PhidgetHandle is used, it’s safe to change the type to Ptr. &lt;br /&gt;
You will also need to copy the phidget21.dll file from the Phidget Framework directory into your project output directory for these declarations to work.&lt;br /&gt;
&lt;br /&gt;
Afterwards, the Phidget object itself will need to be declared and then initialized. &lt;br /&gt;
This can be done by declaring a property on Windows1 named “ifKitHandle” as a Ptr, calling create on an empty block of memory, and then setting the handle to the result.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight lang=vb&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  Dim tmp As MemoryBlock&lt;br /&gt;
  Dim result As Integer&lt;br /&gt;
  tmp = NewMemoryBlock(1000)&lt;br /&gt;
  Call CPhidgetInterfaceKit_create(tmp)&lt;br /&gt;
  ifKitHandle = tmp.Ptr(0)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;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 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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight lang=vb&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  result = CPhidget_open(ifKitHandle, -1)&lt;br /&gt;
  if CPhidget_waitForAttachment(ifKitHandle, 3000)&amp;lt;&amp;gt;0 Then&lt;br /&gt;
     MsgBox(&amp;quot;Can’t find a PhidgetInterfaceKit&amp;quot;)&lt;br /&gt;
  else&lt;br /&gt;
      &#039;More code goes here&lt;br /&gt;
  end if&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;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;
In Real Basic, a few steps will need to be followed to properly hook C events. &lt;br /&gt;
Event handler methods with matching definitions must be created inside their own module (Project | Add | Module). &lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight lang=vb&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  Function ifKit_OnSensorChange(ByVal phid As Ptr, ByVal userPtr As Ptr, ByVal index &lt;br /&gt;
  As Integer, ByVal sensorValue As Integer) As Integer&lt;br /&gt;
     #pragma X86CallingConvention StdCall&lt;br /&gt;
  Window1.EditField1.text = Str(index) + &amp;quot;:&amp;quot; + Str(sensorValue)&lt;br /&gt;
  End Function&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this example, a new module “Module1” was created and given the ifKit_OnSensorChange method. &lt;br /&gt;
Note that the handler must have “#pragma X86CallingConvention StdCall” as the first line. &lt;br /&gt;
Inside Window1.Open we can then link to the method we wrote with a call to CPhidgetInterfaceKit_set_OnSensorChange_Handler.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight lang=vb&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  Call CPhidgetInterfaceKit_set_OnSensorChange_Handler(ifKitHandle, AddressOf Module1.ifKit_OnsensorChange, nil)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this, the code inside ifKit_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 declare the C function before using calls such as CPhidgetInterfaceKit_getSensorValue for PhidgetInterfaceKits.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight lang=vb&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  Declare Function CPhidgetInterfaceKit_getSensorValue lib &amp;quot;phidget21&amp;quot; (phid as Ptr, index as Integer, sensorValue as Ptr) as Integerresult = CPhidgetInterfaceKit_getSensorValue(ifKitHandle, 0, tmp)&lt;br /&gt;
  Dim sensorValue As Integer = tmp.Long(0)&lt;br /&gt;
  Window1.EditField1.Text = Str(sensorValue)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;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 instance of a PhidgetInterfaceKit to be defined and initialized.&lt;br /&gt;
The new instance can 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 call CPhidgetRFID_create instead of CPhidgetInterfaceKit_create. &lt;br /&gt;
The methods and events available would change but they can be used 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>Djrudiak</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=Language_-_Visual_Basic_(.NET_Compact_Framework)&amp;diff=19161</id>
		<title>Language - Visual Basic (.NET Compact Framework)</title>
		<link rel="alternate" type="text/html" href="https://www.phidgets.com/docs21/index.php?title=Language_-_Visual_Basic_(.NET_Compact_Framework)&amp;diff=19161"/>
		<updated>2012-04-20T17:34:44Z</updated>

		<summary type="html">&lt;p&gt;Djrudiak: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Language]]&lt;br /&gt;
{{OSLang|[[File:icon-Visual Basic Net.png|64x64px|link=|alt=]]|Visual Basic(.NET Compact Framework) is a modern, object-oriented programming language developed by [[http://www.microsoft.com Microsoft]] intended for developing applications for smart devices.}}&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
{{LanguageSupport|Visual Basic(.NET Compact Framework)|the complete Phidget API, including events|all Phidget devices.|the .NET Compact Framework. This frameworks is supported on devices with the Windows CE operating system. We provide instructions on how to set up your environment/compilers for [[#Visual Studio 2005/2008/2010 | Visual Studio 2005/2008/2010]]|}}&lt;br /&gt;
&lt;br /&gt;
==Quick Downloads==&lt;br /&gt;
{{QuickDownloads|Visual Basic(.NET Compact Framework)|&lt;br /&gt;
{{APIQuickDownloads|http://www.phidgets.com/documentation/Phidget21.NET.zip .NET}}|&lt;br /&gt;
{{ExampleQuickDownloads|http://www.phidgets.com/downloads/examples/CE_2.1.8.20120216.zip|}}|&lt;br /&gt;
{{ExtraLibraryQuickDownloads|http://www.phidgets.com/downloads/libraries/Phidget21-wincedevel_2.1.8.20120216.zip|Phidget Windows CE|(all architectures)}}&lt;br /&gt;
{{ExtraLibraryQuickDownloads|http://www.phidgets.com/downloads/libraries/Phidget21ARMV4I_2.1.8.20120216.CAB|Windows CE|Installer(ARMV4I)}}&lt;br /&gt;
{{ExtraLibraryQuickDownloads|http://www.phidgets.com/downloads/libraries/Phidget21x86_2.1.8.20120216.CAB|Windows CE|Installer(x86)}}&lt;br /&gt;
{{ExtraLibraryQuickDownloads|http://www.phidgets.com/downloads/libraries/Phidget21MIPSII_2.1.8.20120216.CAB|Windows CE|Installer(MIPSII)}}&lt;br /&gt;
}}&lt;br /&gt;
The source code for the Phidget Kernel driver for Windows CE is also provided:&lt;br /&gt;
* [http://www.phidgets.com/downloads/libraries/Phidget21CEkernalsource_2.1.8.20120216.zip Kernel Driver Source(all architectures)]&lt;br /&gt;
&lt;br /&gt;
==Getting started with Visual Basic(.NET Compact Framework)==&lt;br /&gt;
&lt;br /&gt;
If you are new to writing code for Phidgets, we recommend starting by running, then modifying existing examples. This will allow you to:&lt;br /&gt;
{{ExampleCodeReasons}}&lt;br /&gt;
&lt;br /&gt;
To develop applications on Windows CE, you will need a Windows(2000/XP/Vista/7) system in order to perform development on. The drivers can be easily installed onto the Windows CE system by using the installers in the [[#Libraries and Drivers | Libraries and Drivers]] section. You will also need the (.NET Compact Framework Libraries) on your development system to code against.&lt;br /&gt;
&lt;br /&gt;
==Windows (2000/XP/Vista/7)==&lt;br /&gt;
&lt;br /&gt;
===Description of Library Files===&lt;br /&gt;
Visual Basic(.NET Compact Framework) programs on Windows depend on the following files, which the installers above put onto your system:&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|phidget21.dll}}&amp;lt;/b&amp;gt; contains the actual Phidget library, which is used at run-time.  &lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|phidget.dll}}&amp;lt;/b&amp;gt; is the Phidgets kernel driver.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|Phidget21CE.NET.dll}}&amp;lt;/b&amp;gt; is the .NET(Compact Framework) Phidgets library.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|PhidgetWebService21.exe}}&amp;lt;/b&amp;gt; is used to control Phidgets remotely across a network using the [[#WebService | PhidgetWebservce]].&lt;br /&gt;
&lt;br /&gt;
If you do not want to use our installer, you can download the [http://www.phidgets.com/downloads/libraries/Phidget21-wincedevel_2.1.8.20120216.zip files]. Inside the zip file, please use the files that pertain to your architecture. These files should be placed in the {{Code|\Windows}} folder.&lt;br /&gt;
&lt;br /&gt;
===Visual Studio 2005/2008/2010===&lt;br /&gt;
&lt;br /&gt;
=====Use Our Examples=====&lt;br /&gt;
&lt;br /&gt;
We will start by downloading the examples and building an executable for them on the development machine. Visual Studio will be used for development. We will then transfer the executable onto the Windows CE machine to run.&lt;br /&gt;
&lt;br /&gt;
Please start by downloading the [http://www.phidgets.com/downloads/examples/CE_2.1.8.20120216.zip examples] and unpack them into a folder.  While these examples were written in Visual Studio 2005 and 2008, Visual Studio 2010 will easily open and upgrade them. &lt;br /&gt;
&lt;br /&gt;
If you are opening the Phidget examples in Visual Studio 2010, you will need to go through the Visual Studio Conversion Wizard to convert the 2005 or 2008 project. &lt;br /&gt;
[[File:VS2005 Conversion Wizard.PNG|link=|alt=Conversion Wizard]]&lt;br /&gt;
&lt;br /&gt;
The easiest way to confirm that your environment is set up properly will be to compile and run the {{Code|HelloWorld}} Visual Basic(.NET Compact Framework) example.&lt;br /&gt;
&lt;br /&gt;
Next, build the example project. Right click the {{Code|HelloWorld}} project and select {{Code|Build}} to create an executable. &lt;br /&gt;
&lt;br /&gt;
[[File:VS2008 VBNETCompact Build.PNG|link=|alt=Build]]&lt;br /&gt;
&lt;br /&gt;
Then in Windows Explorer, navigate to the {{Code|project directory\bin\Debug}} folder if you are are targeting a debug configuration. The folder will be {{Code|project directory\bin\Release}} if you are targeting a release configuration. Regardless of whether you are targeting debug or release, you will find an executable named {{Code|HelloWorld.exe}}. Transfer this file onto the Windows CE system. &lt;br /&gt;
&lt;br /&gt;
The only thing left to do is to run the example! Double click on the executable on the Windows CE system to run it. &lt;br /&gt;
&lt;br /&gt;
This program will detect for devices that are attached/detached on the computer. Go ahead, and attach or detach your devices! &lt;br /&gt;
&lt;br /&gt;
After confirming that the {{Code|HelloWorld}} example is working, you can proceed to run the example for your device. If you aren&#039;t sure what the software example for your device is called, check the software object listed in the [[Device List | Getting Started Guide for your Device]]. Currently, the only devices we have example code is for the PhidgetInterfaceKit, PhidgetRFID, PhidgetTextLCD. Please ensure that you have set your start up project to be the one that matches your device before compiling. &lt;br /&gt;
&lt;br /&gt;
Once you have the Visual Basic(.NET Compact Framework) examples running, we have a [[#Follow the Examples|teaching]] section below to help you follow them.&lt;br /&gt;
&lt;br /&gt;
=====Write Your Own Code=====&lt;br /&gt;
&lt;br /&gt;
On the development computer, when you are building a project from scratch, or adding Phidget function calls to an existing project, you&#039;ll need to configure your environment to properly link the Phidget Visual Basic(.NET Compact Framework) libraries. To begin: &lt;br /&gt;
&lt;br /&gt;
1. Generate a new smart device Visual Basic Console Applications project with a descriptive name such as PhidgetTest. &lt;br /&gt;
&lt;br /&gt;
[[File:VS2008 VBNETCompact New Project 1.PNG|link=|alt=New Project]]&lt;br /&gt;
&lt;br /&gt;
[[File:VS2008 VBNETCompact New Project 2.PNG|link=|alt=New Project]]&lt;br /&gt;
&lt;br /&gt;
2. Add a reference to the Phidget .NET library.&lt;br /&gt;
&lt;br /&gt;
[[File:VS2008 VBNETCompact Add Reference 1.PNG|link=|alt=Add Reference]]&lt;br /&gt;
&lt;br /&gt;
3. Download the [http://www.phidgets.com/downloads/libraries/Phidget21-wincedevel_2.1.8.20120216.zip {{Code|Phidget21CE.NET.dll}}] file. The file is contained in the zip file. &lt;br /&gt;
&lt;br /&gt;
4. Under the .NET tab, select {{Code|Phidget21CE.NET.dll}}.&lt;br /&gt;
&lt;br /&gt;
[[File:VS2008 VBNETCompact Add Reference 2.PNG|link=|alt=Add Reference]]&lt;br /&gt;
&lt;br /&gt;
5. Then, in your code, you will need to include the Phidget .NET library:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=csharp&amp;gt;&lt;br /&gt;
  using Phidgets;&lt;br /&gt;
  using Phidgets.Events;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The project now has access to the Phidget function calls and you are ready to begin coding.&lt;br /&gt;
&lt;br /&gt;
The same [[#Follow the Examples|teaching ]] section which describes the examples also has further resources for programming your Phidget.&lt;br /&gt;
&lt;br /&gt;
==Follow the Examples==&lt;br /&gt;
&lt;br /&gt;
By following the instructions for your operating system and compiler above, you probably now have a working example and want to understand it better so you can change it to do what you want.  This teaching section has resources for you to learn from the examples and write your own.&lt;br /&gt;
&lt;br /&gt;
Next, comes our API information.  These resources outline the Visual Basic(.NET Compact Framework) Phidget functions:&lt;br /&gt;
&lt;br /&gt;
{{UsingAPhidgetInCodeGeneral|both of which are available in Visual Basic|[http://www.phidgets.com/documentation/Phidget21.NET.zip .NET API]}}&lt;br /&gt;
&lt;br /&gt;
Here, you can find further examples. Coding in Visual Basic(.NET Compact Framework) is very similar to coding in Visual Basic, so you can take a look at our resources on the [[#Language - Visual Basic .NET | section]].&lt;br /&gt;
&lt;br /&gt;
===Example Flow===&lt;br /&gt;
&lt;br /&gt;
{{ExamplePseudocode|In Visual Basic(.NET Compact Framework), you can name these &#039;&#039;&#039;event&#039;&#039;&#039; functions whatever you like.  You will then pass them as function pointers to the Phidget .NET library below in the Main Code section.  This hooks them into the actual events when they occur. &amp;lt;br&amp;gt; &lt;br /&gt;
In the example code, the event functions common to all Phidgets are called things like &#039;&#039;&#039;AttachHandler()&#039;&#039;&#039; and &#039;&#039;&#039;DetachHandler()&#039;&#039;&#039;, etc.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Some event functions will be specific to each device, like when a tag is read on an RFID board, or when a sensor value changes on an Interface Kit.&lt;br /&gt;
Other functions are given in the examples to show you more detail on using your Phidget.  For example, &#039;&#039;&#039;DeviceInitialize()&#039;&#039;&#039; will show what needs to be set up for your Phidget before using it.&lt;br /&gt;
|Creating a Phidget software object in Visual Basic(.NET Compact Framework) is specific to the Phidget.  For a Phidget Spatial, for example, this would involve creating a {{Code|Spatial}} object.  The examples show how to do this and other API functions.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
The object provides device specific methods and properties which are available from the API for your specific Phidget.|&lt;br /&gt;
[http://www.phidgets.com/documentation/Phidget21.NET.zip .NET API]}}&lt;br /&gt;
&lt;br /&gt;
==Code Snippets==&lt;br /&gt;
&lt;br /&gt;
==Common Problems and Solutions/Workarounds==&lt;br /&gt;
&lt;br /&gt;
==={{ProblemSolution|All Operating Systems|The Phidgets.Events.ErrorEventHandler conflicts with System.IO.ErrorEventHandler.}}===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=csharp&amp;gt;&lt;br /&gt;
using System.IO;&lt;br /&gt;
using Phidgets;&lt;br /&gt;
using Phidgets.Events;&lt;br /&gt;
...&lt;br /&gt;
spatial.Error += new ErrorEventHandler(spatial_Error);&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
void spatial_Error(object sender, ErrorEventArgs e){&lt;br /&gt;
   ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above code produces the following errors:&lt;br /&gt;
&lt;br /&gt;
{{Code|&#039;ErrorEventHandler&#039; is an ambiguous reference between &#039;System.IO.ErrorEventHandler&#039; and &#039;Phidgets.Events.ErrorEventHandler&#039;}}.&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
{{Code|&#039;ErrorEventArgs&#039; is an ambiguous reference between &#039;System.IO.ErrorEventArgs&#039; and &#039;Phidgets.Events.ErrorEventArgs&#039;}}.&lt;br /&gt;
&lt;br /&gt;
The error is due to the {{Code|System.IO}} and {{Code|Phidgets.Events}} namespaces both having a class called {{Code|ErrorEventHandler}}.&lt;br /&gt;
&lt;br /&gt;
To get around this issue, use the fully qualified namespace when referring to the {{Code|ErrorEventHandler}} and {{Code|ErrorEventArgs}} classes:&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=csharp&amp;gt;&lt;br /&gt;
using System.IO;&lt;br /&gt;
using Phidgets;&lt;br /&gt;
using Phidgets.Events;&lt;br /&gt;
...&lt;br /&gt;
spatial.Error += new Phidgets.Events.ErrorEventHandler(spatial_Error);&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
void spatial_Error(object sender, Phidgets.Events.ErrorEventArgs e){&lt;br /&gt;
   ...&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;/div&gt;</summary>
		<author><name>Djrudiak</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=Language_-_C_Sharp_(.NET_Compact_Framework)&amp;diff=19160</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=19160"/>
		<updated>2012-04-20T17:33:38Z</updated>

		<summary type="html">&lt;p&gt;Djrudiak: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Language]]&lt;br /&gt;
{{OSLang|[[File:icon-CSharp.png|64x64px|link=|alt=]]|C#(.NET Compact Framework) is a modern, object-oriented programming language developed by [[http://www.microsoft.com Microsoft]] intended for developing applications for smart devices.}}&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
{{LanguageSupport|C#(.NET Compact Framework)|the complete Phidget API, including events|all Phidget devices.|the .NET Compact Framework. This frameworks is supported on devices with the Windows CE operating system. We provide instructions on how to set up your environment/compilers for [[#Visual Studio 2005/2008/2010 | Visual Studio 2005/2008/2010]]|}}&lt;br /&gt;
&lt;br /&gt;
==Quick Downloads==&lt;br /&gt;
{{QuickDownloads|C#(.NET Compact Framework)|&lt;br /&gt;
{{APIQuickDownloads|http://www.phidgets.com/documentation/Phidget21.NET.zip .NET}}|&lt;br /&gt;
{{ExampleQuickDownloads|http://www.phidgets.com/downloads/examples/CE_2.1.8.20120216.zip|}}|&lt;br /&gt;
{{ExtraLibraryQuickDownloads|http://www.phidgets.com/downloads/libraries/Phidget21-wincedevel_2.1.8.20120216.zip|Phidget Windows CE|(all architectures)}}&lt;br /&gt;
{{ExtraLibraryQuickDownloads|http://www.phidgets.com/downloads/libraries/Phidget21ARMV4I_2.1.8.20120216.CAB|Windows CE|Installer(ARMV4I)}}&lt;br /&gt;
{{ExtraLibraryQuickDownloads|http://www.phidgets.com/downloads/libraries/Phidget21x86_2.1.8.20120216.CAB|Windows CE|Installer(x86)}}&lt;br /&gt;
{{ExtraLibraryQuickDownloads|http://www.phidgets.com/downloads/libraries/Phidget21MIPSII_2.1.8.20120216.CAB|Windows CE|Installer(MIPSII)}}&lt;br /&gt;
}}&lt;br /&gt;
The source code for the Phidget Kernel driver for Windows CE is also provided:&lt;br /&gt;
* [http://www.phidgets.com/downloads/libraries/Phidget21CEkernalsource_2.1.8.20120216.zip Kernel Driver Source(all architectures)]&lt;br /&gt;
&lt;br /&gt;
==Getting started with C#(.NET Compact Framework)==&lt;br /&gt;
&lt;br /&gt;
If you are new to writing code for Phidgets, we recommend starting by running, then modifying existing examples. This will allow you to:&lt;br /&gt;
{{ExampleCodeReasons}}&lt;br /&gt;
&lt;br /&gt;
To develop applications on Windows CE, you will need a Windows(2000/XP/Vista/7) system in order to perform development on. The drivers can be easily installed onto the Windows CE system by using the installers in the [[#Libraries and Drivers | Libraries and Drivers]] section. You will also need the (.NET Compact Framework Libraries) on your development system to code against.&lt;br /&gt;
&lt;br /&gt;
==Windows (2000/XP/Vista/7)==&lt;br /&gt;
&lt;br /&gt;
===Description of Library Files===&lt;br /&gt;
C#(.NET Compact Framework) programs on Windows depend on the following files, which the installers above put onto your system:&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|phidget21.dll}}&amp;lt;/b&amp;gt; contains the actual Phidget library, which is used at run-time.  &lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|phidget.dll}}&amp;lt;/b&amp;gt; is the Phidgets kernel driver.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|Phidget21CE.NET.dll}}&amp;lt;/b&amp;gt; is the .NET(Compact Framework) Phidgets library.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|PhidgetWebService21.exe}}&amp;lt;/b&amp;gt; is used to control Phidgets remotely across a network using the [[#WebService | PhidgetWebservce]].&lt;br /&gt;
&lt;br /&gt;
If you do not want to use our installer, you can download the [http://www.phidgets.com/downloads/libraries/Phidget21-wincedevel_2.1.8.20120216.zip files]. Inside the zip file, please use the files that pertain to your architecture. These files should be placed in the {{Code|\Windows}} folder.&lt;br /&gt;
&lt;br /&gt;
===Visual Studio 2005/2008/2010===&lt;br /&gt;
&lt;br /&gt;
=====Use Our Examples=====&lt;br /&gt;
&lt;br /&gt;
We will start by downloading the examples and building an executable for them on the development machine. Visual Studio will be used for development. We will then transfer the executable onto the Windows CE machine to run.&lt;br /&gt;
&lt;br /&gt;
Please start by downloading the [http://www.phidgets.com/downloads/examples/CE_2.1.8.20120216.zip examples] and unpack them into a folder.  While these examples were written in Visual Studio 2005 and 2008, Visual Studio 2010 will easily open and upgrade them. To load all projects in Visual Studio, go to File &amp;amp;rarr; Open &amp;amp;rarr; Project, and open {{Code|WindowsCE.NET Examples.sln}} or {{Code|WindowsCE.NET Examples_vs2008.sln}} for Visual Studio 2005 and 2008, respectively.&lt;br /&gt;
&lt;br /&gt;
If you are opening the Phidget examples in Visual Studio 2010, you will need to go through the Visual Studio Conversion Wizard to convert the 2005 or 2008 project. &lt;br /&gt;
[[File:VS2005 Conversion Wizard.PNG|link=|alt=Conversion Wizard]]&lt;br /&gt;
&lt;br /&gt;
The easiest way to confirm that your environment is set up properly will be to compile and run the {{Code|HelloWorld}} C#(.NET Compact Framework) example.&lt;br /&gt;
&lt;br /&gt;
Start by setting the {{Code|HelloWorld}} project as your start up project.&lt;br /&gt;
&lt;br /&gt;
Next, build the example project. Right click the {{Code|HelloWorld}} project and select {{Code|Build}} to create an executable. &lt;br /&gt;
&lt;br /&gt;
[[File:VS2005 CSharpCompact Build.PNG|link=|alt=Build]]&lt;br /&gt;
&lt;br /&gt;
Then in Windows Explorer, navigate to the {{Code|project directory\bin\Debug}} folder if you are are targeting a debug configuration. The folder will be {{Code|project directory\bin\Release}} if you are targeting a release configuration. Regardless of whether you are targeting debug or release, you will find an executable named {{Code|HelloWorld.exe}}. Transfer this file onto the Windows CE system. &lt;br /&gt;
&lt;br /&gt;
The only thing left to do is to run the example! Double click on the executable on the Windows CE system to run it. &lt;br /&gt;
&lt;br /&gt;
This program will detect for devices that are attached/detached on the computer. Go ahead, and attach or detach your devices! &lt;br /&gt;
&lt;br /&gt;
After confirming that the {{Code|HelloWorld}} example is working, you can proceed to run the example for your device. If you aren&#039;t sure what the software example for your device is called, check the software object listed in the [[Device List | Getting Started Guide for your Device]]. Currently, the only devices we have example code is for the PhidgetInterfaceKit, PhidgetRFID, PhidgetTextLCD. Please ensure that you have set your start up project to be the one that matches your device before compiling. &lt;br /&gt;
&lt;br /&gt;
Once you have the C#(.NET Compact Framework) examples running, we have a [[#Follow the Examples|teaching]] section below to help you follow them.&lt;br /&gt;
&lt;br /&gt;
=====Write Your Own Code=====&lt;br /&gt;
&lt;br /&gt;
On the development computer, when you are building a project from scratch, or adding Phidget function calls to an existing project, you&#039;ll need to configure your environment to properly link the Phidget C#(.NET Compact Framework) libraries. To begin: &lt;br /&gt;
&lt;br /&gt;
1. Generate a new smart device Windows CE C# Console Applications project with a descriptive name such as PhidgetTest. &lt;br /&gt;
&lt;br /&gt;
[[File:VS2005 CSharpCompact New Project.PNG|link=|alt=New Project]]&lt;br /&gt;
&lt;br /&gt;
2. Add a reference to the Phidget .NET library.&lt;br /&gt;
&lt;br /&gt;
[[File:VS2005 CSharpCompact Add Reference 1.PNG|link=|alt=Add Reference]]&lt;br /&gt;
&lt;br /&gt;
3. Download the [http://www.phidgets.com/downloads/libraries/Phidget21-wincedevel_2.1.8.20120216.zip {{Code|Phidget21CE.NET.dll}}] file. The file is contained in the zip file. &lt;br /&gt;
&lt;br /&gt;
4. Under the .NET tab, select {{Code|Phidget21CE.NET.dll}}.&lt;br /&gt;
&lt;br /&gt;
[[File:VS2005 CSharpCompact Add Reference 2.PNG|link=|alt=Add Reference]]&lt;br /&gt;
&lt;br /&gt;
5. Then, in your code, you will need to include the Phidget .NET library:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=csharp&amp;gt;&lt;br /&gt;
  using Phidgets;&lt;br /&gt;
  using Phidgets.Events;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The project now has access to the Phidget function calls and you are ready to begin coding.&lt;br /&gt;
&lt;br /&gt;
The same [[#Follow the Examples|teaching ]] section which describes the examples also has further resources for programming your Phidget.&lt;br /&gt;
&lt;br /&gt;
==Follow the Examples==&lt;br /&gt;
&lt;br /&gt;
By following the instructions for your operating system and compiler above, you probably now have a working example and want to understand it better so you can change it to do what you want.  This teaching section has resources for you to learn from the examples and write your own.&lt;br /&gt;
&lt;br /&gt;
Next, comes our API information.  These resources outline the C#(.NET Compact Framework) Phidget functions:&lt;br /&gt;
&lt;br /&gt;
{{UsingAPhidgetInCodeGeneral|both of which are available in C#|[http://www.phidgets.com/documentation/Phidget21.NET.zip .NET API]}}&lt;br /&gt;
&lt;br /&gt;
Here, you can find further examples. Coding in C#(.NET Compact Framework) is very similar to coding in C#, so you can take a look at our resources on the [[#Language - C Sharp | C# section]].&lt;br /&gt;
&lt;br /&gt;
===Example Flow===&lt;br /&gt;
&lt;br /&gt;
{{ExamplePseudocode|In C#(.NET Compact Framework), you can name these &#039;&#039;&#039;event&#039;&#039;&#039; functions whatever you like.  You will then pass them as function pointers to the Phidget .NET library below in the Main Code section.  This hooks them into the actual events when they occur. &amp;lt;br&amp;gt; &lt;br /&gt;
In the example code, the event functions common to all Phidgets are called things like &#039;&#039;&#039;AttachHandler()&#039;&#039;&#039; and &#039;&#039;&#039;DetachHandler()&#039;&#039;&#039;, etc.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Some event functions will be specific to each device, like when a tag is read on an RFID board, or when a sensor value changes on an Interface Kit.&lt;br /&gt;
Other functions are given in the examples to show you more detail on using your Phidget.  For example, &#039;&#039;&#039;DeviceInitialize()&#039;&#039;&#039; will show what needs to be set up for your Phidget before using it.&lt;br /&gt;
|Creating a Phidget software object in C#(.NET Compact Framework) is specific to the Phidget.  For a Phidget Spatial, for example, this would involve creating a {{Code|Spatial}} object.  The examples show how to do this and other API functions.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
The object provides device specific methods and properties which are available from the API for your specific Phidget.|&lt;br /&gt;
[http://www.phidgets.com/documentation/Phidget21.NET.zip .NET API]}}&lt;br /&gt;
&lt;br /&gt;
==Code Snippets==&lt;br /&gt;
&lt;br /&gt;
==Common Problems and Solutions/Workarounds==&lt;br /&gt;
&lt;br /&gt;
==={{ProblemSolution|All Operating Systems|The Phidgets.Events.ErrorEventHandler conflicts with System.IO.ErrorEventHandler.}}===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=csharp&amp;gt;&lt;br /&gt;
using System.IO;&lt;br /&gt;
using Phidgets;&lt;br /&gt;
using Phidgets.Events;&lt;br /&gt;
...&lt;br /&gt;
spatial.Error += new ErrorEventHandler(spatial_Error);&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
void spatial_Error(object sender, ErrorEventArgs e){&lt;br /&gt;
   ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above code produces the following errors:&lt;br /&gt;
&lt;br /&gt;
{{Code|&#039;ErrorEventHandler&#039; is an ambiguous reference between &#039;System.IO.ErrorEventHandler&#039; and &#039;Phidgets.Events.ErrorEventHandler&#039;}}.&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
{{Code|&#039;ErrorEventArgs&#039; is an ambiguous reference between &#039;System.IO.ErrorEventArgs&#039; and &#039;Phidgets.Events.ErrorEventArgs&#039;}}.&lt;br /&gt;
&lt;br /&gt;
The error is due to the {{Code|System.IO}} and {{Code|Phidgets.Events}} namespaces both having a class called {{Code|ErrorEventHandler}}.&lt;br /&gt;
&lt;br /&gt;
To get around this issue, use the fully qualified namespace when referring to the {{Code|ErrorEventHandler}} and {{Code|ErrorEventArgs}} classes:&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=csharp&amp;gt;&lt;br /&gt;
using System.IO;&lt;br /&gt;
using Phidgets;&lt;br /&gt;
using Phidgets.Events;&lt;br /&gt;
...&lt;br /&gt;
spatial.Error += new Phidgets.Events.ErrorEventHandler(spatial_Error);&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
void spatial_Error(object sender, Phidgets.Events.ErrorEventArgs e){&lt;br /&gt;
   ...&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;/div&gt;</summary>
		<author><name>Djrudiak</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=Language_-_Max/MSP&amp;diff=19159</id>
		<title>Language - Max/MSP</title>
		<link rel="alternate" type="text/html" href="https://www.phidgets.com/docs21/index.php?title=Language_-_Max/MSP&amp;diff=19159"/>
		<updated>2012-04-20T17:28:21Z</updated>

		<summary type="html">&lt;p&gt;Djrudiak: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Language]]&lt;br /&gt;
{{OSLang|[[File:icon-MaxMSP.png|link=|alt=MaxMSP|64x64px]]|Max/MSP, developed by [http://cycling74.com Cycling74] is a visual programming language for creating music and media applications.}}&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
{{LanguageSupport|Max/MSP|most of the Phidget API, including events. All the supported functions for Max/MSP will be documented in the {{Code|.help}} files|all Phidget devices.| Windows and OS X|&lt;br /&gt;
&lt;br /&gt;
Only Max/MSP 4.5 or higher is supported.}}&lt;br /&gt;
&lt;br /&gt;
==Quick Downloads==&lt;br /&gt;
{{QuickDownloads|Max/MSP|&lt;br /&gt;
* [http://www.phidgets.com/downloads/examples/WinMaxMSP_2.1.8.20120123.zip {{Code|.help}} file(Windows - same file as Max/MSP Examples and Libraries)]&lt;br /&gt;
* [http://www.phidgets.com/downloads/examples/WinMaxMSP_2.1.8.20120123.zip {{Code|.help}} file(OS X - same file as Max/MSP Examples and Libraries)]|&lt;br /&gt;
{{ExampleQuickDownloads|http://www.phidgets.com/downloads/examples/WinMaxMSP_2.1.8.20120123.zip|(Windows - same file as Max/MSP Documentation and Libraries)}}&lt;br /&gt;
{{ExampleQuickDownloads|http://www.phidgets.com/downloads/examples/WinMaxMSP_2.1.8.20120123.zip|(OS X - same file as Max/MSP Documentation and Libraries)}}|{{ExtraLibraryQuickDownloads|http://www.phidgets.com/downloads/examples/WinMaxMSP_2.1.8.20120123.zip|Max/MSP|(Windows - same file as Max/MSP Documentation and Examples)}}&lt;br /&gt;
{{ExtraLibraryQuickDownloads|http://www.phidgets.com/downloads/examples/WinMaxMSP_2.1.8.20120123.zip|Max/MSP|(OS X - same file as Max/MSP Documentation and Examples)}}&lt;br /&gt;
{{WindowsQuickDownloads}}&lt;br /&gt;
{{MacQuickDownloads}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Getting started with Max/MSP==&lt;br /&gt;
&lt;br /&gt;
If you are new to writing code for Phidgets, we recommend starting by running, then modifying existing examples. This will allow you to:&lt;br /&gt;
{{ExampleCodeReasons}}&lt;br /&gt;
&lt;br /&gt;
Instructions are divided up by operating system. Choose:&lt;br /&gt;
*[[#Windows(2000/XP/Vista/7)|Windows 2000 / XP / Vista / 7]]&lt;br /&gt;
*[[#OS X |OS X]]&lt;br /&gt;
&lt;br /&gt;
==Windows (2000/XP/Vista/7)==&lt;br /&gt;
  &lt;br /&gt;
===Description of Library Files===&lt;br /&gt;
Max/MSP programs on Windows depend on the following files. The installers in the [[#Libraries and Drivers | Quick Downloads]] section put only the {{Code|phidget21.dll}} into your system. You will need to manually put the {{Code|PhidgetXXX.mxe}} onto your system. &lt;br /&gt;
* &amp;lt;b&amp;gt;&amp;lt;code&amp;gt;phidget21.dll&amp;lt;/code&amp;gt;&amp;lt;/b&amp;gt; contains the actual Phidget library, which is used at run-time. By default, the installer places it in &amp;lt;code&amp;gt;C:\Windows\System32&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &amp;lt;b&amp;gt;&amp;lt;code&amp;gt;PhidgetXXX.mxe&amp;lt;/code&amp;gt;&amp;lt;/b&amp;gt; is the Phidget library for your specific device. XXX denotes the name of your device, Please make sure the &amp;lt;code&amp;gt;.mxe&amp;lt;/code&amp;gt; file corresponds with the device you are using. For example, if you are using the PhidgetInterfaceKit, you will need the {{Code|PhidgetInterfaceKit.mxe}}. It is to be placed in the same directory as your Max/MSP application or anywhere in the Max/MSP search path.&lt;br /&gt;
&lt;br /&gt;
If you do not want to use our installer, you can download the {{Code|[http://www.phidgets.com/downloads/libraries/phidget21-x86_2.1.8.20110615.zip phidget21.dll]}} and manually install it where you want; refer to our [[OS_-_Windows#Manual_File_Installation|Manual Installation Instructions]].&lt;br /&gt;
&lt;br /&gt;
===Use Our Examples===&lt;br /&gt;
&lt;br /&gt;
Please start by downloading the [http://www.phidgets.com/downloads/examples/WinMaxMSP_2.1.8.20120123.zip  Max/MSP Examples and Library] and unpack them into a folder.  These examples were written in Max/MSP 4.6, but any version above 4.5 are also supported.&lt;br /&gt;
&lt;br /&gt;
Here, you will find example programs, in {{code | .help}} format for all the devices. If you aren&#039;t sure what the software example for your device is called, check the software object listed in the [[Device List | Getting Started guide for your device]].&lt;br /&gt;
&lt;br /&gt;
The only thing left to do is to run the examples! Open the {{code| .help}} file in the Max environment.&lt;br /&gt;
&lt;br /&gt;
Once you have the Max/MSP examples running, we have a [[#Follow the Examples|teaching]] section below to help you follow them.&lt;br /&gt;
&lt;br /&gt;
===Write Your Own Code===&lt;br /&gt;
&lt;br /&gt;
When you are building a project from scratch, or adding Phidget function calls to an existing project, you&#039;ll need to configure the Max/MSP environment to properly link the Phidget Max/MSP libraries. To begin: &lt;br /&gt;
&lt;br /&gt;
Place the {{Code|.mxe}} in the same directory as the patcher, or anywhere in the Max/MSP search path. You can verify the search path locations by navigating to Options &amp;amp;rarr; File Preferences. &lt;br /&gt;
&lt;br /&gt;
[[File:MaxMSP Path.PNG|link=|alt=Search Path]]&lt;br /&gt;
&lt;br /&gt;
The best way to start writing your patch is to modify an example, and saving it as a {{Code|.pat}} file.&lt;br /&gt;
&lt;br /&gt;
If you wish to start a new patch. All you need to do is create an object named PhidgetXXX where XXX is the name of your device. For example, the [[Product - 1023 1 - PhidgetRFID | PhidgetRFID device]] will have the {{Code|PhidgetRFID}} object name. &lt;br /&gt;
The project now has access to the Phidget function calls and you are ready to begin coding.&lt;br /&gt;
&lt;br /&gt;
The same [[#Follow the Examples|teaching]] section which describes the examples also has further resources for programming your Phidget.&lt;br /&gt;
&lt;br /&gt;
==OS X==&lt;br /&gt;
&lt;br /&gt;
Max/MSP has excellent support on OS X.&lt;br /&gt;
&lt;br /&gt;
The first step in using Max/MSP on Mac is to install the Phidget library.  Compile and install them as explained on the [[Device List|getting started guide for your device]].  Then, the [[OS - OS X]] page also describes the different Phidget files, their installed locations, and their roles....&lt;br /&gt;
&lt;br /&gt;
==Follow the Examples==&lt;br /&gt;
&lt;br /&gt;
By following the instructions for your operating system, you probably now have a working example and want to understand it better so you can change it to do what you want.  This teaching section has resources for you to learn from the examples and write your own.&lt;br /&gt;
&lt;br /&gt;
First, let&#039;s explain how to operate the example. &lt;br /&gt;
&lt;br /&gt;
[[File:MaxMSP Example.PNG|link=|alt=Example]]&lt;br /&gt;
&lt;br /&gt;
The above screenshot is what shows up when you open the example for the PhidgetInterfaceKit. If you are using a different device, your example patch will be different, but the idea is the same.&lt;br /&gt;
&lt;br /&gt;
For this particular example, the Max object is called {{Code|PhidgetInterfaceKit}}, which is located in the center of the screen. Objects/message boxes are connected to the inputs and outputs of the PhidgetInterfaceKit object. The input objects will either cause a property of the device to change or request for a property to be retrieved. The output objects return the retrieved information. All the supported features of the device are shown in the {{Code|.help}} file. &lt;br /&gt;
&lt;br /&gt;
Try it for yourself! Click on the {{Code | getSerial}} message box to request the Phidget to retrieve the serial number of the device. You should see the last output object of {{Code|route}} changed to the serial number of your device. All devices support the {{Code|getSerial}} object, and is the easiest way to determine if the Phidget libraries are correctly set up, and whether the Max/MSP application is connected to your device.&lt;br /&gt;
&lt;br /&gt;
[[File:MaxMSP getSerial.PNG|link=|alt=getSerial]]&lt;br /&gt;
&lt;br /&gt;
If your example contains the {{Code|read}} message box, click on it. This will return device specific values to the screen.&lt;br /&gt;
&lt;br /&gt;
[[File:MaxMSP read.PNG|link=|alt=Read Data]]&lt;br /&gt;
&lt;br /&gt;
If your example contains the {{Code|start}} message box, you can continuously poll for events. Set the sample rate input for the {{Code|setSampleRate}} object. Then, press the {{Code|start}} message box to start sampling. When a noteworthy event occurs on a Phidget(i.e., when an analog sensor senses a change in the environment), the value will be displayed onto the screen. Press the {{Code|stop}} message box to stop sampling.&lt;br /&gt;
&lt;br /&gt;
For the PhidgetInterfaceKit example, there also a {{Code|setoutput}} message box. Clicking on the check boxes will cause the digital outputs of the PhidgetInterfaceKit device to change. Your example may contain device specific message boxes/objects to click on. See for yourself what they do!&lt;br /&gt;
&lt;br /&gt;
For information regarding calls specific to your device, please see the [[Device List | API for your specific device]]. Please note that some device functionality are not supported in Max/MSP; the {{Code|.help}} example shows the complete list of functionality supported under Max/MSP.&lt;br /&gt;
&lt;br /&gt;
==Code Snippets==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
openRemote object&lt;br /&gt;
&lt;br /&gt;
multiple phidgets&lt;br /&gt;
&lt;br /&gt;
==Common Problems and Solutions/Workarounds==&lt;br /&gt;
&lt;br /&gt;
{{ProblemSolution|Crash|When a patch file is closed in the Max/MSP environment, the program crashes}}&lt;br /&gt;
&lt;br /&gt;
If in your Max/MSP environment, you have more patches(of the same Phidget object) than you have of the actual hardware device, the Max/MSP environment may crash. This is due to the fact that a single Phidget Max/MSP object &amp;lt;i&amp;gt;only&amp;lt;/i&amp;gt; corresponds to a single Phidget device hardware. For example, your Max/MSP environment may experience unexpected behavior while you have one PhidgetInterfaceKit device connected to the computer, but you have a two seperate patches opened with a single PhidgetInterfaceKit Max object in each one.&lt;br /&gt;
&lt;br /&gt;
Likely Fix: Please ensure that you do not use more patches(of the same Phidget object) than you have of the actual Phidget device.&lt;/div&gt;</summary>
		<author><name>Djrudiak</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=Language_-_LiveCode&amp;diff=19158</id>
		<title>Language - LiveCode</title>
		<link rel="alternate" type="text/html" href="https://www.phidgets.com/docs21/index.php?title=Language_-_LiveCode&amp;diff=19158"/>
		<updated>2012-04-20T17:27:36Z</updated>

		<summary type="html">&lt;p&gt;Djrudiak: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Language]]&lt;br /&gt;
{{OSLang|[[File:icon-LiveCode.png|link=|alt=LiveCode|64x64px]]|LiveCode is a high level programming language, developed by [[http://www.runrev.com RunRev]] that draws on English-like syntax for rapid application development.}}&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
{{LanguageSupport|LiveCode|only the PhidgetInterfaceKit API, including events|the PhidgetInterfaceKit.|Windows and OS X |&lt;br /&gt;
&lt;br /&gt;
If you wish to use other devices with LiveCode, we have a [[#Extending LiveCode to other Phidgets | guide ]] providing instructions to do so.}}&lt;br /&gt;
&lt;br /&gt;
==Quick Downloads==&lt;br /&gt;
{{QuickDownloads|LiveCode|&lt;br /&gt;
{{APIQuickDownloads|http://www.phidgets.com/documentation/LiveCode_API_Manual.pdf}}|&lt;br /&gt;
{{ExampleQuickDownloads|http://www.phidgets.com/downloads/examples/LiveCode_2.1.8.20111220.zip|}}|&lt;br /&gt;
{{ExtraLibraryQuickDownloads|http://www.phidgets.com/downloads/libraries/LiveCodeRequiredWin_2.1.8.20111220.zip|LiveCode Library|(Windows)}}&lt;br /&gt;
{{ExtraLibraryQuickDownloads|http://www.phidgets.com/downloads/libraries/LiveCodeRequiredMac_2.1.8.20111220.zip|LiveCode Library|(OS X)}}&lt;br /&gt;
{{WindowsQuickDownloads}}&lt;br /&gt;
{{MacQuickDownloads}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Getting started with LiveCode==&lt;br /&gt;
&lt;br /&gt;
If you are new to writing code for Phidgets, we recommend starting by running, then modifying existing examples. This will allow you to:&lt;br /&gt;
{{ExampleCodeReasons}}&lt;br /&gt;
&lt;br /&gt;
Instructions are divided up by operating system. Choose:&lt;br /&gt;
*[[#Windows(2000/XP/Vista/7)|Windows 2000 / XP / Vista / 7]]&lt;br /&gt;
*[[#OS X |OS X]]&lt;br /&gt;
&lt;br /&gt;
==Windows (2000/XP/Vista/7)==&lt;br /&gt;
&lt;br /&gt;
===Description of Library Files===&lt;br /&gt;
LiveCode on Windows depend on three files. The installers in the [[#Libraries and Drivers | Quick Downloads]] section put only the {{Code|phidget21.dll}} into your system. You will need to manually put the remaining two files into your system&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|phidget21.dll}}&amp;lt;/b&amp;gt; contains the actual Phidget library, which is used at run-time.  By default, it is placed in {{Code|C:\Windows\System32}}.  &lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|phidgets_livecode.dll}}&amp;lt;/b&amp;gt; is the Phidget library for LiveCode. It should be placed in the LiveCode User Extensions folder. More information on its usage will be provided in the [[#Use Our Examples | Use Our Examples]] section.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|Externals.txt}}&amp;lt;/b&amp;gt; lets LiveCode know the name of the Phidget LiveCode library as well as the name of its corresponding {{Code|phidgets_livecode.dll}}. More information on its usage will be provided in the [[#Use Our Examples | Use Our Examples]] section.&lt;br /&gt;
&lt;br /&gt;
If you do not want to use our installer, you can download the [http://www.phidgets.com/downloads/libraries/phidget21-x86_2.1.8.20110615.zip {{Code|phidget21.dll}}] and manually install it where you want; refer to our [[OS_-_Windows#Manual_File_Installation|Manual Installation Instructions]].&lt;br /&gt;
&lt;br /&gt;
===Use Our Examples===&lt;br /&gt;
&lt;br /&gt;
Currently, the only device we support and have examples for is the PhidgetInterfaceKit. In particular, the examples were written with the [[Product - 1018 2 - PhidgetInterfaceKit 8/8/8 | PhidgetInterfaceKit 8/8/8]] in mind. If you have a different PhidgetInterfaceKit, you will need to modify the example to meet the number of digital inputs, digital outputs, and analog inputs that your device support.&lt;br /&gt;
&lt;br /&gt;
To run the examples, &lt;br /&gt;
&lt;br /&gt;
1. Download the [http://www.phidgets.com/downloads/libraries/LiveCodeRequiredWin_2.1.8.20120131.zip Phidget LiveCode library] and extract it into a folder. Here, you will find two files inside the {{Code|Windows}} folder: {{Code|phidgets_livecode.dll}} and {{Code|Externals.txt}}.&lt;br /&gt;
&lt;br /&gt;
2. Open up the LiveCode environment.&lt;br /&gt;
&lt;br /&gt;
3. Go to Edit &amp;amp;rarr; Preferences.&lt;br /&gt;
&lt;br /&gt;
[[File:LiveCode Preferences.PNG|link=|alt=Preferences]]&lt;br /&gt;
&lt;br /&gt;
4. In the Files &amp;amp; Memory tab, locate the {{Code|User Extensions}} field. This is the path where the Phidget LiveCode library need to be placed.&lt;br /&gt;
&lt;br /&gt;
[[File:LiveCode User Extensions 1.PNG|link=|alt=User Extensions Folder]]&lt;br /&gt;
&lt;br /&gt;
5. Traverse to the User Extensions folder in Windows Explorer. Create a folder named {{Code|Externals}} if it does not already exist. Place  {{Code|phidgets_livecode.dll}} and {{Code|Externals.txt}} inside the {{Code|Externals}} folder.&lt;br /&gt;
&lt;br /&gt;
[[File:LiveCode User Extensions 2.PNG|link=|alt=User Extensions Folder]]&lt;br /&gt;
&lt;br /&gt;
6. Download the [http://www.phidgets.com/downloads/examples/LiveCode_2.1.8.20120131.zip examples] and unpack them into a folder. Navigate to the {{Code|LiveCode/InterfaceKit Example}} folder, and open {{Code|InterfaceKit-full.rev}} in LiveCode. These examples were written in LiveCode 4.5, but will also work with other versions.&lt;br /&gt;
&lt;br /&gt;
7. The example will be running in {{Code|Pointer Tool}} mode.&lt;br /&gt;
&lt;br /&gt;
[[File:LiveCode Pointer Tool.PNG|link=|alt=Example in pointer mode]] ? &lt;br /&gt;
&lt;br /&gt;
8. Switch to the {{Code|Browser Tool}} if you want to control GUI elements such as buttons, and scroll bars.&lt;br /&gt;
&lt;br /&gt;
[[File:LiveCode Browse Tool.PNG|link=|alt=Example in browse mode]]&lt;br /&gt;
&lt;br /&gt;
9. Once you have the LiveCode example running, we have a [[#Follow the Examples|teaching]] section below to help you follow them.&lt;br /&gt;
&lt;br /&gt;
===Write Your Own Code===&lt;br /&gt;
&lt;br /&gt;
When you are building a project from scratch, or adding Phidget function calls to an existing project, you&#039;ll need to configure your development environment to properly link the Phidgets LiveCode library. To begin: &lt;br /&gt;
&lt;br /&gt;
1. Ensure that the {{Code| phidgets_livecode.dll}} and {{Code| Externals.txt}} are inside the User Extensions folder, as described in the [[#Use Our Examples | Use Our Examples]] section.&lt;br /&gt;
&lt;br /&gt;
2. Generate a new Mainstack.&lt;br /&gt;
&lt;br /&gt;
[[File:LiveCode New MainStack.PNG|link=|alt=New MainStack]]&lt;br /&gt;
&lt;br /&gt;
3. Open up the Application Browser.&lt;br /&gt;
&lt;br /&gt;
[[File:LiveCode Application Browser 1.PNG|link=|alt=Application Browser]]&lt;br /&gt;
&lt;br /&gt;
4. Edit the script of the mainstack, {{Code|Untitled 1}}.&lt;br /&gt;
&lt;br /&gt;
[[File:LiveCode Application Browser 2.PNG|link=|alt=Application Browser]]&lt;br /&gt;
&lt;br /&gt;
5. You will need to tell LiveCode to reference the Phidget LiveCode library. Copy the following into the script of the mainstack:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight lang=applescript&amp;gt;&lt;br /&gt;
  on preOpenStack&lt;br /&gt;
    if the short name of the owner of the target is the short name of me and \&lt;br /&gt;
        &amp;quot;phidgets_livecodeExternalWrapper&amp;quot; is not among the lines of the stacksInUse then&lt;br /&gt;
      set the visible of the templateStack to false&lt;br /&gt;
      set the name of the templateStack to &amp;quot;phidgets_livecodeExternalWrapper&amp;quot;&lt;br /&gt;
      set the externals of the templateStack to $EXTERNAL_LIBRARY&lt;br /&gt;
      create stack&lt;br /&gt;
      start using stack &amp;quot;phidgets_livecodeExternalWrapper&amp;quot;&lt;br /&gt;
    end if&lt;br /&gt;
  end preOpenStack&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The project now has access to the Phidget function calls and you are ready to begin coding.&lt;br /&gt;
&lt;br /&gt;
The same [[#Follow the Examples|teaching]] section which describes the examples also has further resources for programming your Phidget.&lt;br /&gt;
&lt;br /&gt;
====Creating Standalone Applications====&lt;br /&gt;
When you are finished coding, and want to create an executable, you will have to inform LiveCode to package the Phidget LiveCode library along with the executable.&lt;br /&gt;
&lt;br /&gt;
* Place the {{Code|phidgets_livecode.dll}} and {{Code|Externals.txt}} inside the {{Code|Runtime}} folder of your LiveCode User Extensions.&lt;br /&gt;
&lt;br /&gt;
[[File:LiveCode User Extensions 3.PNG|link=|alt=User Extensions Folder]]&lt;br /&gt;
&lt;br /&gt;
* Notice that the files are placed in a hierarchical structure of folders. Please see [http://www.runrev.com RunRev] for more details regarding setting up this hierarchical structure for  the {{Code|Runtime}} folder.&lt;br /&gt;
&lt;br /&gt;
* Click on File &amp;amp;rarr; Standalone Application Settings.&lt;br /&gt;
&lt;br /&gt;
[[File:LiveCode Standalone Application Settings 1.PNG|link=|alt=Standalone Application Settings]]&lt;br /&gt;
&lt;br /&gt;
* In the {{Code|Script Libraries}} scroll box, please select {{Code|phidgets_livecode}}&lt;br /&gt;
&lt;br /&gt;
[[File:LiveCode Standalone Application Settings 2.PNG|link=|alt=Standalone Application Settings]]&lt;br /&gt;
&lt;br /&gt;
* Then, navigate to the directory of the application you created. Here, you will see a folder named {{Code|Externals}}. Place {{Code|phidgets_livecode.dll}} in this directory. &lt;br /&gt;
&lt;br /&gt;
Now, the application can be used to control Phidgets.&lt;br /&gt;
&lt;br /&gt;
==OS X==&lt;br /&gt;
&lt;br /&gt;
LiveCode has excellent support on OS X.&lt;br /&gt;
&lt;br /&gt;
The first step in using LiveCode on Mac is to install the Phidget libraries.  Compile and install them as explained on the [[Device List|getting started guide for your device]].  Then, the [[OS - OS X]] page also describes the different Phidget files, their installed locations, and their roles....&lt;br /&gt;
&lt;br /&gt;
===Libraries===&lt;br /&gt;
*[http://www.phidgets.com/downloads/libraries/LiveCodeRequiredMac_2.1.8.20111220.zip Phidget LiveCode Library]&lt;br /&gt;
&lt;br /&gt;
===Description===&lt;br /&gt;
LiveCode on Windows depend on the following files, which the installers above put onto your system:&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code| libphidget21.so}}&amp;lt;/b&amp;gt; contains the actual Phidget library, which is used at run-time.  If you used our installer, it&#039;s already placed in {{Code|C:\Windows\System32}}.  It can be manually installed - check our [[Manual Installation instructions]].&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|phidgets_livecode.bundle}}&amp;lt;/b&amp;gt; is the Phidget library for LiveCode. It should be placed in the LiveCode User Extensions folder. More information will be provided in the [[#Use Our Examples 2 | Use Our Examples]] section.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|Externals.txt}}&amp;lt;/b&amp;gt; lets LiveCode know the name of the Phidget LiveCode library as well as the name of its corresponding {{Code|phidgets_livecode.dll}}. More information will be provided in the [[#Use Our Examples 2 | Use Our Examples]] section.&lt;br /&gt;
&lt;br /&gt;
===Use Our Examples===&lt;br /&gt;
&lt;br /&gt;
===Write Your Own Code===&lt;br /&gt;
====Creating Standalone Applications====&lt;br /&gt;
&lt;br /&gt;
==Follow the Examples==&lt;br /&gt;
&lt;br /&gt;
By following the instructions for your operating system above, you probably now have a working example and want to understand it better so you can change it to do what you want.  This teaching section has resources for you to learn from the examples and write your own.&lt;br /&gt;
&lt;br /&gt;
Next, comes our API information.  These resources outline the LiveCode Phidget methods:&lt;br /&gt;
&lt;br /&gt;
{{UsingAPhidgetInCodeGeneral|both of which are available in LiveCode|[http://www.phidgets.com/documentation/LiveCode_API_Manual.pdf LiveCode API]}}&lt;br /&gt;
&lt;br /&gt;
===Example Flow===&lt;br /&gt;
&lt;br /&gt;
{{ExamplePseudocode|In LiveCode, you can name these &#039;&#039;&#039;event&#039;&#039;&#039; functions whatever you like.  You will then pass them as function pointers to the Phidget library below in the Main Code section.  This hooks them into the actual events when they occur. &amp;lt;br&amp;gt; &lt;br /&gt;
In the example code, the event functions common to all Phidgets are called things like &#039;&#039;&#039;AttachHandler()&#039;&#039;&#039; and &#039;&#039;&#039;DetachHandler()&#039;&#039;&#039;, etc.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
The object provides device specific methods and properties which are available from the API for your specific Phidget.|&lt;br /&gt;
[http://www.phidgets.com/documentation/LiveCode_API_Manual.pdf LiveCode API]}}&lt;br /&gt;
&lt;br /&gt;
==Code Snippets==&lt;br /&gt;
&lt;br /&gt;
==Extending LiveCode to other Phidgets==&lt;br /&gt;
&lt;br /&gt;
The Phidgets LiveCode library was developed from a C++ external wrapper and allows the PhidgetInterfaceKit to be programmable in LiveCode. It is possible to extend this external to other Phidgets as well. The goal of this section is to equip the reader with knowledge so that they can understand the relationship between LiveCode and the Phidgets framework. It is intended to provide guidance for readers who wish to extend LiveCode to other Phidgets. This guide uses C++, Microsoft Visual Studio 2005(for Windows XP SP3), XCode 3.2.4(for OS X 10.6.4), LiveCode 4.5 IDE and it is assumed that the reader has a solid understanding of these technologies. It will also help if you are familiar with programming with Phidgets in [[Language - C/C++ | C/C++]]. For your reference, the Visual Studio and XCode project solutions for the Phidget LiveCode library are provided in the [http://www.phidgets.com/downloads/examples/LiveCode_2.1.8.20111220.zip LiveCode examples]&lt;br /&gt;
&lt;br /&gt;
The first step is to download LiveCode Externals Creator SDK from [http://www.runrev.com RunRev]. Run the SDK, select C++ as the language, enter the project name, select the platform and specify the LiveCode installation path. Hit generate to create a skeleton project for the external. &lt;br /&gt;
&lt;br /&gt;
The next step is to setup the environment to allow for access to the Phidget function call.&lt;br /&gt;
&lt;br /&gt;
In Visual Studio, you will need the latest Phidget Windows library and header - these are installed into {{Code|C:\Program Files\Phidgets}} by default if you ran the Phidgets installer. Place the {{Code|phidget21.lib}} and {{Code|phidget21.h}} in the Visual Studio project directory. Be sure to open the properties window, navigate to Configuration Properties &amp;amp;rarr; Linker &amp;amp;rarr; Input and add  {{Code|phidget21.lib}} to the additional dependencies section. Also, include a reference to the library header in the source code.&lt;br /&gt;
&lt;br /&gt;
In XCode, open the newly created {{Code|.xcodeproj}} project into XCode. Add the Phidget framework to the project and include the a reference to the library header in the source code.&lt;br /&gt;
&lt;br /&gt;
Now, we are ready to create external functions. LiveCode will have to acknowledge the existence of any external function. Function declarations are placed inside the {{Code|USER DECLARATIONS}} section of the the code. Here, a call to the function {{Code|phidgetsInterfaceKit_create}} in LiveCode will be mapped to a call to the C++ function,{{Code|phidgetsInterfaceKit_create}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=cpp&amp;gt;&lt;br /&gt;
  EXTERNAL_DECLARE_FUNCTION(&amp;quot;phidgetsInterfaceKit_create&amp;quot;, phidgetsInterfaceKit_create)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For example, LiveCode will use the following lines of code to call the external function {{Code|phidgetsInterfaceKit_create}}.&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=applescript&amp;gt;&lt;br /&gt;
  local ifKit&lt;br /&gt;
  get phidgetsInterfaceKit_create(&amp;quot;ifKit&amp;quot;)  --&amp;quot;ifKit&amp;quot; is the name of the variable phid&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The result of {{Code|get phidgetsInterfaceKit_create(&amp;quot;ifKit&amp;quot;)}} will be 0 or the error code depending on whether the external function succeeded or failed, respectively.&lt;br /&gt;
&lt;br /&gt;
Now, we implement the {{Code|phidgetsInterfaceKit_create}} C++ function.&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=cpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  void phidgetsInterfaceKit_create(char *p_arguments[], int p_argument_count, char **r_result, Bool *r_pass, Bool *r_err)&lt;br /&gt;
  {&lt;br /&gt;
    char outcome_str[8];&lt;br /&gt;
    CPhidgetInterfaceKitHandle ifKit = (CPhidgetInterfaceKitHandle) strtoul(p_arguments[0], NULL, 16);  &lt;br /&gt;
    int outcome=CPhidgetInterfaceKit_create(&amp;amp;ifKit);&lt;br /&gt;
    if(outcome==0){&lt;br /&gt;
      char str[90];&lt;br /&gt;
      int t_success;&lt;br /&gt;
      // Converts to Hexadecimal format&lt;br /&gt;
      sprintf(str,&amp;quot;%08x&amp;quot;,ifKit);&lt;br /&gt;
      // Passes back to LiveCode a reference of the InterfaceKit handle&lt;br /&gt;
      SetVariable(p_arguments[0], str, &amp;amp;t_success);&lt;br /&gt;
    }&lt;br /&gt;
    sprintf(outcome_str, &amp;quot;%d&amp;quot;, outcome);&lt;br /&gt;
    *r_result = strdup(outcome_str);&lt;br /&gt;
    *r_err = False;&lt;br /&gt;
    *r_pass = False;&lt;br /&gt;
    return;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you can see, this function follows the same format as a typical external function. {{Code|p_arguments[]}} stores the arguments that are passed from the LiveCode function. First, we allocate memory to store a {{Code|CPhidgetInterfaceKitHandle}} and store its address in {{Code|ifKit}}. Next, we call the C function {{Code|CPhidgetInterfaceKit_create}}, create the {{Code|PhidgetInterfaceKit}} handle and return the error code to outcome. If outcome is 0, the address of {{Code|ifKit}} is converted into hexadecimal form. The hexadecimal form is then stored in the LiveCode variable {{Code|ifKit}}, so that LiveCode has a reference to the newly created InterfaceKit handle. Lastly, the result of this external function is stored in {{Code|*r_result}}, which is passed back as the return value for the LiveCode function.&lt;br /&gt;
&lt;br /&gt;
It is also possible to implement Phidgets events with LiveCode. We will implement the {{Code|phidgetsInterfaceKit_set_OnSensorChange_Handler}} function. Again, we declare the existence of the function.&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=cpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  EXTERNAL_DECLARE_FUNCTION(&amp;quot;phidgetsInterfaceKit_set_OnSensorChange_Handler&amp;quot;, phidgetsInterfaceKit_set_OnSensorChange_Handler)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In LiveCode, we use the following code to call the external function.&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=applescript&amp;gt;&lt;br /&gt;
  get phidgetsInterfaceKit_set_OnSensorChange_Handler(ifKit, &amp;quot;sensorChange&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and {{Code|sensorChange}} is the name of the LiveCode command to be called whenever a digital input changes. This command must be in the script of the card that called {{Code|phidgetsInterfaceKit_set_OnSensorChange_Handler}} or its stack. The form of the command is as follow:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=applescript&amp;gt;&lt;br /&gt;
  command sensorChange phid pIndex pValue&lt;br /&gt;
    ...&lt;br /&gt;
  end sensorChange&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, we implement the {{Code|phidgetsInterfaceKit_set_OnSensorChange_Handler}} C++ function&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=cpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  void phidgetsInterfaceKit_set_OnSensorChange_Handler(char *p_arguments[], int p_argument_count, char **r_result, Bool *r_pass, Bool *r_err)&lt;br /&gt;
  {  &lt;br /&gt;
    CPhidgetInterfaceKitHandle ifKit = (CPhidgetInterfaceKitHandle)strtoul(p_arguments[0], NULL, 16);  &lt;br /&gt;
    char* str=(char *)malloc(90);&lt;br /&gt;
    str=strdup(p_arguments[1]);&lt;br /&gt;
    int outcome=CPhidgetInterfaceKit_set_OnSensorChange_Handler((CPhidgetInterfaceKitHandle)ifKit, &amp;amp;SensorChangeHandler, str);&lt;br /&gt;
    returnOutcome(outcome, r_result, r_pass, r_err);&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and the callback function&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=cpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  int __stdcall SensorChangeHandler(CPhidgetInterfaceKitHandle ifKit, void *usrptr, int Index, int Value)&lt;br /&gt;
  {&lt;br /&gt;
    int t_success;&lt;br /&gt;
    char * scmMsg;&lt;br /&gt;
    scmMsg=NULL;&lt;br /&gt;
    scmMsg = (char *)malloc(512);&lt;br /&gt;
    sprintf(scmMsg, &amp;quot;send \&amp;quot;%s %08x, %d, %d\&amp;quot; to current card&amp;quot;, (char *)usrptr, ifKit, Index, Value);&lt;br /&gt;
    SendCardMessage(scmMsg, &amp;amp;t_success);&lt;br /&gt;
    if (scmMsg != NULL)&lt;br /&gt;
      free(scmMsg);&lt;br /&gt;
    return 0&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Note:&amp;lt;/b&amp;gt; For OS X, {{Code|__stdcall}} is not needed.&lt;br /&gt;
&lt;br /&gt;
Here, we use {{Code|SendCardMessage}} to run the LiveCode command {{Code|sensorChange}}. The message will be passed to the card that called {{Code|phidgetsInterfaceKit_set_OnSensorChange_Handler}} before passing through the stack in the message hierarchy. Other Phidgets and functions can be extended in a similar manner. The [http://www.phidgets.com/documentation/Phidget21_C_Doc.zip C/C++ API Manual] contains calls and events for every type of Phidget.&lt;br /&gt;
&lt;br /&gt;
==Common Problems and Solutions/Workarounds==&lt;br /&gt;
&lt;br /&gt;
Here you can put various frequent problems and our recommended solutions.&lt;/div&gt;</summary>
		<author><name>Djrudiak</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=Language_-_Flex_AS3&amp;diff=19157</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=19157"/>
		<updated>2012-04-20T17:26:44Z</updated>

		<summary type="html">&lt;p&gt;Djrudiak: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Language]]&lt;br /&gt;
{{OSLang|[[File:icon-Flex_AS3.png|64x64px|link=|alt=]]|Flex AS3 is no longer maintained by Phidgets.}}&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 Phidget Programming]] 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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight lang=actionscript&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
  phid.addEventListener(PhidgetDataEvent.SENSOR_CHANGE, onSensorChange);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;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>Djrudiak</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=Language_-_Flash_AS3&amp;diff=19156</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=19156"/>
		<updated>2012-04-20T17:23:35Z</updated>

		<summary type="html">&lt;p&gt;Djrudiak: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Language]]&lt;br /&gt;
{{OSLang|[[File:icon-Flash AS3.png|64x64px|link=|alt=]]|Flash, developed by [http://www.adobe.com Adobe Systems] is used to build and deploy dynamic multimedia applications to the Internet.}}&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
{{LanguageSupport|Flash ActionScript|Phidgets &amp;lt;i&amp;gt;only&amp;lt;/i&amp;gt; over the Phidget WebService, and it is unlike the majority of the other programming languages we support where the device can be used without the Phidget WebService. The complete Phidget API, including events are supported|all Phidget devices.|[[#Windows | Windows]] and [[#OS X | OS X]]|&lt;br /&gt;
&lt;br /&gt;
Only ActionScript 3 is supported. Interaction with Phidgets is made possible as the library uses web sockets to communicate with Phidgets over the PhidgetWebService.}}&lt;br /&gt;
&lt;br /&gt;
==Quick Downloads==&lt;br /&gt;
{{QuickDownloads|Flash ActionScript|&lt;br /&gt;
{{APIQuickDownloads|http://www.phidgets.com/documentation/Phidget21Flash_doc.zip ActionScript 3}}|&lt;br /&gt;
{{ExampleQuickDownloads|http://www.phidgets.com/downloads/examples/Flash_2.1.8.20120131.zip| (same file as ActionScript Libraries below)}}|&lt;br /&gt;
{{ExtraLibraryQuickDownloads|http://www.phidgets.com/downloads/examples/Flash_2.1.8.20120131.zip|ActionScript| (same file as Examples above)}}&lt;br /&gt;
{{WindowsQuickDownloads}}&lt;br /&gt;
{{MacQuickDownloads}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Getting started with Flash ActionScript==&lt;br /&gt;
&lt;br /&gt;
If you are new to writing code for Phidgets, we recommend starting by running, then modifying existing examples. This will allow you to:&lt;br /&gt;
{{ExampleCodeReasons}}&lt;br /&gt;
&lt;br /&gt;
Instructions are divided up by operating system. Choose:&lt;br /&gt;
*[[#Windows (2000/XP/Vista/7)|Windows 2000 / XP / Vista / 7]]&lt;br /&gt;
*[[#OS X |OS X]]&lt;br /&gt;
*[[#Linux | Linux]] (including PhidgetSBC)&lt;br /&gt;
&lt;br /&gt;
==Windows (2000/XP/Vista/7)==&lt;br /&gt;
&lt;br /&gt;
===Description of Library===&lt;br /&gt;
Flash ActionScript on Windows depend on the following files and folders. The installers in the [[#Libraries and Drivers | Quick Downloads]] section put only the {{Code|phidget21.dll}} and {{Code|PhidgetWebservice21.exe}} into your system. You will need to manually put the {{Code|com}} folder into your system. &lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|phidget21.dll}}&amp;lt;/b&amp;gt; contains the actual Phidget library, which is used at run-time.  This needs to be installed on the computer that the Phidget is connected. By default, it is placed in {{Code|C:\Windows\System32}}.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|PhidgetWebservice21.exe}}&amp;lt;/b&amp;gt; allows for controlling Phidgets remotely across the network. This needs to be installed on the computer that the Phidget is connected.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|com}}&amp;lt;/b&amp;gt; folder is the Phidget ActionScript library. The computer that is used for Flash development will need this folder. It is to be manually placed in the same directory as your project root.&lt;br /&gt;
&lt;br /&gt;
Unlike the majority of the [[Software_Overview#Language_Support |programming languages]] we support (where applications can directly connect to the Phidgets), Flash can only connect to the Phidgets over the PhidgetWebService. There are potentially three roles that a computer can act as: host, developer, and an end user. It is possible for a single computer to act as more than one of these roles at the same time:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Host&amp;lt;/b&amp;gt;: The computer that the Phidget is attached to, and can broadcast device information to any computer over the network. The {{Code|phidget21.dll}} and {{Code|PhidgetWebservice21.exe}} must be installed on the host. The host must also have the PhidgetWebService started in order for it and other computers to connect to the Phidgets attached to the host.&lt;br /&gt;
* &amp;lt;b&amp;gt;Developer&amp;lt;/b&amp;gt;: The computer that is used to develop Flash applications. This computer needs the {{Code|com}} folder in the root directory of your project. The {{Code|phidget21.dll}} and {{Code|PhidgetWebservice21.exe}} are only needed if the Phidget is directly attached to the computer.&lt;br /&gt;
* &amp;lt;b&amp;gt;End user&amp;lt;/b&amp;gt;: The computer that is used to run the compiled flash application (i.e., {{Code|.swf}}).The {{Code|phidget21.dll}} and {{Code|PhidgetWebservice21.exe}} are only needed if the Phidget is directly connected to the computer. If the computer is used for developing Flash applications, then it will need the {{Code|com}} folder in the root directory of your project.&lt;br /&gt;
&lt;br /&gt;
Here is a table summarizing what files/folders are needed for each computer role:&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;border:1px solid darkgray;&amp;quot; cellpadding=&amp;quot;7px;&amp;quot;&lt;br /&gt;
|-style=&amp;quot;background: #f0f0f0&amp;quot; align=center &lt;br /&gt;
! Computer Role&lt;br /&gt;
! {{Code|phidget21.dll}}&lt;br /&gt;
! {{Code|Phidget21WebService.dll}}&lt;br /&gt;
! {{Code|com}} folder&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|Host&lt;br /&gt;
|style=&amp;quot;background: #5EC155&amp;quot; align=center|[[Image:Checkmark.png|link=]]&lt;br /&gt;
|style=&amp;quot;background: #5EC155&amp;quot; align=center|[[Image:Checkmark.png|link=]]&lt;br /&gt;
|style=&amp;quot;background: #5EC155&amp;quot; align=center|&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|Developer&lt;br /&gt;
|style=&amp;quot;background: #5EC155&amp;quot; align=center|&lt;br /&gt;
|style=&amp;quot;background: #5EC155&amp;quot; align=center|&lt;br /&gt;
|style=&amp;quot;background: #5EC155&amp;quot; align=center|[[Image:Checkmark.png|link=]]&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|End User&lt;br /&gt;
|style=&amp;quot;background: #5EC155&amp;quot; align=center|&lt;br /&gt;
|style=&amp;quot;background: #5EC155&amp;quot; align=center|&lt;br /&gt;
|style=&amp;quot;background: #5EC155&amp;quot; align=center|&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Please see the [[Phidget WebService | Phidget WebService]] section for more information. &lt;br /&gt;
&lt;br /&gt;
If you do not want to use our installer, you can download the [http://www.phidgets.com/downloads/libraries/phidget21-x86_2.1.8.20110615.zip {{Code|phidget21.dll}}] and manually install them where you want; refer to our [[OS_-_Windows#Manual_File_Installation | Manual Installation Instructions]].&lt;br /&gt;
&lt;br /&gt;
===Flash Professional===&lt;br /&gt;
&lt;br /&gt;
====Use Our Examples====&lt;br /&gt;
&lt;br /&gt;
This section will assume that the device is plugged into the host computer, and that the development computer has Flash Professional installed.&lt;br /&gt;
&lt;br /&gt;
As the Flash ActionScript library only supports communication with Phidgets through the PhidgetWebService, begin by [[starting the PhidgetWebService]] on the host computer with the default port (5001).&lt;br /&gt;
&lt;br /&gt;
To run the examples on a development computer, download the [http://www.phidgets.com/downloads/examples/Flash_2.1.8.20120131.zip examples] and unpack them into a folder.  Here, you will find example programs for all devices.  If you aren&#039;t sure what the software example for your device is called, check the software object listed in the [[Device List | Getting Started Guide for your Device]].&lt;br /&gt;
&lt;br /&gt;
When you have found your example, open that {{Code|.fla}} file in the Adobe Professional Flash environment. The only thing left to do is to run the examples! Click on Control &amp;amp;rarr; Test Movie. &lt;br /&gt;
&lt;br /&gt;
[[File:Flash Test Movie.png|link=|alt=Run]]&lt;br /&gt;
&lt;br /&gt;
Once you have the Flash ActionScript examples running, we have a [[#Follow the Examples|teaching]] section below to help you follow them.&lt;br /&gt;
&lt;br /&gt;
You may also run the examples by navigating to Control &amp;amp;rarr; Test Scene. If you are running the examples with Debug &amp;amp;rarr; Debug Movie, you will have to change the Flash Global Security Settings in order for the example to run. More information will be provided about the Flash Global Security Settings in the [[#Running Compiled Code | Running Compiled Code]] section.&lt;br /&gt;
&lt;br /&gt;
=====Write Your Own Code=====&lt;br /&gt;
&lt;br /&gt;
When you are building a project from scratch, or adding Phidget function calls to an existing project, you&#039;ll need to configure your development environment to properly link the Phidget ActionScript library. To begin: &lt;br /&gt;
&lt;br /&gt;
1. Place a copy of the [http://www.phidgets.com/downloads/examples/Flash_2.1.8.20120131.zip {{Code|com}}] folder in the root directory of your Flash project.&lt;br /&gt;
&lt;br /&gt;
2. Generate a new ActionScript 3 Flash file.&lt;br /&gt;
&lt;br /&gt;
[[File:Flash New Project.png|link=|alt=New Project]]&lt;br /&gt;
&lt;br /&gt;
3. Then, in your code, you will need to include the Phidget ActionScript library. Navigate to Window &amp;amp;rarr; Actions to bring up the Actions window and enter in the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=actionscript&amp;gt;&lt;br /&gt;
import com.phidgets.*;&lt;br /&gt;
import com.phidgets.events.*;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The project now has access to the Phidget function calls and you are ready to begin coding.&lt;br /&gt;
&lt;br /&gt;
The same [[#Follow the Examples|teaching]] section which describes the examples also has further resources for programming your Phidget.&lt;br /&gt;
&lt;br /&gt;
=====Running Compiled Code=====&lt;br /&gt;
&lt;br /&gt;
Running a compiled {{Code|.swf}} application on an end user computer will prompt the Flash player to display a dialog box mentioning that the application will block all communications with the Internet.&lt;br /&gt;
&lt;br /&gt;
[[File:Flash Player Security Warning.png|link=|alt=Flash Player Security Warning]]&lt;br /&gt;
&lt;br /&gt;
1. Click on the {{Code|Settings}} button to bring up the Flash Global Security Settings Manager in your default web browser. Alternatively, you can access the manager with the following URL: [http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04a.html http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04a.html].&lt;br /&gt;
&lt;br /&gt;
[[File:Flash Global Security Settings 1.png|link=|alt=Flash Global Security Settings]]&lt;br /&gt;
&lt;br /&gt;
2. In the Global Security Settings tab, navigate to {{Code|Edit locations ...}} &amp;amp;rarr; {{Code|Add locations}}.&lt;br /&gt;
&lt;br /&gt;
[[File:Flash Global Security Settings 2.png|link=|alt=Browse for File/Folder]]&lt;br /&gt;
&lt;br /&gt;
3. Then, browse and add the application or the folder containing the application. &lt;br /&gt;
&lt;br /&gt;
[[File:Flash Global Security Settings 3.png|link=|alt=Added file to the trusted locations]]&lt;br /&gt;
&lt;br /&gt;
This will allow the Flash Player to allow the application to accept any communication with the Internet.&lt;br /&gt;
&lt;br /&gt;
==OS X==&lt;br /&gt;
&lt;br /&gt;
Flash ActionScript has excellent support on OS X over the PhidgetWebService.&lt;br /&gt;
&lt;br /&gt;
The first step in using Flash ActionScript on Mac is to install...&lt;br /&gt;
&lt;br /&gt;
==Follow the Examples==&lt;br /&gt;
&lt;br /&gt;
By following the instructions for your operating system and compiler above, you probably now have a working example and want to understand it better so you can change it to do what you want.  This [[#Follow the Examples|teaching]] section has resources for you to learn from the examples and write your own.&lt;br /&gt;
&lt;br /&gt;
Next comes our ActionScript API information, with syntax for all of our functions:&lt;br /&gt;
&lt;br /&gt;
{{UsingAPhidgetInCodeGeneral|both of which are available in C/C++|[http://www.phidgets.com/documentation/Phidget21Flash_doc.zip ActionScript API]}}&lt;br /&gt;
&lt;br /&gt;
===Example Flow===&lt;br /&gt;
&lt;br /&gt;
{{ExamplePseudocode|In flash ActionScript, you can name these &#039;&#039;&#039;event&#039;&#039;&#039; functions whatever you like.  You will then pass them as function pointers to the Phidget library below in the Main Code section.  This hooks them into the actual events when they occur. &amp;lt;br&amp;gt; &lt;br /&gt;
In the example code, the event functions common to all Phidgets are called things like &#039;&#039;&#039;AttachHandler ()&#039;&#039;&#039; and &#039;&#039;&#039;DetachHandler ()&#039;&#039;&#039;, etc.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Some event functions will be specific to each device, like when a tag is read on an RFID board, or when a sensor value changes on an Interface Kit.&lt;br /&gt;
Other functions are given in the examples to show you more detail on using your Phidget.  For example, &#039;&#039;&#039;DeviceInitialize ()&#039;&#039;&#039; will show what needs to be set up for your Phidget before using it.&lt;br /&gt;
|Creating a Phidget software object in Flash ActionScript is specific to the Phidget.  For a Phidget Spatial, for example, this would involve creating a {{Code|PhidgetSpatial}} object.  The examples show how to do this and other API functions.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Code Snippets==&lt;br /&gt;
a single Phidget to be opened by multiple applications - something that cannot be done with the regular interface&lt;br /&gt;
&lt;br /&gt;
==Common Problems and Solutions/Workarounds==&lt;br /&gt;
&lt;br /&gt;
Problem: My compiled application is experiencing the following security error upon launching: &amp;quot;SecurityError: Error #2010: Local-with-filesystem SWF files are not permitted to use sockets&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
[[File:Socket Runtime Error.png|link=|alt=Socket Error]]&lt;br /&gt;
&lt;br /&gt;
Solution: The symptom of this problem is similar to the one that is discussed in steps 1 - 3 of the [[#Running Compiled Code | Running Compiled Code]] section. Please see that section for a remedy. To access the Flash Global Security Settings Manager, go to [http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04a.html http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04a.html].&lt;/div&gt;</summary>
		<author><name>Djrudiak</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=Language_-_Flash_AS3&amp;diff=19155</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=19155"/>
		<updated>2012-04-20T17:23:18Z</updated>

		<summary type="html">&lt;p&gt;Djrudiak: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Language]]&lt;br /&gt;
{{OSLang|[[File:icon-Flash AS3.png|64x64px||link=|alt=]]|Flash, developed by [http://www.adobe.com Adobe Systems] is used to build and deploy dynamic multimedia applications to the Internet.}}&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
{{LanguageSupport|Flash ActionScript|Phidgets &amp;lt;i&amp;gt;only&amp;lt;/i&amp;gt; over the Phidget WebService, and it is unlike the majority of the other programming languages we support where the device can be used without the Phidget WebService. The complete Phidget API, including events are supported|all Phidget devices.|[[#Windows | Windows]] and [[#OS X | OS X]]|&lt;br /&gt;
&lt;br /&gt;
Only ActionScript 3 is supported. Interaction with Phidgets is made possible as the library uses web sockets to communicate with Phidgets over the PhidgetWebService.}}&lt;br /&gt;
&lt;br /&gt;
==Quick Downloads==&lt;br /&gt;
{{QuickDownloads|Flash ActionScript|&lt;br /&gt;
{{APIQuickDownloads|http://www.phidgets.com/documentation/Phidget21Flash_doc.zip ActionScript 3}}|&lt;br /&gt;
{{ExampleQuickDownloads|http://www.phidgets.com/downloads/examples/Flash_2.1.8.20120131.zip| (same file as ActionScript Libraries below)}}|&lt;br /&gt;
{{ExtraLibraryQuickDownloads|http://www.phidgets.com/downloads/examples/Flash_2.1.8.20120131.zip|ActionScript| (same file as Examples above)}}&lt;br /&gt;
{{WindowsQuickDownloads}}&lt;br /&gt;
{{MacQuickDownloads}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Getting started with Flash ActionScript==&lt;br /&gt;
&lt;br /&gt;
If you are new to writing code for Phidgets, we recommend starting by running, then modifying existing examples. This will allow you to:&lt;br /&gt;
{{ExampleCodeReasons}}&lt;br /&gt;
&lt;br /&gt;
Instructions are divided up by operating system. Choose:&lt;br /&gt;
*[[#Windows (2000/XP/Vista/7)|Windows 2000 / XP / Vista / 7]]&lt;br /&gt;
*[[#OS X |OS X]]&lt;br /&gt;
*[[#Linux | Linux]] (including PhidgetSBC)&lt;br /&gt;
&lt;br /&gt;
==Windows (2000/XP/Vista/7)==&lt;br /&gt;
&lt;br /&gt;
===Description of Library===&lt;br /&gt;
Flash ActionScript on Windows depend on the following files and folders. The installers in the [[#Libraries and Drivers | Quick Downloads]] section put only the {{Code|phidget21.dll}} and {{Code|PhidgetWebservice21.exe}} into your system. You will need to manually put the {{Code|com}} folder into your system. &lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|phidget21.dll}}&amp;lt;/b&amp;gt; contains the actual Phidget library, which is used at run-time.  This needs to be installed on the computer that the Phidget is connected. By default, it is placed in {{Code|C:\Windows\System32}}.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|PhidgetWebservice21.exe}}&amp;lt;/b&amp;gt; allows for controlling Phidgets remotely across the network. This needs to be installed on the computer that the Phidget is connected.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|com}}&amp;lt;/b&amp;gt; folder is the Phidget ActionScript library. The computer that is used for Flash development will need this folder. It is to be manually placed in the same directory as your project root.&lt;br /&gt;
&lt;br /&gt;
Unlike the majority of the [[Software_Overview#Language_Support |programming languages]] we support (where applications can directly connect to the Phidgets), Flash can only connect to the Phidgets over the PhidgetWebService. There are potentially three roles that a computer can act as: host, developer, and an end user. It is possible for a single computer to act as more than one of these roles at the same time:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Host&amp;lt;/b&amp;gt;: The computer that the Phidget is attached to, and can broadcast device information to any computer over the network. The {{Code|phidget21.dll}} and {{Code|PhidgetWebservice21.exe}} must be installed on the host. The host must also have the PhidgetWebService started in order for it and other computers to connect to the Phidgets attached to the host.&lt;br /&gt;
* &amp;lt;b&amp;gt;Developer&amp;lt;/b&amp;gt;: The computer that is used to develop Flash applications. This computer needs the {{Code|com}} folder in the root directory of your project. The {{Code|phidget21.dll}} and {{Code|PhidgetWebservice21.exe}} are only needed if the Phidget is directly attached to the computer.&lt;br /&gt;
* &amp;lt;b&amp;gt;End user&amp;lt;/b&amp;gt;: The computer that is used to run the compiled flash application (i.e., {{Code|.swf}}).The {{Code|phidget21.dll}} and {{Code|PhidgetWebservice21.exe}} are only needed if the Phidget is directly connected to the computer. If the computer is used for developing Flash applications, then it will need the {{Code|com}} folder in the root directory of your project.&lt;br /&gt;
&lt;br /&gt;
Here is a table summarizing what files/folders are needed for each computer role:&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;border:1px solid darkgray;&amp;quot; cellpadding=&amp;quot;7px;&amp;quot;&lt;br /&gt;
|-style=&amp;quot;background: #f0f0f0&amp;quot; align=center &lt;br /&gt;
! Computer Role&lt;br /&gt;
! {{Code|phidget21.dll}}&lt;br /&gt;
! {{Code|Phidget21WebService.dll}}&lt;br /&gt;
! {{Code|com}} folder&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|Host&lt;br /&gt;
|style=&amp;quot;background: #5EC155&amp;quot; align=center|[[Image:Checkmark.png|link=]]&lt;br /&gt;
|style=&amp;quot;background: #5EC155&amp;quot; align=center|[[Image:Checkmark.png|link=]]&lt;br /&gt;
|style=&amp;quot;background: #5EC155&amp;quot; align=center|&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|Developer&lt;br /&gt;
|style=&amp;quot;background: #5EC155&amp;quot; align=center|&lt;br /&gt;
|style=&amp;quot;background: #5EC155&amp;quot; align=center|&lt;br /&gt;
|style=&amp;quot;background: #5EC155&amp;quot; align=center|[[Image:Checkmark.png|link=]]&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|End User&lt;br /&gt;
|style=&amp;quot;background: #5EC155&amp;quot; align=center|&lt;br /&gt;
|style=&amp;quot;background: #5EC155&amp;quot; align=center|&lt;br /&gt;
|style=&amp;quot;background: #5EC155&amp;quot; align=center|&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Please see the [[Phidget WebService | Phidget WebService]] section for more information. &lt;br /&gt;
&lt;br /&gt;
If you do not want to use our installer, you can download the [http://www.phidgets.com/downloads/libraries/phidget21-x86_2.1.8.20110615.zip {{Code|phidget21.dll}}] and manually install them where you want; refer to our [[OS_-_Windows#Manual_File_Installation | Manual Installation Instructions]].&lt;br /&gt;
&lt;br /&gt;
===Flash Professional===&lt;br /&gt;
&lt;br /&gt;
====Use Our Examples====&lt;br /&gt;
&lt;br /&gt;
This section will assume that the device is plugged into the host computer, and that the development computer has Flash Professional installed.&lt;br /&gt;
&lt;br /&gt;
As the Flash ActionScript library only supports communication with Phidgets through the PhidgetWebService, begin by [[starting the PhidgetWebService]] on the host computer with the default port (5001).&lt;br /&gt;
&lt;br /&gt;
To run the examples on a development computer, download the [http://www.phidgets.com/downloads/examples/Flash_2.1.8.20120131.zip examples] and unpack them into a folder.  Here, you will find example programs for all devices.  If you aren&#039;t sure what the software example for your device is called, check the software object listed in the [[Device List | Getting Started Guide for your Device]].&lt;br /&gt;
&lt;br /&gt;
When you have found your example, open that {{Code|.fla}} file in the Adobe Professional Flash environment. The only thing left to do is to run the examples! Click on Control &amp;amp;rarr; Test Movie. &lt;br /&gt;
&lt;br /&gt;
[[File:Flash Test Movie.png|link=|alt=Run]]&lt;br /&gt;
&lt;br /&gt;
Once you have the Flash ActionScript examples running, we have a [[#Follow the Examples|teaching]] section below to help you follow them.&lt;br /&gt;
&lt;br /&gt;
You may also run the examples by navigating to Control &amp;amp;rarr; Test Scene. If you are running the examples with Debug &amp;amp;rarr; Debug Movie, you will have to change the Flash Global Security Settings in order for the example to run. More information will be provided about the Flash Global Security Settings in the [[#Running Compiled Code | Running Compiled Code]] section.&lt;br /&gt;
&lt;br /&gt;
=====Write Your Own Code=====&lt;br /&gt;
&lt;br /&gt;
When you are building a project from scratch, or adding Phidget function calls to an existing project, you&#039;ll need to configure your development environment to properly link the Phidget ActionScript library. To begin: &lt;br /&gt;
&lt;br /&gt;
1. Place a copy of the [http://www.phidgets.com/downloads/examples/Flash_2.1.8.20120131.zip {{Code|com}}] folder in the root directory of your Flash project.&lt;br /&gt;
&lt;br /&gt;
2. Generate a new ActionScript 3 Flash file.&lt;br /&gt;
&lt;br /&gt;
[[File:Flash New Project.png|link=|alt=New Project]]&lt;br /&gt;
&lt;br /&gt;
3. Then, in your code, you will need to include the Phidget ActionScript library. Navigate to Window &amp;amp;rarr; Actions to bring up the Actions window and enter in the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=actionscript&amp;gt;&lt;br /&gt;
import com.phidgets.*;&lt;br /&gt;
import com.phidgets.events.*;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The project now has access to the Phidget function calls and you are ready to begin coding.&lt;br /&gt;
&lt;br /&gt;
The same [[#Follow the Examples|teaching]] section which describes the examples also has further resources for programming your Phidget.&lt;br /&gt;
&lt;br /&gt;
=====Running Compiled Code=====&lt;br /&gt;
&lt;br /&gt;
Running a compiled {{Code|.swf}} application on an end user computer will prompt the Flash player to display a dialog box mentioning that the application will block all communications with the Internet.&lt;br /&gt;
&lt;br /&gt;
[[File:Flash Player Security Warning.png|link=|alt=Flash Player Security Warning]]&lt;br /&gt;
&lt;br /&gt;
1. Click on the {{Code|Settings}} button to bring up the Flash Global Security Settings Manager in your default web browser. Alternatively, you can access the manager with the following URL: [http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04a.html http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04a.html].&lt;br /&gt;
&lt;br /&gt;
[[File:Flash Global Security Settings 1.png|link=|alt=Flash Global Security Settings]]&lt;br /&gt;
&lt;br /&gt;
2. In the Global Security Settings tab, navigate to {{Code|Edit locations ...}} &amp;amp;rarr; {{Code|Add locations}}.&lt;br /&gt;
&lt;br /&gt;
[[File:Flash Global Security Settings 2.png|link=|alt=Browse for File/Folder]]&lt;br /&gt;
&lt;br /&gt;
3. Then, browse and add the application or the folder containing the application. &lt;br /&gt;
&lt;br /&gt;
[[File:Flash Global Security Settings 3.png|link=|alt=Added file to the trusted locations]]&lt;br /&gt;
&lt;br /&gt;
This will allow the Flash Player to allow the application to accept any communication with the Internet.&lt;br /&gt;
&lt;br /&gt;
==OS X==&lt;br /&gt;
&lt;br /&gt;
Flash ActionScript has excellent support on OS X over the PhidgetWebService.&lt;br /&gt;
&lt;br /&gt;
The first step in using Flash ActionScript on Mac is to install...&lt;br /&gt;
&lt;br /&gt;
==Follow the Examples==&lt;br /&gt;
&lt;br /&gt;
By following the instructions for your operating system and compiler above, you probably now have a working example and want to understand it better so you can change it to do what you want.  This [[#Follow the Examples|teaching]] section has resources for you to learn from the examples and write your own.&lt;br /&gt;
&lt;br /&gt;
Next comes our ActionScript API information, with syntax for all of our functions:&lt;br /&gt;
&lt;br /&gt;
{{UsingAPhidgetInCodeGeneral|both of which are available in C/C++|[http://www.phidgets.com/documentation/Phidget21Flash_doc.zip ActionScript API]}}&lt;br /&gt;
&lt;br /&gt;
===Example Flow===&lt;br /&gt;
&lt;br /&gt;
{{ExamplePseudocode|In flash ActionScript, you can name these &#039;&#039;&#039;event&#039;&#039;&#039; functions whatever you like.  You will then pass them as function pointers to the Phidget library below in the Main Code section.  This hooks them into the actual events when they occur. &amp;lt;br&amp;gt; &lt;br /&gt;
In the example code, the event functions common to all Phidgets are called things like &#039;&#039;&#039;AttachHandler ()&#039;&#039;&#039; and &#039;&#039;&#039;DetachHandler ()&#039;&#039;&#039;, etc.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Some event functions will be specific to each device, like when a tag is read on an RFID board, or when a sensor value changes on an Interface Kit.&lt;br /&gt;
Other functions are given in the examples to show you more detail on using your Phidget.  For example, &#039;&#039;&#039;DeviceInitialize ()&#039;&#039;&#039; will show what needs to be set up for your Phidget before using it.&lt;br /&gt;
|Creating a Phidget software object in Flash ActionScript is specific to the Phidget.  For a Phidget Spatial, for example, this would involve creating a {{Code|PhidgetSpatial}} object.  The examples show how to do this and other API functions.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Code Snippets==&lt;br /&gt;
a single Phidget to be opened by multiple applications - something that cannot be done with the regular interface&lt;br /&gt;
&lt;br /&gt;
==Common Problems and Solutions/Workarounds==&lt;br /&gt;
&lt;br /&gt;
Problem: My compiled application is experiencing the following security error upon launching: &amp;quot;SecurityError: Error #2010: Local-with-filesystem SWF files are not permitted to use sockets&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
[[File:Socket Runtime Error.png|link=|alt=Socket Error]]&lt;br /&gt;
&lt;br /&gt;
Solution: The symptom of this problem is similar to the one that is discussed in steps 1 - 3 of the [[#Running Compiled Code | Running Compiled Code]] section. Please see that section for a remedy. To access the Flash Global Security Settings Manager, go to [http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04a.html http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04a.html].&lt;/div&gt;</summary>
		<author><name>Djrudiak</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=Language_-_Adobe_Director&amp;diff=19153</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=19153"/>
		<updated>2012-04-20T17:20:41Z</updated>

		<summary type="html">&lt;p&gt;Djrudiak: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Language]]&lt;br /&gt;
{{OSLang|[[File:icon-Adobe_Director.png|64x64px|link=|alt=]]|Adobe Director, developed by [http://www.adobe.com Adobe Systems] is a tool used to build interactive and multimedia applications.}}&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
{{LanguageSupport|Adobe Director|the complete Phidget API, including events|the PhidgetInterfaceKit devices.|Windows.|}}&lt;br /&gt;
&lt;br /&gt;
==Quick Downloads==&lt;br /&gt;
&lt;br /&gt;
{{QuickDownloads|Adobe Director|&lt;br /&gt;
{{APIQuickDownloads|http://www.phidgets.com/documentation/COM_API_Manual.pdf}}|&lt;br /&gt;
{{ExampleQuickDownloads|http://www.phidgets.com/downloads/examples/AdobeDirector_2.1.8.20120216.zip|}}|&lt;br /&gt;
{{ExtraLibraryQuickDownloads|http://www.phidgets.com/downloads/libraries/Phidget21-windevel_2.1.8.20120216.zip|COM|}}&lt;br /&gt;
{{WindowsQuickDownloads}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Getting started with Adobe Director==&lt;br /&gt;
&lt;br /&gt;
If you are new to writing code for Phidgets, we recommend starting by running, then modifying existing examples. This will allow you to:&lt;br /&gt;
{{ExampleCodeReasons}}&lt;br /&gt;
&lt;br /&gt;
==Windows (2000/XP/Vista/7)==&lt;br /&gt;
&lt;br /&gt;
===Description of Library===&lt;br /&gt;
Adobe Director programs on Windows depend on the following. The installers in the [[#Libraries and Drivers | Quick Downloads]] section put only the {{Code|phidget21.dll}} into your system.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|phidget21.dll}}&amp;lt;/b&amp;gt; contains the actual Phidget library, which is used at run-time.  By default, it is placed in {{Code|C:\Windows\System32}}.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|Phidget21COM.dll}}&amp;lt;/b&amp;gt; is the Component Object Model(COM) library and provides your project access to the Phidget ActiveX objects. If you installed the Phidget drivers, it will have automatically registered the ActiveX objects into your system. If you are manually installing this file, you must register it through command line by running: {{Code|regsvr32 Phidget21COM.dll}}.&lt;br /&gt;
&lt;br /&gt;
If you do not want to use our installer, you can download both [http://www.phidgets.com/downloads/libraries/Phidget21-windevel_2.1.8.20111220.zip files] and manually install them where you want; refer to our [[OS_-_Windows#Manual_File_Installation| Manual Installation Instructions]].&lt;br /&gt;
&lt;br /&gt;
===Adobe Director 11.5===&lt;br /&gt;
&lt;br /&gt;
====Use Our Examples====&lt;br /&gt;
&lt;br /&gt;
1. Download the [http://www.phidgets.com/downloads/examples/AdobeDirector_2.1.8.20120216.zip examples] and unpack them into a folder.  These examples were written in Adobe Director 11.5. &lt;br /&gt;
&lt;br /&gt;
2. The easiest way to confirm that your environment is set up properly will be to run the HelloWorld Adobe Director example. In the Adobe Director environment, open up the file named {{Code|HelloWorld.dir}}.&lt;br /&gt;
&lt;br /&gt;
3. To run the example, click on Control &amp;amp;rarr; Play. &lt;br /&gt;
&lt;br /&gt;
[[File:AdobeDirector Play.PNG|link=|alt=Play]]&lt;br /&gt;
&lt;br /&gt;
4. This program will detect for devices that are attached/detached on the computer. Go ahead, and attach or detach your devices! Here is an example output:&lt;br /&gt;
&lt;br /&gt;
[[File:AdobeDirector HelloWorld Output.PNG|link=|alt=HelloWorld Output]]&lt;br /&gt;
&lt;br /&gt;
After confirming that the {{Code|HelloWorld}} example is working, you can proceed to run the example for your device. Currently, the only device we have example code for is the PhidgetInterfaceKit. &lt;br /&gt;
&lt;br /&gt;
Once you have the Adobe Director examples running, we have a teaching section below to help you follow them.&lt;br /&gt;
&lt;br /&gt;
====Write Your Own Code====&lt;br /&gt;
&lt;br /&gt;
When you are building a project from scratch, or adding Phidget function calls to an existing project, you&#039;ll need to configure your environment to properly link the Phidget ActiveX object. &lt;br /&gt;
&lt;br /&gt;
1. Create a new movie. &lt;br /&gt;
&lt;br /&gt;
2. Navigate to Insert &amp;amp;rarr; Control &amp;amp;rarr; ActiveX. &lt;br /&gt;
&lt;br /&gt;
[[File:AdobeDirector Add ActiveX 1.PNG |link=|alt=Add ActiveX Control]]&lt;br /&gt;
&lt;br /&gt;
3. Select the ActiveX control that corresponds to your device. Select {{Code|OK}}.&lt;br /&gt;
&lt;br /&gt;
[[File:AdobeDirector Add ActiveX 2.PNG |link=|alt=Add ActiveX Control]]&lt;br /&gt;
&lt;br /&gt;
4. A window will pop up listing the properties and methods of the ActiveX class. Select {{Code|OK}}.&lt;br /&gt;
&lt;br /&gt;
[[File:AdobeDirector Class ActiveX Properties.PNG |link=|alt=ActiveX Properties]]&lt;br /&gt;
&lt;br /&gt;
5. The ActiveX class will be added to your cast. Create an instance of it by dragging and dropping the cast member onto the stage.&lt;br /&gt;
&lt;br /&gt;
[[File:AdobeDirector ActiveX Cast.PNG ‎|link=|alt=ActiveX Cast]]&lt;br /&gt;
&lt;br /&gt;
The project now has access to the Phidget function calls and you are ready to begin coding.&lt;br /&gt;
&lt;br /&gt;
The same [[#Follow the Examples|teaching ]] section which describes the examples also has further resources for programming your Phidget.&lt;br /&gt;
&lt;br /&gt;
==Follow the Examples==&lt;br /&gt;
&lt;br /&gt;
By following the instructions for your operating system and compiler above, you probably now have a working example and want to understand it better so you can change it to do what you want.  This teaching section has resources for you to learn from the examples and write your own.&lt;br /&gt;
&lt;br /&gt;
Next, comes our API information.  These resources outline the Adobe Director Phidget functions:&lt;br /&gt;
&lt;br /&gt;
{{UsingAPhidgetInCodeGeneral|both of which are available in Adobe Director|[http://www.phidgets.com/documentation/COM_API_Manual.pdf COM API]}}&lt;br /&gt;
&lt;br /&gt;
===Example Flow===&lt;br /&gt;
&lt;br /&gt;
{{ExamplePseudocode|In Adobe Director, you can name these &#039;&#039;&#039;event&#039;&#039;&#039; functions whatever you like.  You will then pass them as function pointers to the Phidget library below in the Main Code section.  This hooks them into the actual events when they occur. &amp;lt;br&amp;gt; &lt;br /&gt;
In the example code, the event functions common to all Phidgets are called things like &#039;&#039;&#039;OnAttach()&#039;&#039;&#039; and &#039;&#039;&#039;OnDetach()&#039;&#039;&#039;, etc.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Some event functions will be specific to each device, like when a tag is read on an RFID board, or when a sensor value changes on an Interface Kit.&lt;br /&gt;
Other functions are given in the examples to show you more detail on using your Phidget.  For example, &#039;&#039;&#039;DeviceInitialize()&#039;&#039;&#039; will show what needs to be set up for your Phidget before using it.&lt;br /&gt;
|Creating a Phidget software object in Adobe Director is specific to the Phidget.  For a Phidget Spatial, for example, this would involve creating a {{Code|Spatial}} ActiveX object.  The examples show how to do this and other API functions.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
The object provides device specific methods and properties which are available from the API for your specific Phidget.|&lt;br /&gt;
[http://www.phidgets.com/documentation/COM_API_Manual.pdf COM API]}}&lt;br /&gt;
&lt;br /&gt;
==Code Snippets==&lt;br /&gt;
&lt;br /&gt;
==Common Problems and Solutions/Workarounds==&lt;br /&gt;
&lt;br /&gt;
==={{ProblemSolution|Windows users in Netherlands|The examples are mislukken}}===&lt;br /&gt;
&lt;br /&gt;
Our examples are unsupported to all users in the country of Netherlands. Sorry!  We do not currently know why; a Director version problem is suspected.  As we aren&#039;t able to run a Netherlands version outside of the Netherlands, this makes the problem very difficult to debug.  If you would like to help us work through the example code that we provide and help us figure out why, please contact us.&lt;/div&gt;</summary>
		<author><name>Djrudiak</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=Language_-_Simulink&amp;diff=19152</id>
		<title>Language - Simulink</title>
		<link rel="alternate" type="text/html" href="https://www.phidgets.com/docs21/index.php?title=Language_-_Simulink&amp;diff=19152"/>
		<updated>2012-04-20T17:19:55Z</updated>

		<summary type="html">&lt;p&gt;Djrudiak: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Language]]&lt;br /&gt;
{{OSLang|[[File:icon-Simulink.png|64x64px]]|Preamble about the language&#039;s origin and its main characteristics.}}&lt;br /&gt;
==Support==&lt;br /&gt;
Simulink 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;
* 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;
* 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/cdoc/index.html API Reference]&lt;br /&gt;
* [http://www.phidgets.com/downloads/examples/Simulink_2.1.8.20110615.zip Simulink 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;
Due to the nature of Simulink, some function calls and Phidget classes may not be supported. &lt;br /&gt;
These will be discussed later in the tutorial.&lt;br /&gt;
&lt;br /&gt;
Simulink offers several different types of user defined blocks that can interact with MATLAB or C code. &lt;br /&gt;
This tutorial will use MATLAB code to demonstrate how user defined functions can be used to interact with Phidgets through the use of MATLAB Fcn, M Level 1 S Functions, and M Level 2 S Function blocks. &lt;br /&gt;
As writing C code is beyond the scope of this guide, C S Function blocks will not be discussed. &lt;br /&gt;
However, C S Function blocks work similar to M S Function blocks. &lt;br /&gt;
 &lt;br /&gt;
MATLAB Fcn blocks are the easiest blocks to use, but have limited features(i.e., only 1 input port). &lt;br /&gt;
Level 1 S Functions blocks have more featues, but are more complicated to implement. Level 2 S Functions blocks are the most complex, but benefit in supporting the most features. &lt;br /&gt;
   &lt;br /&gt;
This tutorial will assume the reader is familiar with Simulink, Simulink user defined functions and interacting with Phidgets using MATLAB. &lt;br /&gt;
For more information about interacting with Phidgets using MATLAB, please see the [[Language - MATLAB#Getting Started|Getting Started Guide for MATLAB]]. &lt;br /&gt;
&lt;br /&gt;
===Setting up a Phidgets Project===&lt;br /&gt;
&lt;br /&gt;
The Phidget examples were written using Simulink 6.1/MATLAB 7 in Windows XP. &lt;br /&gt;
Other recent versions should work as well and would be set up in a similar manner. &lt;br /&gt;
To begin, &lt;br /&gt;
* The first step is to set the path for phidget21Matlab.h in MATLAB(File-&amp;gt;Set Path). The phidget21Matlab.h can be found in the MATLAB examples.&lt;br /&gt;
* Launch MATLAB and enter “simulink” in the MATLAB command window to open up the Simulink Library Browser.&lt;br /&gt;
* Create a new model&lt;br /&gt;
The project now has access to Phidgets and we are ready to begin coding.&lt;br /&gt;
&lt;br /&gt;
===Connecting to the Phidget===&lt;br /&gt;
&lt;br /&gt;
The Phidget object will need to be declared and initialized. &lt;br /&gt;
For example, we can declare and initialize an instance of a PhidgetInterfaceKit inside a M file of a Level 1 S Function block with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight lang=cpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    global handle;&lt;br /&gt;
    loadlibrary(&#039;phidget21&#039;, &#039;phidget21Matlab.h&#039;);&lt;br /&gt;
    ptr = libpointer(&#039;int32Ptr&#039;,0);&lt;br /&gt;
    calllib(&#039;phidget21&#039;, &#039;CPhidgetInterfaceKit_create&#039;, ptr);&lt;br /&gt;
    handle = get(ptr, &#039;Value&#039;);&lt;br /&gt;
    calllib(&#039;phidget21&#039;, &#039;CPhidget_open&#039;, handle, -1)&lt;br /&gt;
    calllib(&#039;phidget21&#039;, &#039;CPhidget_waitForAttachment&#039;, handle, 2500)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The handle variable is declared as a global, and can be easily accessed by other blocks. &lt;br /&gt;
Since blocks repeatedly run until the simulation is completed, the above code will need to be restricted so that it runs only once during a simulation. &lt;br /&gt;
It is placed inside the mdlInitializeSizes function. &lt;br /&gt;
At the end of the simulation, the Phidget object will need to be closed and deleted. &lt;br /&gt;
The folowing lines are added to mdlTerminate. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight lang=cpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    calllib(&#039;phidget21&#039;, &#039;CPhidget_close&#039;, handle);&lt;br /&gt;
    calllib(&#039;phidget21&#039;, &#039;CPhidget_delete&#039;, handle);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Working directly with the Phidget===&lt;br /&gt;
&lt;br /&gt;
In this section, a MATLAB Fcn block will be used to set the output states of the digital output ports on a PhidgetInterfaceKit 8/8/8. &lt;br /&gt;
The following code is placed inside a M file. &lt;br /&gt;
The block’s input is the desired output state. &lt;br /&gt;
    &lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight lang=cpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    function setOutputStates(outputState)&lt;br /&gt;
        global handle;&lt;br /&gt;
        for i = 0:7&lt;br /&gt;
            if (calllib(&#039;phidget21&#039;, &#039;CPhidgetInterfaceKit_setOutputState&#039;, handle, i, outputState) == 1)&lt;br /&gt;
                display(&#039;Set output state failed&#039;)&lt;br /&gt;
       &lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that this handle is the same handle that was created earlier.&lt;br /&gt;
Next, a M Level 2 S Function will be used to retrieve sensor values of analog sensor ports and output it to a scope. &lt;br /&gt;
The block will contain no inputs and 1 output, with 8 dimensions(1 dimension for each analog sensor of a PhidgetInterfaceKit 8/8/8). &lt;br /&gt;
The following code is placed in the Output function in the M file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight lang=cpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    function Output(block)&lt;br /&gt;
        dataptr = libpointer(&#039;int32Ptr&#039;,0);&lt;br /&gt;
        global handle;&lt;br /&gt;
        for i = 0:7&lt;br /&gt;
            if (calllib(&#039;phidget21&#039;, &#039;CPhidgetInterfaceKit_getSensorValue&#039;, handle, i, dataptr) == 0)&lt;br /&gt;
                block.OutputPort(1).Data(i+1) = get(dataptr, &#039;Value&#039;);&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Event Driven Programming===&lt;br /&gt;
&lt;br /&gt;
MATLAB and Simulink do not support event handling.&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 model. &lt;br /&gt;
Each instance of a Phidget corresponding to a particular handle. &lt;br /&gt;
Create more handles to work with more Phidgets. 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;
===Working with Strings===&lt;br /&gt;
&lt;br /&gt;
It is possible for a user to specify a string of characters in the block parameters dialog box of a user defined function such that it is passed into a user defined function. &lt;br /&gt;
Please see the PhidgetInterfaceKit_RemoteIP block library in the Simulink examples for details.&lt;br /&gt;
Simulink cannot display strings in the GUI, however it is possible to write a C S function that displays strings in the MATLAB console.  &lt;br /&gt;
&lt;br /&gt;
===Working in Real Time===&lt;br /&gt;
&lt;br /&gt;
Even though a model may finish simulating before a user has a chance to interact with Phidgets, there are workarounds that can be used to slow down simulation time to allow for user interaction. &lt;br /&gt;
One method is to modify the Solver Options(under Simulation-&amp;gt;Configuration Parameters-&amp;gt;Solver). &lt;br /&gt;
Changing the step size and stop time may slow down the simulation. Another method is to implement a user defined function that reduces the simulation speed until the system clock matches the Simulink clock. &lt;br /&gt;
The Phidget Simulink example uses the “Real Time Block” to simulate the model in approximate real time. &lt;br /&gt;
For more information about the “Real Time Block”, please see &lt;br /&gt;
&lt;br /&gt;
http://www.mathworks.com/support/solutions/en/data/1-15JAW/&lt;br /&gt;
&lt;br /&gt;
To use the “Real Time Block”, place the following files in your MATLAB working directory: slblocks.m, rtc.mdl, waitforreal.m. &lt;br /&gt;
These files can be found in the Simulink examples. &lt;br /&gt;
Open up the Simulink Library Browser and select “Real Time Clock”. &lt;br /&gt;
Place the Real Time Clock block onto your model. &lt;br /&gt;
&lt;br /&gt;
For applications where accurate real time simuation is needed, xPC Target can be used. &lt;br /&gt;
&lt;br /&gt;
Please note that the simulation speed of these methods may differ depending on the CPU speed, complexity of the model, the amount of text being displayed in the MATLAB console, etc....&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>Djrudiak</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=Language_-_MATLAB&amp;diff=19151</id>
		<title>Language - MATLAB</title>
		<link rel="alternate" type="text/html" href="https://www.phidgets.com/docs21/index.php?title=Language_-_MATLAB&amp;diff=19151"/>
		<updated>2012-04-20T17:16:51Z</updated>

		<summary type="html">&lt;p&gt;Djrudiak: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Language]]&lt;br /&gt;
{{OSLang|[[File:Icon-Matlab.png|64x64px]]|MATLAB is a scientific and numerical analysis oriented language, with many graphical libraries and a wide user base.}}&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
{{LanguageSupport|MATLAB|the non-[[General Phidget Programming#Event Driven Code|event driven]] part of the Phidget API|AdvancedServo, Encoder, InterfaceKit, Servo and Stepper.|any operating system that can run MATLAB code|}}&lt;br /&gt;
&lt;br /&gt;
If you want to use the events provided by the Phidget library (for, say, collecting sensor data as it changes) then consider using Python as a wrapper.  Python has many libraries which can provide MATLAB-like functionality, such as:&lt;br /&gt;
* MatplotLib (plotting functions very similar to MATLAB)&lt;br /&gt;
* NumPy (array functions similar to MATLAB)&lt;br /&gt;
* SciPy (scientific functions similar to MATLAB libraries)&lt;br /&gt;
&lt;br /&gt;
There is also Pytave, which interfaces with Octave, which can read .m files.  Using the list of libraries above would &#039;&#039;&#039;mimic&#039;&#039;&#039; MATLAB abilities in Python.  Using Pytave would allow you to open most MATLAB code directly, as long as it works on Octave.  In both of these cases, you would use the [[Language - Python | Python Phidget libraries]], and Python as your main Phidget programming language, not MATLAB.  Python has excellent [http://python.org/ web documentation], and it is interpreted like MATLAB so there is no need to compile.&lt;br /&gt;
&lt;br /&gt;
We do not support Octave.  Phidgets in MATLAB depend on the &amp;lt;code&amp;gt;calllib()&amp;lt;/code&amp;gt; function, which Octave does not have.  For workarounds, see our [[#Common Problems and Solutions|common problems]] section.  Also, the {{Code|calllib}} library uses our C libraries, so programming in MATLAB for Phidgets uses the C API.&lt;br /&gt;
&lt;br /&gt;
==Quick Downloads==&lt;br /&gt;
{{QuickDownloads|MATLAB|&lt;br /&gt;
{{APIQuickDownloads|http://www.phidgets.com/documentation/Phidget21_C_Doc.zip}}|&lt;br /&gt;
{{ExampleQuickDownloads|http://www.phidgets.com/downloads/examples/Matlab_2.1.8.20110615.zip MATLAB|}}|&lt;br /&gt;
{{ExtraLibraryQuickDownloads|http://www.phidgets.com/downloads/libraries/Matlab_2.1.8.20110615.zip|MATLAB (Windows and Mac)|}}&lt;br /&gt;
{{WindowsQuickDownloads}}&lt;br /&gt;
{{MacQuickDownloads}}&lt;br /&gt;
{{LinuxQuickDownloads}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Quick Downloads==&lt;br /&gt;
&lt;br /&gt;
Just need the MATLAB drivers, libraries, and examples?  Here they are.  &lt;br /&gt;
&lt;br /&gt;
* [http://www.phidgets.com/downloads/examples/Matlab_2.1.8.20110615.zip MATLAB Sample Code], including the &#039;&#039;&#039;&amp;lt;code&amp;gt;phidget21Matlab.h&amp;lt;/code&amp;gt;&#039;&#039;&#039; library file, needed for any MATLAB project.&lt;br /&gt;
&lt;br /&gt;
MATLAB depends on the C/C++ libraries, and all MATLAB calls essentially call functions in the C library.  So. you need the C/C++ drivers and libraries, and you may also find the C/C++ API reference handy:&lt;br /&gt;
*[http://www.phidgets.com/documentation/Phidget21_C_Doc.zip C/C++ API Manual Download] or [http://www.phidgets.com/documentation/web/cdoc/index.html (HTML online version)]&lt;br /&gt;
*[[General API]] (more help on functions common to all Phidgets)&lt;br /&gt;
*[[Device List | Device Specific APIs]] (more help on functions specific to your Phidget)&lt;br /&gt;
&lt;br /&gt;
Libraries and Drivers which MATLAB depends on:&lt;br /&gt;
*[http://www.phidgets.com/downloads/libraries/phidget21-x86_2.1.8.20110615.zip 32 bit Windows (drivers, with libraries)]&lt;br /&gt;
*[http://www.phidgets.com/downloads/libraries/phidget21-x64_2.1.8.20110615.zip 64 bit Windows (drivers, with libraries)]&lt;br /&gt;
*[http://www.phidgets.com/downloads/libraries/libphidget_2.1.8.20111028.tar.gz General Linux Libraries] ([[OS - Linux | Linux Library Setup Instructions]])&lt;br /&gt;
*[http://www.phidgets.com/downloads/libraries/Phidget_2.1.8.20111103.dmg General Mac OSX Libraries] ([[OS - Mac OSX | Mac OSX Library Setup Instructions]])&lt;br /&gt;
&lt;br /&gt;
==Getting Started with MATLAB (Windows 2000/XP/Vista/7)==&lt;br /&gt;
&lt;br /&gt;
If you are new to writing code for Phidgets, we recommend starting by running, then modifying existing examples. This will allow you to:&lt;br /&gt;
{{ExampleCodeReasons}}&lt;br /&gt;
&lt;br /&gt;
===Use Our Examples===&lt;br /&gt;
&lt;br /&gt;
Start by using and modifying existing examples.  You can find the MATLAB example code here:&lt;br /&gt;
&lt;br /&gt;
*[http://www.phidgets.com/downloads/examples/Matlab_2.1.8.20111028.zip MATLAB Examples]&lt;br /&gt;
&lt;br /&gt;
If you are using a 64 bit version of Windows, a small modification to the {{Code|phidget21Matlab.h}} will be required to use our examples or writing your own code. Please add the following lines to the beginning of the file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  #ifndef WIN32 &lt;br /&gt;
  #define __stdcall&lt;br /&gt;
  #endif&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To run the example code, you&#039;ll need to unpack the download and find the source code &#039;&#039;for your specific device&#039;&#039; within the example package.  The file you need will be named something similar to your device name.  Once you have found the file that runs your device, copy that .m source file &#039;&#039;&#039;and&#039;&#039;&#039; phidget21Matlab.h from the examples folder to your project directory.   Then, run the code within MATLAB as you would any .m file.  For example, from the MATLAB command line, to run the example that reads the analog input from a Phidget Interface Kit:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=matlab&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  run analogin.m&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will allow you to:&lt;br /&gt;
{{ExampleCodeReasons}}&lt;br /&gt;
&lt;br /&gt;
If you receive an error regarding that the selected compiler cannot be found.&lt;br /&gt;
&lt;br /&gt;
[[File:MATLAB Win Compiler Error.png|link=|alt=Compile cannot be found]]&lt;br /&gt;
&lt;br /&gt;
You will have to to configure your compiler for MATLAB by entering the following command in the MATLAB command window:&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=matlab&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  mex -setup&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;
[[File:MATLAB Win Mex Setup.png|link=|alt=Mex Setup]]&lt;br /&gt;
&lt;br /&gt;
Next, select {{Code|y}} to view all installed compilers.&lt;br /&gt;
&lt;br /&gt;
[[File:MATLAB Win Choose Your Compiler.png|link=|alt=Choose your Compiler]]&lt;br /&gt;
&lt;br /&gt;
Finally, select the compiler you wish MATLAB to use. &lt;br /&gt;
&lt;br /&gt;
[[File:MATLAB Win Mex Setup Output.png|link=|alt=Mex Setup Output]]&lt;br /&gt;
&lt;br /&gt;
===Write Your Own Code===&lt;br /&gt;
&lt;br /&gt;
You can write your MATLAB code the same way you usually do, whether within a text editor or within MATLAB itself.  However, to use Phidget calls within your code, you must include a reference to the Phidget library in your main body of code, before any Phidget calls:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=matlab&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  function phidgettest(n)&lt;br /&gt;
     loadlibrary phidget21 phidget21Matlab.h;&lt;br /&gt;
      % More code goes here&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, before running your code, remember to &#039;&#039;&#039;copy phidget21Matlab.h to your project directory&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==Getting Started with MATLAB (Mac OS)==&lt;br /&gt;
&lt;br /&gt;
If you are new to writing code for Phidgets, we recommend starting by running, then modifying existing examples. This will allow you to:&lt;br /&gt;
{{ExampleCodeReasons}}&lt;br /&gt;
&lt;br /&gt;
===Use Our Examples===&lt;br /&gt;
&lt;br /&gt;
Due to different library naming conventions, as well as different compiler support for the behind-the-scenes libraries, you will have to make two small modifications to our MATLAB examples to run them on Mac OS.&lt;br /&gt;
&lt;br /&gt;
Instructions will differ depending on whether you are using a 32 or 64 bit system.  &lt;br /&gt;
&lt;br /&gt;
For, &amp;lt;b&amp;gt;32 bit systems&amp;lt;/b&amp;gt;, you need to make one change to {{Code|phidget21Matlab.h}}, by adding the following to the top of the file: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  #ifndef WIN32 &lt;br /&gt;
  #define __stdcall&lt;br /&gt;
  #endif&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and keep it in the same folder where you will run the example.&lt;br /&gt;
&lt;br /&gt;
This change simply defines __stdcall to be nothing. The __stdcall function is not supported on a Mac because it is not supported by the library compiler gcc. Removing the __stdcall definition will simply call the Phidget functions in a raw manner rather than having the stack managed by the function itself. &lt;br /&gt;
&lt;br /&gt;
The next change is to the example {{Code|.m}} source code file you are using.  In all of the example code {{Code|.m}} files, there is a line near the very top (line 4 or so) that says:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=matlab&amp;gt;&lt;br /&gt;
loadlibrary phidget21 phidget21Matlab.h;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=matlab&amp;gt;&lt;br /&gt;
loadlibrary (&#039;phidget21&#039;, &#039;phidget21Matlab.h&#039;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On Mac OS, this needs to be changed to:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=matlab&amp;gt;&lt;br /&gt;
loadlibrary /Library/frameworks/Phidget21.framework/Versions/Current/Phidget21 phidget21Matlab.h alias phidget21&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The location of {{Code|Phidget21}} should be the actual location of the Phidget libraries on your system.  If you just did a default install, the locations as written above should be fine.  Otherwise, find the libraries (use a search or locate function from the command line or operating system) and substitute their actual location.&lt;br /&gt;
&lt;br /&gt;
These changes are needed because the Phidget libraries are named differently on Mac OS than they are on Windows.  On Windows, the {{Code|loadlibrary}} function looks for a &#039;&#039;phidget21&#039;&#039;.dll file and links it to the phidget21 alias used throughout the MATLAB program.  This alias linking happens automatically because the library and the alias have the same name, including capitalization.&lt;br /&gt;
&lt;br /&gt;
On Mac OS, however, the library to be linked is the executable {{Code|Phidget21}}.  Because it does not have exactly the same name as &#039;&#039;phidget21&#039;&#039; (which is used as the alias in the rest of the {{Code|.m}} code), you have to link it and alias it explicitly.&lt;br /&gt;
&lt;br /&gt;
Without these changes, the errors that appear can be quite strange.  They show up as file-not-found errors, ELF-header errors, or simply {{Code|evalin()}} errors, depending on whether you&#039;ve changed the phidget21Matlab.h file, the path, the file, or none of the above.  The file-not-found error looks like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=text&amp;gt;&lt;br /&gt;
Error in ==&amp;gt; digitalout at 3&lt;br /&gt;
loadlibrary phidget21 phidget21Matlab.h;&lt;br /&gt;
&lt;br /&gt;
Error in ==&amp;gt; run at 74&lt;br /&gt;
    evalin(&#039;caller&#039;,[script &#039;;&#039;]);&lt;br /&gt;
&lt;br /&gt;
Caused by:&lt;br /&gt;
    Error using ==&amp;gt; loaddefinedlibrary&lt;br /&gt;
    phidget21.so: cannot open shared object file: No such file or directory&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The phidget21Matlab.h file should be either in the current project directory, or in a MATLAB path (type {{Code|path}} in MATLAB to see the current setup).  If you prefer to use parentheses and quotations for aliasing (to keep your formatting strict), you can read about the various syntax options for the {{Code|loadlibrary}} function on the [http://www.mathworks.com/help/techdoc/ref/loadlibrary.html MathWorks website].&lt;br /&gt;
&lt;br /&gt;
Once you have made the changes above to both the {{Code|phidget21Matlab.h}} file and the {{Code|*.m}} example file you want to run, running the example you want is easy.  Just put the {{Code|*.m}} example and the {{Code|phidget21Matlab.h}} file into your current directory in Matlab, and type the example name.&lt;br /&gt;
&lt;br /&gt;
For instance, to use the {{Code|analogin.m}} example to read analog in data from a Phidget Interface Kit, you can just type it on the MATLAB command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=text&amp;gt;&lt;br /&gt;
&amp;lt; M A T L A B (R) &amp;gt;&lt;br /&gt;
Copyright 1984-2012 The MathWorks, Inc.&lt;br /&gt;
R2012a (7.14.0.739) 64-bit (glnxa64)&lt;br /&gt;
February 9, 2012&lt;br /&gt;
 &lt;br /&gt;
To get started, type one of these: helpwin, helpdesk, or demo.&lt;br /&gt;
For product information, visit www.mathworks.com.&lt;br /&gt;
 &lt;br /&gt;
&amp;gt;&amp;gt; analogin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For &amp;lt;b&amp;gt;64 bit systems&amp;lt;/b&amp;gt;, the {{Code|phidget21Matlab.h}} will differ slightly from the 32 bit version. Download the 64 bit version of {{Code|phidget21Matlab.h}}, and change the following line:&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  typedef void* CPhidgetHandle;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with:&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  typedef long long CPhidgetHandle;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The next change is to the example {{Code|.m}} source code file you are using.  In all of the example code {{Code|.m}} files, there is a line near the very top (line 4 or so) that says:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=matlab&amp;gt;&lt;br /&gt;
loadlibrary phidget21 phidget21Matlab.h;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=matlab&amp;gt;&lt;br /&gt;
loadlibrary (&#039;phidget21&#039;, &#039;phidget21Matlab.h&#039;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On Mac OS, this needs to be changed to:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=matlab&amp;gt;&lt;br /&gt;
loadlibrary /Library/frameworks/Phidget21.framework/Versions/Current/Phidget21 phidget21Matlab.h alias phidget21&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The location of {{Code|Phidget21}} should be the actual location of the Phidget libraries on your system.  If you just did a default install, the locations as written above should be fine.  Otherwise, find the libraries (use a search or locate function from the command line or operating system) and substitute their actual location.&lt;br /&gt;
&lt;br /&gt;
The pointer data type of the PhidgetHandle will also need to be changed. Replace the following:&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  ptr = libpointer(&#039;int32Ptr&#039;,0);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  ptr = libpointer(&#039;int64Ptr&#039;,0);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The phidget21Matlab.h file should be either in the current project directory, or in a MATLAB path (type {{Code|path}} in MATLAB to see the current setup).  If you prefer to use parentheses and quotations for aliasing (to keep your formatting strict), you can read about the various syntax options for the {{Code|loadlibrary}} function on the [http://www.mathworks.com/help/techdoc/ref/loadlibrary.html MathWorks website].&lt;br /&gt;
&lt;br /&gt;
Once you have made the changes above to both the {{Code|phidget21Matlab.h}} file and the {{Code|*.m}} example file you want to run, running the example you want is easy.  Just put the {{Code|*.m}} example and the {{Code|phidget21Matlab.h}} file into your current directory in Matlab, and type the example name.&lt;br /&gt;
&lt;br /&gt;
For instance, to use the {{Code|analogin.m}} example to read analog in data from a Phidget Interface Kit, you can just type it on the MATLAB command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=text&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
  &amp;gt;&amp;gt; analogin&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Write Your Own Code===&lt;br /&gt;
&lt;br /&gt;
You can write your MATLAB code the same way you usually do, whether within a text editor or within MATLAB itself.  However, to use Phidget calls within your code, you must include a reference to the Phidget library in your main body of code, before any Phidget calls.&lt;br /&gt;
&lt;br /&gt;
On Mac OS:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=matlab&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  function phidgettest(n)&lt;br /&gt;
     loadlibrary /Library/framework/Phidget21.framework/Versions/Current/Phidget21 phidget21Matlab.h alias phidget21&lt;br /&gt;
      % More code goes here&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Getting Started with MATLAB (Linux)==&lt;br /&gt;
&lt;br /&gt;
If you are new to writing code for Phidgets, we recommend starting by running, then modifying existing examples. This will allow you to:&lt;br /&gt;
{{ExampleCodeReasons}}&lt;br /&gt;
&lt;br /&gt;
===Use our Examples===&lt;br /&gt;
&lt;br /&gt;
====Step 1: Compile the MATLAB Library====&lt;br /&gt;
&lt;br /&gt;
In the [http://www.phidgets.com/downloads/libraries/libphidget_2.1.8.20120216.tar.gz Phidget Linux libraries] (not the MATLAB libraries) you have already have compiled the {{Code|phidget21.h}} for running all Phidgets on Linux.  There is &#039;&#039;another&#039;&#039; make target in those libraries to make the MATLAB library header file for your Linux system.&lt;br /&gt;
&lt;br /&gt;
To make this MATLAB library:&lt;br /&gt;
# Re-download the [http://www.phidgets.com/downloads/libraries/libphidget_2.1.8.20120216.tar.gz Phidget Linux libraries] if you have deleted the Phidget Library source code&lt;br /&gt;
#* If you re-download, also make the main {{Code|phidget21.h}} Phidget library as described on the [[OS - Linux]] page so the MATLAB library matches&lt;br /&gt;
#Then, in the source code directory where you ran {{Code|./configure}}, {{Code|make}}, and {{Code|make install}} for the main libraries, also run:&lt;br /&gt;
#:{{Code|make phidget21matlab.h}}&lt;br /&gt;
&lt;br /&gt;
This will generate a file called {{Code|phidget21matlab.h}} which you can rename to {{Code|phidget21Matlab.h}} so that it works with our examples:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=bash&amp;gt;&lt;br /&gt;
mv phidget21matlab.h phidget21Matlab.h&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, if you have an older library, you may have to add one line at the top of {{Code|phidget21Matlab.h}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=cpp&amp;gt;&lt;br /&gt;
typedef long long __int64;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you try running the examples as below, and something similar to this is not already in the {{Code|phidget21Matlab.h}} file, MATLAB will give you a series of fairly descriptive errors involving {{Code|__int64}}.  So you can also try running the examples and adding this if needed.&lt;br /&gt;
&lt;br /&gt;
And, on &#039;&#039;&#039;64-bit Linux systems&#039;&#039;&#039; with older libraries, you will need to change the line that says {{Code|typedef long CPhidgetHandle;}} to say either:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=cpp&amp;gt;&lt;br /&gt;
typedef long long CPhidgetHandle;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=cpp&amp;gt;&lt;br /&gt;
typedef void* CPhidgetHandle;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
....depending on how you want to typecast your Phidget handle within your code (if you are not sure, the first one should work fine).&lt;br /&gt;
&lt;br /&gt;
This changes the pointer type for the Phidget software object to be 64 bits, which is what your 64 bit machine will naturally create.&lt;br /&gt;
&lt;br /&gt;
====Step 2: Modify the Examples====&lt;br /&gt;
&lt;br /&gt;
Download the and unzip the [http://www.phidgets.com/downloads/examples/Matlab_2.1.8.20120216.zip Phidget examples for MATLAB].  Put the {{Code|phidget21Matlab.h}} header file that you just compiled into the unzipped example directory, overwriting the existing Windows/Mac {{Code|phidget21Matlab.h}} file that came with the examples.&lt;br /&gt;
&lt;br /&gt;
The next change is to the example {{Code|.m}} source code file you are using.  In all of the example code {{Code|.m}} files, there is a line near the very top (line 4 or so) that says:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=matlab&amp;gt;&lt;br /&gt;
loadlibrary phidget21 phidget21Matlab.h;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=matlab&amp;gt;&lt;br /&gt;
loadlibrary (&#039;phidget21&#039;, &#039;phidget21Matlab.h&#039;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This needs to be changed to:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=matlab&amp;gt;&lt;br /&gt;
loadlibrary /usr/lib/libphidget21.so phidget21Matlab.h alias phidget21&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The location of {{Code|libphidget21.so}} should be the actual location of the Phidget libraries on your system.  If you just did a default install, the location as written above should be fine.  Otherwise, find the libraries (use a search or locate function from the command line or operating system) and substitute the actual location.&lt;br /&gt;
&lt;br /&gt;
These changes are needed because the Phidget libraries are named differently on Linux than they are on Windows.  On Windows, the {{Code|loadlibrary}} function looks for a &#039;&#039;phidget21&#039;&#039;.dll file and links it to the phidget21 alias used throughout the MATLAB program.  This alias linking happens automatically because the library and the alias have the same name, including capitalization.&lt;br /&gt;
&lt;br /&gt;
On Linux, however, the library to be linked is the executable {{Code|libphidget21.so}}.  Because it does not have exactly the same name as &#039;&#039;phidget21&#039;&#039; (which is used as the alias in the rest of the {{Code|.m}} code), you have to link it and alias it explicitly.&lt;br /&gt;
&lt;br /&gt;
Without these changes, the errors that appear can be quite strange.  They show up as file-not-found errors, ELF-header errors, or simply {{Code|evalin()}} errors, depending on whether you&#039;ve changed the phidget21Matlab.h file, the path, the file, or none of the above.  The file-not-found error looks like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=text&amp;gt;&lt;br /&gt;
Error in ==&amp;gt; digitalout at 3&lt;br /&gt;
loadlibrary phidget21 phidget21Matlab.h;&lt;br /&gt;
&lt;br /&gt;
Error in ==&amp;gt; run at 74&lt;br /&gt;
    evalin(&#039;caller&#039;,[script &#039;;&#039;]);&lt;br /&gt;
&lt;br /&gt;
Caused by:&lt;br /&gt;
    Error using ==&amp;gt; loaddefinedlibrary&lt;br /&gt;
    phidget21.so: cannot open shared object file: No such file or directory&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On a &#039;&#039;&#039;64-bit Linux&#039;&#039;&#039; system, you will need to change the Phidget handle within the example to be a 64 bit pointer, matching the {{Code|phidget21Matlab.h}} file.  For example, in the {{Code|analogin.m}} example, the line that says &amp;lt;code&amp;gt;ptr = libpointer(&#039;int32Ptr&#039;,0);&amp;lt;/code&amp;gt; to say:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=matlab&amp;gt;&lt;br /&gt;
ptr = libpointer(&#039;int64Ptr&#039;,0);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Step 3: Run the Examples====&lt;br /&gt;
&lt;br /&gt;
The compiled and edited {{Code|phidget21Matlab.h}} file should be either in the current project directory, or in a MATLAB path (type {{Code|path}} in MATLAB to see the current setup).  If you prefer to use parentheses and quotations for aliasing (to keep your formatting strict), you can read about the various syntax options for the {{Code|loadlibrary}} function on the [http://www.mathworks.com/help/techdoc/ref/loadlibrary.html MathWorks website].&lt;br /&gt;
&lt;br /&gt;
Once you have made the changes above to both the {{Code|phidget21Matlab.h}} file and the {{Code|*.m}} example file you want to run, running the example you want is easy.  Just put the {{Code|*.m}} example and the {{Code|phidget21Matlab.h}} file into your current directory in Matlab, and type the example name.&lt;br /&gt;
&lt;br /&gt;
For instance, to use the {{Code|analogin.m}} example to read analog in data from a Phidget Interface Kit, you can just type it on the MATLAB command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=text&amp;gt;&lt;br /&gt;
&amp;lt; M A T L A B (R) &amp;gt;&lt;br /&gt;
Copyright 1984-2012 The MathWorks, Inc.&lt;br /&gt;
R2012a (7.14.0.739) 64-bit (glnxa64)&lt;br /&gt;
February 9, 2012&lt;br /&gt;
 &lt;br /&gt;
To get started, type one of these: helpwin, helpdesk, or demo.&lt;br /&gt;
For product information, visit www.mathworks.com.&lt;br /&gt;
 &lt;br /&gt;
&amp;gt;&amp;gt; analogin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Write Your Own Code===&lt;br /&gt;
&lt;br /&gt;
You can write your MATLAB code the same way you usually do, whether within a text editor or within MATLAB itself.  However, to use Phidget calls within your code, you must include a reference to the Phidget library in your main body of code, before any Phidget calls.&lt;br /&gt;
&lt;br /&gt;
And on Linux:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=matlab&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  function phidgettest(n)&lt;br /&gt;
     loadlibrary /usr/lib/libphidget21.so phidget21Matlab.h alias phidget21&lt;br /&gt;
      % More code goes here&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, before running your code, remember to &#039;&#039;&#039;copy phidget21Matlab.h to your project directory&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==Follow The Examples==&lt;br /&gt;
&lt;br /&gt;
By following the instructions above, you probably now have a working example and want to understand it better so you can change it to do what you want. This section has resources for you to learn from the examples and write your own.&lt;br /&gt;
&lt;br /&gt;
Programming with Phidgets in MATLAB makes extensive use of the &#039;&#039;&#039;calllib()&#039;&#039;&#039; function to the C/C++ library, so the C/C++ API reference will be helpful:&lt;br /&gt;
&lt;br /&gt;
{{UsingAPhidgetInCodeGeneral|although you can only use the logic code type design in MATLAB|[http://www.phidgets.com/documentation/Phidget21_C_Doc.zip C/C++ API]}}&lt;br /&gt;
&lt;br /&gt;
If you find yourself wanting to use event functions in the API (which are not available in MATLAB), try using Python as described in the [[#Support | support]] section at the top of this page.&lt;br /&gt;
&lt;br /&gt;
===Code Snippets===&lt;br /&gt;
&lt;br /&gt;
Specific calls in MATLAB will differ in syntax from those on the [[General Phidget Programming]] page, but the concepts stay the same.  &lt;br /&gt;
&lt;br /&gt;
It may help to have the [[General Phidget Programming]] page and this section open at the same time, because they parallel each other and you can refer to the MATLAB syntax.  However, many additional concepts are covered on the General Phidget Programming page on a high level, such as using multiple Phidgets, handling errors, and different styles of programming.&lt;br /&gt;
&lt;br /&gt;
For example, if we were using a [[Product - 1018 - PhidgetInterfaceKit 8/8/8 | Phidget Interface Kit]] as our device, the general calls would look like this:&lt;br /&gt;
&lt;br /&gt;
====Step One: Initialize and Open====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=matlab&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  devicePointer = libpointer(&#039;int32Ptr&#039;,0);&lt;br /&gt;
  calllib(&#039;phidget21&#039;, &#039;CPhidgetInterfaceKit_create&#039;, devicePointer);&lt;br /&gt;
  device = get(devicePointer, &#039;Value&#039;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The devicePointer is converted to the handle &#039;&#039;&#039;device&#039;&#039;&#039; as a handle for the Phidget.  This example is &#039;&#039;specific to the Interface Kit&#039;&#039; because the call CPhidgetInterfaceKit_create is used.  For another device, use the correspondingly named call in the C/C++ API. &lt;br /&gt;
&lt;br /&gt;
The handle &#039;&#039;&#039;device&#039;&#039;&#039; is then used for all the C function calls where CPhidgetHandle phid is used in the C/C++ API.  Every type of Phidget also inherits functionality from the Phidget base class.&lt;br /&gt;
&lt;br /&gt;
Note that open() opens the software object, but not hardware.  So, it is not a guarantee you can use the Phidget immediately.&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. The API manual lists all of the available modes that open provides. &lt;br /&gt;
&lt;br /&gt;
====Step Two: Wait for Attachment (plugging in) of the Phidget==== &lt;br /&gt;
&lt;br /&gt;
To use the Phidget, it must be plugged in (attached).  We can handle this by calling waitForAttachment. This function works for any Phidget. 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 class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=matlab&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  calllib(&#039;phidget21&#039;, &#039;CPhidget_open&#039;, device, -1);&lt;br /&gt;
  if calllib(&#039;phidget21&#039;, &#039;CPhidget_waitForAttachment&#039;, device, 2500) == 0&lt;br /&gt;
     % Insert your code here&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Step Three: Do Things with the Phidget====&lt;br /&gt;
&lt;br /&gt;
MATLAB does not support event handling, so all data must be read and sent directly. &lt;br /&gt;
&lt;br /&gt;
The most common thing you might want to do is read data from sensors.  For example, in the code below, we might want to read data from a sensor on the [[Product - 1018 - PhidgetInterfaceKit 8/8/8 | Phidget Interface Kit]].&lt;br /&gt;
&lt;br /&gt;
Simply use the C API functions such as CPhidgetInterfaceKit_getSensorValue() or CPhidgetInterfaceKit_setOutState() for Interface Kits.  The following reads and displays data from a sensor ten times as quickly as the while loop can execute: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=matlab&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  while n&amp;lt;10&lt;br /&gt;
    dataPointer = libpointer(&#039;int32Ptr&#039;,0);&lt;br /&gt;
    calllib(&#039;phidget21&#039;, &#039;CPhidgetInterfaceKit_getSensorValue&#039;, device, 0, dataPointer)&lt;br /&gt;
    disp(get(dataPointer, &#039;Value&#039;));&lt;br /&gt;
    n=n+1;&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Step Four: Close and Delete====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=matlab&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  calllib(&#039;phidget21&#039;, &#039;CPhidget_close&#039;, ikhandle);&lt;br /&gt;
  calllib(&#039;phidget21&#039;, &#039;CPhidget_delete&#039;, ikhandle);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At the end of your program, don’t forget to call close to free any locks on the Phidget that the open() call put in place!&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;complete&#039;&#039; set of functions you have available for all Phidgets can be found in the [http://www.phidgets.com/documentation/Phidget21_C_Doc.zip C/C++ API].  Note, however, MATLAB does not make use of the event functions in the C/C++ API. You can also find more description on any device-specific function either in the [[Device List|Device API]] page for calls available only on your specific Phidget.&lt;br /&gt;
&lt;br /&gt;
==Common Problems and Solutions==&lt;br /&gt;
{{ProblemSolution|Octave Problem|The function calls loadlibrary() and callib() are not supported in Octave}}&lt;br /&gt;
&lt;br /&gt;
Likely Fix: As use of Phidgets in MATLAB requires these calls, the best is probably to choose a programming language that is not MATLAB.  You can choose [[Software Overview#Language Support|from many languages]] that we support.&lt;br /&gt;
&lt;br /&gt;
However, this may not be possible if, for example, you already have a lot of external code written in MATLAB that you would like to interface your Phidget with.  Here are a few suggestions to help you find a way to use your existing MATLAB code:&lt;br /&gt;
* Write your overall program in Python.  Python natively controls Phidgets, and you can use Pytave to interface between the Python Phidget code and your Octave code.  &lt;br /&gt;
* If you are using a version of Octave that Pytave does not support, write your program in Python as above.  Then, you can try reading your matlab code through R, and using RPy to interface with Python.&lt;br /&gt;
* External foreign linking libraries (Swig, FFCall) might be made to work...&lt;br /&gt;
&lt;br /&gt;
{{ProblemSolution|All Operating Systems|You get a warning: The library class &#039;libphidget21&#039; already exists.  Use a classname alias.}}&lt;br /&gt;
&lt;br /&gt;
Note that the {{Code|phidget21}} library is not unloaded at the end of our example {{Code|.m}} files.  This is because rapidly unloading the library just after linking it can cause problems in short programs.&lt;br /&gt;
&lt;br /&gt;
So, when you run the program again within the same MATLAB session, you will get this warning. Your code will still work, it is just that running the same code again loads the library again without closing it first.&lt;br /&gt;
&lt;br /&gt;
{{ProblemSolution|OS X|The examples do not run with Rosetta under OS X.}}&lt;br /&gt;
&lt;br /&gt;
The example programs uses the MATLAB {{Code|timer()}} call, which relies on the Java Virtual Machine. Since Rosetta does not support Java, the examples will not operate as expected.&lt;/div&gt;</summary>
		<author><name>Djrudiak</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=Language_-_LabVIEW&amp;diff=19150</id>
		<title>Language - LabVIEW</title>
		<link rel="alternate" type="text/html" href="https://www.phidgets.com/docs21/index.php?title=Language_-_LabVIEW&amp;diff=19150"/>
		<updated>2012-04-20T17:11:38Z</updated>

		<summary type="html">&lt;p&gt;Djrudiak: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Language]]&lt;br /&gt;
{{OSLang|[[File:icon-LabVIEW.png|64x64px|link=|alt=]]|LabVIEW, developed by [http://www.ni.com National Instruments] is dataflow programming language for data processing.}}&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
{{LanguageSupport|LabVIEW|the complete Phidget API, including events|all Phidget devices.| Windows. A minimum version of LabVIEW  7.1.1 is required to use the Phidget LabVIEW 32 bit library. For the Phidget LabVIEW 64 bit library, a minimum version of LabVIEW 2009 is required. OS X and Linux are unsupported as Phidgets have not been tested on those systems.|}}&lt;br /&gt;
&lt;br /&gt;
==Quick Downloads==&lt;br /&gt;
{{QuickDownloads|LabVIEW|&lt;br /&gt;
{{APIQuickDownloads|http://www.phidgets.com/documentation/LabVIEW_Manual.pdf}}|&lt;br /&gt;
{{ExampleQuickDownloads|http://www.phidgets.com/downloads/examples/LabVIEWx86_2.1.8.20120216.zip| (32 bit Windows - same file as LabVIEW library)}}&lt;br /&gt;
{{ExampleQuickDownloads|http://www.phidgets.com/downloads/examples/LabVIEWx64_2.1.8.20120216.zip| (64 bit Windows - same file as LabVIEW library)}}|&lt;br /&gt;
{{ExtraLibraryQuickDownloads|http://www.phidgets.com/downloads/examples/LabVIEWx86_2.1.8.20120216.zip|LabVIEW|(32 bit Windows - same file as LabVIEW Examples)}}&lt;br /&gt;
{{ExtraLibraryQuickDownloads|http://www.phidgets.com/downloads/examples/LabVIEWx64_2.1.8.20120216.zip|LabVIEW|(64 bit Windows - same file as LabVIEW Examples)}}&lt;br /&gt;
{{WindowsQuickDownloads}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Getting started with LabVIEW==&lt;br /&gt;
&lt;br /&gt;
If you are new to writing code for Phidgets, we recommend starting by running, then modifying existing examples. This will allow you to:&lt;br /&gt;
{{ExampleCodeReasons}}&lt;br /&gt;
&lt;br /&gt;
==Windows (2000/XP/Vista/7)==&lt;br /&gt;
&lt;br /&gt;
===Description of Library Files===&lt;br /&gt;
LabVIEW programs on Windows depend on the following two items, The installers in the [[#Libraries and Drivers|Quick Downloads]] section put only the {{Code|phidget21.dll}} into your system. You will need to manually put the Phidget LabVIEW library onto your system:&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|phidget21.dll}}&amp;lt;/b&amp;gt; contains the actual Phidget library, which is used at run-time.  By default, it is placed in {{Code|C:\Windows\System32}}.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|Phidgets LabVIEW library}}&amp;lt;/b&amp;gt; contains the Phidget library for LabVIEW. You need to place the library into your LabVIEW functions palette. Instructions are explained in the [[#Write Your Own Code | Write Your Own Code]] section.&lt;br /&gt;
&lt;br /&gt;
If you do not want to use our installer, you can download the [http://www.phidgets.com/downloads/libraries/phidget21-x86_2.1.8.20110615.zip {{Code|phidget21.dll}}] and manually install it where you want; refer to our [[OS_-_Windows#Manual_File_Installation | Manual Installation Instructions]].&lt;br /&gt;
&lt;br /&gt;
We include instructions for LabVIEW 2011 on [[#Use Our Examples | using our examples]] and [[#Write Your Own Code | writing your own code]].&lt;br /&gt;
&lt;br /&gt;
====Use Our Examples====&lt;br /&gt;
&lt;br /&gt;
To run the examples, you first download the examples found in the [[#Example Code | Quick Downloads]] section and unpack them into a folder. Here, you will find the {{Code|examples}} folder, which contains {{Code|vi}} programs for all the devices. Each {{Code|vi}} example demonstrate the usage of a few of the device&#039;s properties. To get a broader understanding of the device, you should take a look at all the  {{Code|vi}} examples inside the directory for your device. If you aren&#039;t sure what the software example for your device is called, check the software object listed in the [[Device List | Getting Started guide for your device]].&lt;br /&gt;
&lt;br /&gt;
1. Inside the {{Code|examples}} folder, navigate to the directory for your device. &lt;br /&gt;
&lt;br /&gt;
2. Open up any {{Code|.vi}} of your choice in LabVIEW. In this section, the {{Code|Sensor to Output Example.vi}} of the PhidgetInterfaceKit examples will be used. &lt;br /&gt;
&lt;br /&gt;
[[File:LabVIEW Win Front Panel.PNG|link=|alt=Front Panel]]&lt;br /&gt;
&lt;br /&gt;
You will see the front panel of the example. The front panel shows the user interface of the {{code|vi}} program.&lt;br /&gt;
&lt;br /&gt;
3. Next, let us take a look at the block diagram by navigating to {{Code|Window &amp;amp;rarr; Show Block  Diagram}}.&lt;br /&gt;
&lt;br /&gt;
[[File:LabVIEW Win Block Diagram 1.PNG|link=|alt=Block Diagram]]&lt;br /&gt;
&lt;br /&gt;
The block diagram shows the logic of the application.&lt;br /&gt;
&lt;br /&gt;
[[File:LabVIEW Win Block Diagram 2.PNG|link=|alt=Block Diagram]]&lt;br /&gt;
&lt;br /&gt;
4. The only thing left to do is to run the examples! Navigate to {{Code|Operate &amp;amp;rarr; Run}}.&lt;br /&gt;
&lt;br /&gt;
[[File:LabVIEW Win Run 1.PNG|link=|alt=Run]]&lt;br /&gt;
&lt;br /&gt;
5. The application will run. &lt;br /&gt;
&lt;br /&gt;
[[File:LabVIEW Win Run 2.PNG|link=|alt=Run]]&lt;br /&gt;
&lt;br /&gt;
You can determine that your device is connected to your application if you see the indicator for {{Code|attached}} turn green and the correct serial number is displayed. These features are available in most of the example {{Code|vis}} we provide.&lt;br /&gt;
 &lt;br /&gt;
6. When you are ready to terminate the application, click on the [[File:LabVIEW Win Stop.PNG|link=|alt=Stop]] button to release the hold on the device. Please keep in mind that the application may not terminate properly if you stop it by clicking on {{Code|Operate &amp;amp;rarr; Stop}}.&lt;br /&gt;
&lt;br /&gt;
Once you have the LabVIEW examples running, we have a [[#Follow the Examples|teaching]] section below to help you follow them.&lt;br /&gt;
&lt;br /&gt;
====Write Your Own Code====&lt;br /&gt;
&lt;br /&gt;
When you are building a project from scratch, or adding Phidget function calls to an existing project, you&#039;ll need to add the Phidget LabVIEW library to your development environment. To begin: &lt;br /&gt;
&lt;br /&gt;
1. Navigate to {{Code|Tools &amp;amp;rarr; Advanced &amp;amp;rarr; Edit Palette Set}} to modify the functions palette.&lt;br /&gt;
&lt;br /&gt;
[[File:LabVIEW Win Functions Palette 1.PNG|link=|alt=Edit Function Palette]]&lt;br /&gt;
&lt;br /&gt;
2. The functions palette will show up. Right click an empty area, and select {{Code|Insert &amp;amp;rarr; Subpalette}}. &lt;br /&gt;
&lt;br /&gt;
[[File:LabVIEW Win Functions Palette 2.PNG|link=|alt=Insert Function Palette]]&lt;br /&gt;
&lt;br /&gt;
3. Next, select {{Code|Link to a directory}}.&lt;br /&gt;
&lt;br /&gt;
[[File:LabVIEW Win Functions Palette 3.PNG|link=|alt=Link to a library]]&lt;br /&gt;
&lt;br /&gt;
4. Make sure you have the Phidget LabVIEW library and examples in the [[#Libraries and Drivers| Quick Downloads]] section downloaded and extracted. After extracting, you will find the {{Code|Phidgets}} folder. In LabVIEW, browse to the {{Code|Phidgets}} folder, and select {{Code|Current Folder}}. &lt;br /&gt;
&lt;br /&gt;
[[File:LabVIEW Win Functions Palette 4.PNG|link=|alt=Select Phidgets library]]&lt;br /&gt;
&lt;br /&gt;
This will load the Phidget LabVIEW library into the functions palette. You can find all the functions that pertain to Phidgets inside the {{Code|Phidgets}} palette. &lt;br /&gt;
&lt;br /&gt;
[[File:LabVIEW Win Functions Palette 5.PNG|link=|alt=Phidgets LabVIEW Library]]&lt;br /&gt;
&lt;br /&gt;
5. Click on {{Code|Save Changes}} in the {{Code|Edit Controls and Functions Palette Set}} window. &lt;br /&gt;
&lt;br /&gt;
[[File:LabVIEW Win Functions Palette 6.PNG|link=|alt=Save Function Palette]]&lt;br /&gt;
&lt;br /&gt;
The project now has access to the Phidget function calls and you are ready to begin coding.&lt;br /&gt;
&lt;br /&gt;
The same [[#Follow the Examples|teaching]] section which describes the examples also has further resources for programming your Phidget.&lt;br /&gt;
&lt;br /&gt;
==Follow the Examples==&lt;br /&gt;
&lt;br /&gt;
By following the instructions for your operating system and compiler above, you probably now have a working example and want to understand it better so you can change it to do what you want.  This teaching section has resources for you to learn from the examples and write your own.&lt;br /&gt;
&lt;br /&gt;
Next comes our API information, with syntax for all of our functions:&lt;br /&gt;
&lt;br /&gt;
{{UsingAPhidgetInCodeGeneral|both of which are available in LabVIEW|[http://www.phidgets.com/documentation/LabVIEW_Manual.pdf API Manual]}}&lt;br /&gt;
&lt;br /&gt;
==Common Problems and Solutions/Workarounds==&lt;br /&gt;
&lt;br /&gt;
{{KnownIssues|Phidgets do not always work cleanly in Labview.  Sometimes they do not appear, sometimes they work veeerrryyy slowly.  No known fixes yet, hopefully soon.}}&lt;/div&gt;</summary>
		<author><name>Djrudiak</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=Language_-_AutoIt&amp;diff=19149</id>
		<title>Language - AutoIt</title>
		<link rel="alternate" type="text/html" href="https://www.phidgets.com/docs21/index.php?title=Language_-_AutoIt&amp;diff=19149"/>
		<updated>2012-04-20T17:10:20Z</updated>

		<summary type="html">&lt;p&gt;Djrudiak: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Language]]&lt;br /&gt;
{{OSLang|[[File:icon-Autoit.png|64x64px]]|Preamble about the language&#039;s origin and its main characteristics.}}&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;
* 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;
* 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 Phidget Programming]] 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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;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>Djrudiak</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=Language_-_Applescript&amp;diff=19148</id>
		<title>Language - Applescript</title>
		<link rel="alternate" type="text/html" href="https://www.phidgets.com/docs21/index.php?title=Language_-_Applescript&amp;diff=19148"/>
		<updated>2012-04-20T17:08:19Z</updated>

		<summary type="html">&lt;p&gt;Djrudiak: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Language]]&lt;br /&gt;
{{OSLang|[[File:icon-Applescript.png|64x64px]]|Applescript is a scripting language for Mac OSX designed primarily for interfacing between applications.}}&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;
* 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;
* 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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight lang=applescript&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  tell ifkit to open&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&amp;lt;/div&amp;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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;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;
Please keep in mind that events are triggered from the PhidgetsOSA application and not from AppleScript. Thus, the AppleScript editor won&#039;t be able to receive replies when the script runs. In addition, any changes you make to the event code must be saved in order for the changes to take effect.&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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;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 class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;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>Djrudiak</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=Language_-_Android_Java&amp;diff=19147</id>
		<title>Language - Android Java</title>
		<link rel="alternate" type="text/html" href="https://www.phidgets.com/docs21/index.php?title=Language_-_Android_Java&amp;diff=19147"/>
		<updated>2012-04-20T16:42:18Z</updated>

		<summary type="html">&lt;p&gt;Djrudiak: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Language]]&lt;br /&gt;
{{OSLang|[[File:Icon-Android.png‎|64x64px|link=|alt=]]|Android Java is the main language used to program for the [[OS - Android|Android OS]].}}&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
{{LanguageSupport|Android|nearly the complete Phidget API, including events, and only excepting a few open() calls outlined later|the Phidget Interface Kit and two Hello World examples.|Eclipse on Windows, Mac OS, and Linux|}}&lt;br /&gt;
&lt;br /&gt;
==Quick Downloads==&lt;br /&gt;
{{QuickDownloads|Android|&lt;br /&gt;
{{APIQuickDownloads|http://www.phidgets.com/documentation/JavaDoc.zip}}|&lt;br /&gt;
{{ExampleQuickDownloads|http://www.phidgets.com/downloads/examples/android-examples_2.1.8.20120216.tar.gz|(and Phidget Android Library)}}|&lt;br /&gt;
{{ExtraLibraryQuickDownloads|http://www.phidgets.com/downloads/examples/android-examples_2.1.8.20120216.tar.gz||(Phidget21.jar included in Examples)}}&lt;br /&gt;
{{WindowsQuickDownloads}}&lt;br /&gt;
{{MacQuickDownloads}}&lt;br /&gt;
{{LinuxQuickDownloads}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Getting Started with Android Java (Eclipse)==&lt;br /&gt;
&lt;br /&gt;
If you are new to writing code for Phidgets, we recommend starting by running, then modifying existing examples. This will allow you to:&lt;br /&gt;
{{ExampleCodeReasons}}&lt;br /&gt;
&lt;br /&gt;
As Android development is primarily done on Eclipse, and Eclipse is relatively platform-independent, we provide instructions for Eclipse rather than by operating system.&lt;br /&gt;
&lt;br /&gt;
For basic differences on installing and setting up Eclipse on your development system, you can try the [[OS - Android|Android Operating System]] page.  However, your best bet for information about general use of Eclipse on your development operating system (Windows, Mac, or Linux) will be the [http://www.eclipse.org/documentation/ Eclipse support page] or the Internet at large.&lt;br /&gt;
&lt;br /&gt;
Phidgets can run directly plugged in to Android devices with a USB port and system 3.1 or later.  &lt;br /&gt;
&lt;br /&gt;
Otherwise, Android can control a Phidget remotely over a network, by using the [[Phidget WebService]]&lt;br /&gt;
&lt;br /&gt;
Hence, we split instructions up by Android OS version number.&lt;br /&gt;
&lt;br /&gt;
===Android Under 3.1 (and/or no USB Port)===&lt;br /&gt;
&lt;br /&gt;
These types of phones and tablets can use Phidgets only remotely over a network using the [[OS - Android#WebService|Phidget WebService]].&lt;br /&gt;
&lt;br /&gt;
====Use Our Examples====&lt;br /&gt;
&lt;br /&gt;
Download and unpack the [http://www.phidgets.com/downloads/examples/android-examples_2.1.8.20120216.tar.gz Phidget Examples for Android].  There are two Hello World examples: {{Code|HelloWorldRemote}} (the one you want), and {{Code|HelloWorld}} (for tablets with a USB port).&lt;br /&gt;
&lt;br /&gt;
Import the {{Code|HelloWorldRemote}} example into Eclipse:&lt;br /&gt;
* File &amp;amp;rarr; Import... &amp;amp;rarr; General &amp;amp;rarr; Existing Projects Into Workspace &amp;amp;rarr; (Next)&lt;br /&gt;
* Select {{Code|HelloWorldRemote}} root directory &amp;amp;rarr; Select all files &amp;amp;rarr; Finish&lt;br /&gt;
&lt;br /&gt;
Next, you &#039;&#039;&#039;must change&#039;&#039;&#039; the IP address within the example code to the IP address of the computer directly connected to the Phidget you are trying to control.  This happens on the line that says something like:&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=java&amp;gt;&lt;br /&gt;
device.open(&amp;quot;192.168.3.133&amp;quot;, 5001);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, note that the HelloWorldRemote example was written for Android 2.1.  If needed, you can change this in:&lt;br /&gt;
(Right Click on Project) &amp;amp;rarr; Properties &amp;amp;rarr; Resource (on left) &amp;amp;rarr; Android&lt;br /&gt;
&lt;br /&gt;
To run the example: Right-click on project in Package Explorer (To open the Package Explorer, use Window &amp;amp;rarr; Show View &amp;amp;rarr; Package Explorer)&lt;br /&gt;
&lt;br /&gt;
Select Run As... &amp;amp;rarr; Android Application&lt;br /&gt;
&lt;br /&gt;
This will bring up the Android Virtual Device manager window.  If your Android hardware is plugged in to your debugging computer, you will see the hardware as an option on which to run the example.  You should run it directly on your Android device, unless you are comfortable setting up the emulator to run on your local network.&lt;br /&gt;
&lt;br /&gt;
After the {{Code|HelloWorldRemote}} application starts running on your Android device: &lt;br /&gt;
# Make sure the Phidget WebService is running on the computer with the IP address you put into the code&lt;br /&gt;
#*For directions on how to set up and run the webservice on a remote computer, refer to the page [[Software Overview#Operating System Support|for that operating system]]&lt;br /&gt;
# Plug a Phidget into that computer&lt;br /&gt;
&lt;br /&gt;
And on your Android device, depending on which Phidget you plug in, you should see something like:&lt;br /&gt;
&lt;br /&gt;
[[Image:android_helloworld_remotehello.png|700px|alt=|link=]]&lt;br /&gt;
&lt;br /&gt;
And when you unplug that Phidget from the remote computer, you should see something like this on your Android device:&lt;br /&gt;
&lt;br /&gt;
[[Image:android_helloworld_remotegoodbye.png|700px|alt=|link=]]&lt;br /&gt;
&lt;br /&gt;
If you have the specific Phidget for the other included Android examples (i.e. the InterfaceKit), you can run the other examples in the same way.&lt;br /&gt;
&lt;br /&gt;
To envision the system in the background, you can refer to the WebService section on the [[OS - Android]] page.&lt;br /&gt;
&lt;br /&gt;
====Write Your Own Code====&lt;br /&gt;
&lt;br /&gt;
To write your own code from scratch, start with an Android project in Eclipse (File &amp;amp;rarr; New &amp;amp;rarr; Android Project).  Then....&lt;br /&gt;
&lt;br /&gt;
=====Step One: Link the Phidget Libraries to your Project=====&lt;br /&gt;
&lt;br /&gt;
When you download and unzip the [http://www.phidgets.com/downloads/examples/android-examples_2.1.8.20120216.tar.gz Phidget Examples for Android], each project folder will (in addition to the project files themselves) contain three things:&lt;br /&gt;
# A libs/ folder (containing an armabi/ folder and a single file called libphidget21.so)&lt;br /&gt;
# A jar file containing the general Phidget java library (phidget21.jar)&lt;br /&gt;
# A jar file for directly driving USB devices from a USB port on the Android device (PhidgetsUSB.jar)&lt;br /&gt;
&lt;br /&gt;
Copy the {{Code|libs}} folder, the {{Code|PhidgetsUSB.jar}} file, and the {{Code|phidget21.jar}} file to your project folder.&lt;br /&gt;
&lt;br /&gt;
To install libraries to run a Phidget &#039;&#039;&#039;remotely&#039;&#039;&#039; over a network using the WebService:&lt;br /&gt;
# Add the libs/ folder to your project&lt;br /&gt;
#* To add the libs/ folder in Eclipse, simply place it in the root folder of your project&lt;br /&gt;
# Add the phidget21.jar file to your project&lt;br /&gt;
#* In Eclipse use the top-bar menu: Project &amp;amp;rarr; Properties &amp;amp;rarr; Java Build Path &amp;amp;rarr; Libraries (tab) &amp;amp;rarr; Add JAR&lt;br /&gt;
&lt;br /&gt;
=====Step Two: Give your Program Permission to use the Internet=====&lt;br /&gt;
&lt;br /&gt;
Add the following to your &amp;lt;code&amp;gt;AndroidManifest.xml&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight lang=xml&amp;gt;&lt;br /&gt;
    &amp;lt;uses-permission android:name=&amp;quot;android.permission.INTERNET&amp;quot;&amp;gt;&amp;lt;/uses-permission&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Step Three: Include the Phidget Libraries in your Source=====&lt;br /&gt;
&lt;br /&gt;
Then, in your code, include an {{Code|import}} reference to the library. In Android Java:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight lang=java&amp;gt;&lt;br /&gt;
  // This contains all of the devices and the exceptions&lt;br /&gt;
  import com.phidgets.*;&lt;br /&gt;
 &lt;br /&gt;
  // This contains all of the event listeners&lt;br /&gt;
  import com.phidgets.event.*;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then you are ready to begin coding!&lt;br /&gt;
&lt;br /&gt;
===Android 3.1+ with USB Port===&lt;br /&gt;
&lt;br /&gt;
If your tablet has a USB host port and is running Android 3.1 or later, you can plug Phidgets directly into it.&lt;br /&gt;
&lt;br /&gt;
====Use Our Examples====&lt;br /&gt;
&lt;br /&gt;
Download and unpack the [http://www.phidgets.com/downloads/examples/android-examples_2.1.8.20120216.tar.gz Phidget Examples for Android].  There are two Hello World examples: {{Code|HelloWorld}} (the one you want), and {{Code|HelloWorldRemote}} (for controlling Phidgets over the WebService).&lt;br /&gt;
&lt;br /&gt;
Import the {{Code|HelloWorld}} example into Eclipse:&lt;br /&gt;
* File &amp;amp;rarr; Import... &amp;amp;rarr; General &amp;amp;rarr; Existing Projects Into Workspace &amp;amp;rarr; (Next)&lt;br /&gt;
* Select {{Code|HelloWorldRemote}} root directory &amp;amp;rarr; Select all files &amp;amp;rarr; Finish&lt;br /&gt;
&lt;br /&gt;
Note that the HelloWorld example was written for Android 3.1.  If needed, you can change this in:&lt;br /&gt;
(Right Click on Project) &amp;amp;rarr; Properties &amp;amp;rarr; Resource (on left) &amp;amp;rarr; Android&lt;br /&gt;
&lt;br /&gt;
To run the example: Right-click on project in Package Explorer (To open the Package Explorer, use Window &amp;amp;rarr; Show View &amp;amp;rarr; Package Explorer)&lt;br /&gt;
&lt;br /&gt;
Select Run As... &amp;amp;rarr; Android Application&lt;br /&gt;
&lt;br /&gt;
This will bring up the Android Virtual Device manager window.  If your Android hardware is plugged in to your debugging computer, you will see the hardware as an option on which to run the example.  You should run it directly on your Android device, unless you are comfortable setting up the emulator to use your development computer&#039;s USB hub.&lt;br /&gt;
&lt;br /&gt;
After the {{Code|HelloWorld}} application starts running on your Android device, plug a Phidget into your Android tablet&#039;s USB port!&lt;br /&gt;
&lt;br /&gt;
Since the USB device requires special permission, the first thing you will probably see is a request from the Phidget example to use the USB port:&lt;br /&gt;
&lt;br /&gt;
[[Image:android_helloworld_usb_permissions.png|500px|alt=|link=]]&lt;br /&gt;
&lt;br /&gt;
And on your Android device, depending on which Phidget you plug in, you should see something like:&lt;br /&gt;
&lt;br /&gt;
[[Image:android_helloworld_hello.png|700px|alt=|link=]]&lt;br /&gt;
&lt;br /&gt;
And when you unplug that Phidget from the remote computer, you should see something like this on your Android device:&lt;br /&gt;
&lt;br /&gt;
[[Image:android_helloworld_goodbye.png|700px|alt=|link=]]&lt;br /&gt;
&lt;br /&gt;
If you have the specific Phidget for the other included Android examples (i.e. the InterfaceKit), you can run the other examples in the same way.&lt;br /&gt;
&lt;br /&gt;
If you are having trouble running the examples, a method to debug the Android USB port is on the [[OS - Android]] page, under the Hardware section.&lt;br /&gt;
&lt;br /&gt;
====Write Your Own Code====&lt;br /&gt;
&lt;br /&gt;
To write your own code from scratch, start with an Android project in Eclipse (File &amp;amp;rarr; New &amp;amp;rarr; Android Project).  Then....&lt;br /&gt;
&lt;br /&gt;
=====Step One: Link the Phidget Libraries to your Project=====&lt;br /&gt;
&lt;br /&gt;
When you download and unzip the [http://www.phidgets.com/downloads/examples/android-examples_2.1.8.20120216.tar.gz Phidget Examples for Android], each project folder will (in addition to the project files themselves) contain three things:&lt;br /&gt;
# A libs/ folder (containing an armabi/ folder and a single file called libphidget21.so)&lt;br /&gt;
# A jar file containing the general Phidget java library (phidget21.jar)&lt;br /&gt;
# A jar file for directly driving USB devices from a USB port on the Android device (PhidgetsUSB.jar)&lt;br /&gt;
&lt;br /&gt;
Copy the {{Code|libs}} folder, the {{Code|PhidgetsUSB.jar}} file, and the {{Code|phidget21.jar}} file to your project folder.&lt;br /&gt;
&lt;br /&gt;
To install libraries to run a Phidget &#039;&#039;&#039;remotely&#039;&#039;&#039; over a network using the WebService:&lt;br /&gt;
# Add the libs/ folder to your project&lt;br /&gt;
#* To add the libs/ folder in Eclipse, simply place it in the root folder of your project&lt;br /&gt;
# Add the phidget21.jar file to your project&lt;br /&gt;
# Also add the PhidgetsUSB.jar file to your project&lt;br /&gt;
#* In Eclipse, to add jar files use the top-bar menu: Project &amp;amp;rarr; Properties &amp;amp;rarr; Java Build Path &amp;amp;rarr; Libraries (tab) &amp;amp;rarr; Add JAR&lt;br /&gt;
&lt;br /&gt;
=====Step Two: Give your Program Permission to use USB=====&lt;br /&gt;
&lt;br /&gt;
Add the following to your &amp;lt;code&amp;gt;AndroidManifest.xml&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight lang=xml&amp;gt;&lt;br /&gt;
    &amp;lt;uses-feature android:name=&amp;quot;android.hardware.usb.host&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Step Three: Include the Phidget Libraries in your Source=====&lt;br /&gt;
&lt;br /&gt;
Then, in your code, include an {{Code|import}} reference to the library. In Android Java:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight lang=java&amp;gt;&lt;br /&gt;
  // This contains all of the devices and the exceptions&lt;br /&gt;
  import com.phidgets.*;&lt;br /&gt;
 &lt;br /&gt;
  // This contains all of the event listeners&lt;br /&gt;
  import com.phidgets.event.*;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then you are ready to begin coding!&lt;br /&gt;
&lt;br /&gt;
==Follow the Examples==&lt;br /&gt;
&lt;br /&gt;
By following the instructions above, you probably now have a working example and want to understand it better so you can change it to do what you want. This section has resources for you to learn from the examples and write your own.&lt;br /&gt;
&lt;br /&gt;
Programming with Phidgets in MATLAB makes extensive use of the mainstream Java Phidgets library, so the Java API reference will be helpful:&lt;br /&gt;
&lt;br /&gt;
{{UsingAPhidgetInCodeGeneral|although you can only use the event code in Android|[http://www.phidgets.com/documentation/JavaDoc.zip Java API]}}&lt;br /&gt;
&lt;br /&gt;
===API Support===&lt;br /&gt;
&lt;br /&gt;
Most of the Java API is supported in Android.  However, only some of the available open calls are supported:&lt;br /&gt;
&lt;br /&gt;
When using a Phidget over a network, you can open the remote Phidget using one of the supported Java API calls:&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight lang=java&amp;gt;&lt;br /&gt;
void open(int serial, java.lang.String ipAddress, int port)&lt;br /&gt;
void open(int serial, java.lang.String ipAddress, int port, java.lang.String password)&lt;br /&gt;
void openAny(java.lang.String ipAddress, int port)&lt;br /&gt;
void openAny(java.lang.String ipAddress, int port, java.lang.String password)&lt;br /&gt;
void openLabel(java.lang.String label, java.lang.String ipAddress, int port)&lt;br /&gt;
void openLabel(java.lang.String label, java.lang.String ipAddress, int port, java.lang.String password)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When using a Phidget when it is directly plugged in to an Android 3.1 or later tablet, you can use one of these supported Java API calls:&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight lang=java&amp;gt;&lt;br /&gt;
void open(int serial)&lt;br /&gt;
void openAny()&lt;br /&gt;
void openLabel(java.lang.String label)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This leaves these Java API calls, which are &#039;&#039;&#039;unsupported&#039;&#039;&#039; on Android:&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight lang=java&amp;gt;&lt;br /&gt;
void open(int serial, java.lang.String serverID)&lt;br /&gt;
void open(int serial, java.lang.String serverID, java.lang.String password)&lt;br /&gt;
void openAny(java.lang.String serverID)&lt;br /&gt;
void openAny(java.lang.String serverID, java.lang.String password)&lt;br /&gt;
void openLabel(java.lang.String label, java.lang.String serverID)&lt;br /&gt;
void openLabel(java.lang.String label, java.lang.String serverID,&lt;br /&gt;
java.lang.String password)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Code Snippets===&lt;br /&gt;
&lt;br /&gt;
Specific calls in Android Java will differ in syntax from those on the [[General Phidget Programming]] page, but the concepts stay the same.  &lt;br /&gt;
&lt;br /&gt;
It may help to have the [[General Phidget Programming]] page and this section open at the same time, because they parallel each other and you can refer to the Android Java syntax.  However, many additional concepts are covered on the General Phidget Programming page on a high level, such as using multiple Phidgets, handling errors, and different styles of programming.&lt;br /&gt;
&lt;br /&gt;
For example, if we were using a [[Product - 1018 - PhidgetInterfaceKit 8/8/8 | Phidget Interface Kit]] as our device, the general calls would look like this:&lt;br /&gt;
&lt;br /&gt;
====Step One: Initialize and Open====&lt;br /&gt;
&lt;br /&gt;
For opening a remote Phidget over the network using the WebService:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight lang=java&amp;gt;&lt;br /&gt;
  InterfaceKitPhidget device;&lt;br /&gt;
  device = new InterfaceKitPhidget();&lt;br /&gt;
 &lt;br /&gt;
  // Open first detected Interface Kit, remotely with IP address and port&lt;br /&gt;
  device.open(&amp;quot;192.168.3.33&amp;quot;, 5001);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For opening a Phidget directly attached to the tablet&#039;s USB port:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight lang=java&amp;gt;&lt;br /&gt;
 InterfaceKitPhidget device;&lt;br /&gt;
 com.phidgets.usb.Manager.Initialize(this);&lt;br /&gt;
 device = new InterfaceKitPhidget();&lt;br /&gt;
&lt;br /&gt;
 // Open locally, with Phidget in tablet USB port&lt;br /&gt;
 ik.open(&amp;quot;192.168.3.33&amp;quot;, 5001);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The direct open call 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;
Both open 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. We can handle this by using event driven programming and tracking the AttachEvents and DetachEvents....&lt;br /&gt;
&lt;br /&gt;
====Step Two: Wait for Attachment (plugging in) of the Phidget====&lt;br /&gt;
&lt;br /&gt;
To use the Phidget, it must be plugged in and a software event caught (i.e. attached). &lt;br /&gt;
&lt;br /&gt;
Android Java is &#039;&#039;&#039;only&#039;&#039;&#039; event-driven, so you cannot use {{Code|waitForAttachment()}} without hanging and being relatively unsafe with your threads.  Instead, you should define an event handler function that you can then synchronize and tie in with the attachment event itself.&lt;br /&gt;
&lt;br /&gt;
First, let&#039;s write our handler:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight lang=java&amp;gt;&lt;br /&gt;
  class AttachEventHandler implements Runnable { &lt;br /&gt;
    Phidget device; &lt;br /&gt;
    TextView eventOutput;&lt;br /&gt;
&lt;br /&gt;
    public AttachEventHandler(Phidget device, TextView eventOutput) {&lt;br /&gt;
      this.device = device;&lt;br /&gt;
      this.eventOutput = eventOutput; }&lt;br /&gt;
&lt;br /&gt;
    public void run() {&lt;br /&gt;
      try {&lt;br /&gt;
        // The actual useful thing our handler does&lt;br /&gt;
	eventOutput.setText(&amp;quot;Hello &amp;quot; + device.getDeviceName() + &amp;quot;, Serial &amp;quot; + Integer.toString(device.getSerialNumber()));&lt;br /&gt;
      } catch (PhidgetException e) { e.printStackTrace(); }&lt;br /&gt;
        &lt;br /&gt;
      // Notify whoever called us (and is waiting) that we&#039;re done&lt;br /&gt;
      synchronized(this) { this.notify(); }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This may seem complex, but really it is just:&lt;br /&gt;
# A class wrapper so we can work independently once we get permission from the main thread, and&lt;br /&gt;
# A way to call back to the {{Code|synchronized()}} call to let them know we&#039;re done and stay thread safe&lt;br /&gt;
&lt;br /&gt;
Now that we have our &#039;handler&#039; we can hook it in as an event function to trigger on device attachment:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight lang=java&amp;gt;&lt;br /&gt;
device.addAttachListener(new AttachListener() {&lt;br /&gt;
  public void attached(final AttachEvent attachEvent) {&lt;br /&gt;
    AttachEventHandler handler = new AttachEventHandler(attachEvent.getSource(), eventOutput);&lt;br /&gt;
&lt;br /&gt;
    // This is synchronised in case more than one device is attached before one completes attaching&lt;br /&gt;
    synchronized(handler) {&lt;br /&gt;
&lt;br /&gt;
      runOnUiThread(handler);&lt;br /&gt;
      try { handler.wait(); } catch (InterruptedException e) { e.printStackTrace(); }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}); &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Step Three: Do Things with the Phidget====&lt;br /&gt;
&lt;br /&gt;
Again, because Android is event driven, use buttons (or timers) to schedule events if you want to poll the device at a certain interval or user specification.  Otherwise, simply set the sensitivity and/or data rate (depending on your device type) and catch events as they come in using the handler structure above.&lt;br /&gt;
&lt;br /&gt;
====Step Four: Close and Delete====&lt;br /&gt;
&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;
We can put the close() call for Phidgets in Android within an overridden version of the onDestroy() Android application function.  Within it, we simply close the device.  For Phidgets directly attached to a USB Android tablet, you should also call Uninitialize():&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight lang=java&amp;gt;&lt;br /&gt;
  @Override&lt;br /&gt;
  protected void onDestroy() {&lt;br /&gt;
    super.onDestroy();&lt;br /&gt;
      try { device.close(); } catch (PhidgetException e) { e.printStackTrace(); }&lt;br /&gt;
      // Uninitialize should only be called for directly connected Phidgets&lt;br /&gt;
      com.phidgets.usb.Manager.Uninitialize();&lt;br /&gt;
  }    &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;complete&#039;&#039; set of functions you have available for all Phidgets can be found in the [http://www.phidgets.com/documentation/JavaDoc.zip Java API].  You can also find more description on any device-specific function either in the [[Device List|Device API]] page for calls available only on your specific Phidget.&lt;br /&gt;
&lt;br /&gt;
==Common Problems and Solutions/Workarounds==&lt;br /&gt;
&lt;br /&gt;
This section contains some Android Java and Eclipse-specific common problems.  For more answers about using Phidgets, visit our forums, FAQ, or contact us.&lt;br /&gt;
&lt;br /&gt;
{{ProblemSolution|Eclipse Error|Unable to get view server protocol version from device emulator}}&lt;br /&gt;
&lt;br /&gt;
Likely Fix: Project &amp;amp;rarr; Clean... &amp;amp;rarr; Clean All  (If that does not work, clean again and restart Eclipse)&lt;br /&gt;
&lt;br /&gt;
{{ProblemSolution|Eclipse Error|Android requires compiler compliance level 5.0 or 6.0. Found &#039;X.Y&#039; instead}}&lt;br /&gt;
&lt;br /&gt;
Likely Fix: This may happen when running the examples.  The javac and java version on the example do not match those on your computer.&lt;br /&gt;
* Find the version of java and javac on your computer (for example, &amp;lt;code&amp;gt;java -version&amp;lt;/code&amp;gt; on the command line)&lt;br /&gt;
* In Eclipse, open the Package Explorer (Window &amp;amp;rarr; Show View &amp;amp;rarr; Package Explorer)&lt;br /&gt;
* Find the project, right-click and select Properties&lt;br /&gt;
* In Properties &amp;amp;rarr; Java Compiler &amp;amp;rarr; (Checkbox) Enable Project Specific Settings &amp;amp;rarr; Set Compiler Compliance Level = Java Version &amp;amp;rarr; Apply&lt;br /&gt;
* When told this requires rebuild, say Rebuild Now&lt;/div&gt;</summary>
		<author><name>Djrudiak</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=Language_-_iOS&amp;diff=19146</id>
		<title>Language - iOS</title>
		<link rel="alternate" type="text/html" href="https://www.phidgets.com/docs21/index.php?title=Language_-_iOS&amp;diff=19146"/>
		<updated>2012-04-20T16:41:28Z</updated>

		<summary type="html">&lt;p&gt;Djrudiak: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Language]]&lt;br /&gt;
{{OSLang|[[File:icon-iOS.png|64x64px|alt=|link=]]|applications are built using the Cocoa Touch framework and the Objective C programming language, both developed by [http://www.apple.com Apple].}}&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
{{LanguageSupport|iOS|nearly the complete Phidget API, including events. As iOS devices do not have USB ports, Phidgets can only be remotely controlled over a network, by using the [[Phidget WebService]]|the Phidget InterfaceKit, Hello World examples and a Skeleton starter project.|Xcode on OS X.|}}&lt;br /&gt;
&lt;br /&gt;
==Quick Downloads==&lt;br /&gt;
{{QuickDownloads|iOS|&lt;br /&gt;
* [http://www.phidgets.com/documentation/Phidget21_C_Doc.zip C API]|&lt;br /&gt;
{{ExampleQuickDownloads|http://www.phidgets.com/downloads/libraries/Phidget-iPhone_2.1.8.20120216.zip|(same file as iOS libraries)}}|&lt;br /&gt;
{{ExtraLibraryQuickDownloads|http://www.phidgets.com/downloads/libraries/Phidget-iPhone_2.1.8.20120216.zip|iOS|(same file as iOS examples)}}&lt;br /&gt;
{{MacQuickDownloads}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Getting Started with Cocoa Touch==&lt;br /&gt;
&lt;br /&gt;
If you are new to writing code for Phidgets, we recommend starting by running, then modifying existing examples. This will allow you to:&lt;br /&gt;
* Make sure your libraries are properly linked&lt;br /&gt;
* Go from source code to a test application as quickly as possible&lt;br /&gt;
&lt;br /&gt;
As iOS development is primarily done on Xcode, we provide instructions for Xcode, specifically version 4.0.&lt;br /&gt;
&lt;br /&gt;
====Use Our Examples====&lt;br /&gt;
&lt;br /&gt;
Start by ensuring that the WebService is running on the computer that the Phidget is connected to. This computer needs to have an USB port and can be an OS X system or any other [[Software Overview#Operating System Support|operating systems]] we support. For directions on how to set up and run the WebService , refer to the page [[Software Overview#Operating System Support|for that operating system]]&lt;br /&gt;
&lt;br /&gt;
Then on the the OS X system that will be used for developing iOS applications, download and unpack the [http://www.phidgets.com/downloads/examples/android-examples_2.1.8.20120216.tar.gz Phidget Examples for iOS]. The easiest way to confirm that your environment is set up properly will be to compile and run the HelloWorld iOS example.&lt;br /&gt;
Start by opening the HelloWorld.xcodeproj in Xcode.&lt;br /&gt;
&lt;br /&gt;
Next, select your target destination that you want the application be ran on: an iOS device or simulator. For the purpose of this section, we will be using the simulator. &lt;br /&gt;
&lt;br /&gt;
[[Image:IOS Xcode Destination.png||alt=|link=]]&lt;br /&gt;
&lt;br /&gt;
To run the example, click on the {{Code|Run}} button. &lt;br /&gt;
&lt;br /&gt;
[[Image:IOS Xcode Run.png||alt=|link=]]&lt;br /&gt;
&lt;br /&gt;
This program will detect for Phidgets that are attached/detached on the host computer. Go ahead, and attach or detach your devices! Here is an example output:&lt;br /&gt;
&lt;br /&gt;
[[Image:IOS Webservice Example HelloWorld Output.png||alt=|link=]]&lt;br /&gt;
&lt;br /&gt;
After confirming that the {{Code|HelloWorld}} example is working, you can proceed to run the example for your specific device. If you aren&#039;t sure what the software example for your device is called, check the software object listed in the [[Device List | Getting Started Guide for your Device]]. Currently, the only device we provide example code for is the PhidgetInterfaceKit.&lt;br /&gt;
&lt;br /&gt;
Once you have the iOS examples running, we have a [[#Follow the Examples|teaching]] section below to help you follow them.&lt;br /&gt;
&lt;br /&gt;
=====Write Your Own Code=====&lt;br /&gt;
&lt;br /&gt;
When you are building a project from scratch, or adding Phidget function calls to an existing project, you&#039;ll need to configure your development environment to properly link the Phidget iOS library. To begin: &lt;br /&gt;
&lt;br /&gt;
1. Generate a new iOS Windows-based application project with a descriptive name such as PhidgetTest. &lt;br /&gt;
&lt;br /&gt;
[[File:IOS NewProject 1.png|link=|alt=New Project]]&lt;br /&gt;
&lt;br /&gt;
[[File:IOS NewProject 2.png|link=|alt=New Project]]&lt;br /&gt;
&lt;br /&gt;
A {{Code|.xcodeproj}} project file will be created. &lt;br /&gt;
&lt;br /&gt;
2. Set up the Provisioning Profiles and Code Signing settings, if necessary.&lt;br /&gt;
&lt;br /&gt;
3. Download the [http://www.phidgets.com/downloads/libraries/Phidget-iPhone_2.1.8.20120216.zip Phidget iOS library] and extract it.&lt;br /&gt;
&lt;br /&gt;
4. Inside, you will find the {{Code|iphoneos}} and the {{Code|iphonesimulator}} folders. Move the two folders as well as the {{Code|phidget21.h}} into the same directory as the newly created {{Code|.xcodeproj}} file.&lt;br /&gt;
&lt;br /&gt;
5. In Xcode, open up the Project Settings &amp;amp;rarr; Build Settings.&lt;br /&gt;
&lt;br /&gt;
6. In Linking &amp;amp;rarr; Other Linker Flags, follow these steps for both the Debug, and Release sections: &lt;br /&gt;
&lt;br /&gt;
Select {{Code|Any iOS Simulator SDK}} and enter: {{Code|$(SRCROOT)/iphonesimulator/libPhidget21.a}}.&lt;br /&gt;
&lt;br /&gt;
Select {{Code|Any iOS SDK}} and enter: {{Code|$(SRCROOT)/iphoneos/libPhidget21.a}}.&lt;br /&gt;
&lt;br /&gt;
[[File:IOS Add Library.png|link=|alt=Add Library]]&lt;br /&gt;
&lt;br /&gt;
7. In Search Paths &amp;amp;rarr; Header Search Paths, enter: {{Code|$(SRCROOT)}}.&lt;br /&gt;
&lt;br /&gt;
[[File:IOS Add Header.png|link=|alt=Add Header]]&lt;br /&gt;
&lt;br /&gt;
8. In the header file, add a reference to {{Code|phidget21.h}}:&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=objc&amp;gt;&lt;br /&gt;
  #import &amp;quot;phidget21.h&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&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.&lt;br /&gt;
&lt;br /&gt;
Please note that the Phidget iPhone library also contains a sample skeleton xCode project for iOS. This project already contains project settings similar to those discussed above and it lets you quickly start on Phidgets development.&lt;br /&gt;
&lt;br /&gt;
The same [[#Follow the Examples|teaching]] section which describes the examples also has further resources for programming your Phidget.&lt;br /&gt;
&lt;br /&gt;
==Follow the Examples==&lt;br /&gt;
&lt;br /&gt;
By following the instructions above, you probably now have a working example and want to understand it better so you can change it to do what you want. This section has resources for you to learn from the examples and write your own.&lt;br /&gt;
&lt;br /&gt;
Your main reference for writing iOS applications will be our C API information, with syntax for all of our functions:&lt;br /&gt;
&lt;br /&gt;
{{UsingAPhidgetInCodeGeneral|both of which are available in iOS|[http://www.phidgets.com/documentation/Phidget21_C_Doc.zip C API]}}&lt;br /&gt;
&lt;br /&gt;
===API Support===&lt;br /&gt;
&lt;br /&gt;
Most of the C API is supported in iOS, with the exception of the local open calls. This is because there are no USB ports on iOS devices, so only the remote open calls can be used.&lt;br /&gt;
&lt;br /&gt;
The following open calls are unsupported:&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight lang=objc&amp;gt;&lt;br /&gt;
  int CPhidget_open(CPhidgetHandle phid, int serialNumber)&lt;br /&gt;
  int CPhidget_openLabel(CPhidgetHandle phid, const char * label)	&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
===Code Snippets===&lt;br /&gt;
&lt;br /&gt;
Specific calls in iOS will differ in syntax from those on the [[General Phidget Programming]] page, but the concepts stay the same.  &lt;br /&gt;
&lt;br /&gt;
It may help to have the [[General Phidget Programming]] page and this section open at the same time, because they parallel each other and you can refer to the Cocoa Touch syntax, as described on this page.  However, many additional concepts are covered on the General Phidget Programming page on a high level, such as using multiple Phidgets, handling errors, and different styles of programming.&lt;br /&gt;
&lt;br /&gt;
For example, if we were using a [[Product - 1018 - PhidgetInterfaceKit 8/8/8 | Phidget Interface Kit]] as our device, the general calls would look like this:&lt;br /&gt;
&lt;br /&gt;
====Step One: Initialize and Open====&lt;br /&gt;
&lt;br /&gt;
For opening a remote Phidget over the network using the WebService:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&amp;lt;syntaxhighlight lang=objc&amp;gt;&lt;br /&gt;
  CPhidgetInterfaceKitHandle device;&lt;br /&gt;
 &lt;br /&gt;
  // Open first detected Interface Kit, remotely with IP address and port&lt;br /&gt;
  CPhidget_openRemoteIP((CPhidgetHandle)device, -1, &amp;quot;192.168.3.33&amp;quot;, 5001, NULL);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the WebService is used to connect to the Phidget, the one connection per device limit does not apply.&lt;br /&gt;
&lt;br /&gt;
The open 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. We can handle this by using event driven programming and tracking the attach events and detach events.&lt;br /&gt;
&lt;br /&gt;
====Step Two: Wait for Attachment (plugging in) of the Phidget==== &lt;br /&gt;
&lt;br /&gt;
To use the Phidget, it must be plugged in (attached).  We can handle this simply by calling {{Code|CPhidget_waitForAttachment}}. This function works for any Phidget. {{Code|CPhidget_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 class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=objc&amp;gt;&lt;br /&gt;
  int serialNum;&lt;br /&gt;
  CPhidget_waitForAttachment(10000);&lt;br /&gt;
  CPhidget_getSerialNumber((CPhidgetHandle)device, &amp;amp;serialNum);&lt;br /&gt;
  NSLog(&amp;quot;%d attached!&amp;quot;, serialNum);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sometimes, it makes more sense to handle the attachment via an event.  This would be in instances where the Phidget is being plugged and unplugged, and you want to handle these incidents.  Or, when you want to use event-driven programming because you have a GUI-driven program.  In these cases, an event-driven code snippet to handle the attachment might look something like this.&lt;br /&gt;
&lt;br /&gt;
First, you hook an event handler with the following code:&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=objc&amp;gt;&lt;br /&gt;
  - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions&lt;br /&gt;
    ...   &lt;br /&gt;
    CPhidgetManager_set_OnAttach_Handler(manager, gotAttach, self);&lt;br /&gt;
    ...&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/syntaxhighlight&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:&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=objc&amp;gt;&lt;br /&gt;
  // ========== Event Handling Setup Functions ==========&lt;br /&gt;
  int gotAttach(CPhidgetHandle phid, void *context) {&lt;br /&gt;
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];&lt;br /&gt;
    &lt;br /&gt;
    //invokes the DeviceAttach event method on the main thread and block the main thread until after the DeviceAttach method finishes&lt;br /&gt;
    //A bad access exception may occur if you set waitUntilDone to No&lt;br /&gt;
    [(id)context performSelectorOnMainThread:@selector(DeviceAttach:)&lt;br /&gt;
     					     withObject:[NSValue valueWithPointer:phid]&lt;br /&gt;
                                             waitUntilDone:YES];&lt;br /&gt;
    [pool release];&lt;br /&gt;
    return 0;&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Above, the {{Code|DeviceAttach}} method is invoked on the main thread. The {{Code|NSAutoreleasePool}} object is created to clean up released objects on the event thread, and is released at the end of the method. The {{Code|DeviceAttach}} method is defined as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=objc&amp;gt;&lt;br /&gt;
  // ========== Event Handling Functions ==========&lt;br /&gt;
  - (void)DeviceAttach:(NSValue *)phid&lt;br /&gt;
  {&lt;br /&gt;
    int phidgetSerial;&lt;br /&gt;
    const char * phidgetName;&lt;br /&gt;
    &lt;br /&gt;
    CPhidget_getSerialNumber((CPhidgetHandle)[phid pointerValue], &amp;amp;phidgetSerial);&lt;br /&gt;
    CPhidget_getDeviceName((CPhidgetHandle)[phid pointerValue], &amp;amp;phidgetName);&lt;br /&gt;
    &lt;br /&gt;
    outputField.text = [NSString stringWithFormat:@&amp;quot;%@Hello Device %@, Serial Number: %d\n\n&amp;quot;, outputField.text, [NSString stringWithCString:phidgetName encoding:NSASCIIStringEncoding], phidgetSerial];&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this function, the code inside {{Code|DeviceAttach}} will get executed every time the PhidgetInterfaceKit is attaches to the computer. 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;
====Step Three: Do Things with the Phidget====&lt;br /&gt;
&lt;br /&gt;
You can read data and interact with your Phidget both by polling it for its current state (or to set a state), or by catching events that trigger when the data changes.&lt;br /&gt;
&lt;br /&gt;
For our [[Product - 1018 - PhidgetInterfaceKit 8/8/8 | PhidgetInterfaceKit]], the polling method of getting the current sensor state and setting an output state looks something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=objc&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  # Get a data point from Analog Port 0&lt;br /&gt;
  int sensorValue;&lt;br /&gt;
  CPhidgetInterfaceKit_getSensorValue(device, 0, &amp;amp;sensorValue);&lt;br /&gt;
  [sensorValueTxt setintValue: sensorValue];&lt;br /&gt;
&lt;br /&gt;
  # Set digital output port 0 to be on&lt;br /&gt;
  CPhidgetInterfaceKit_setOutputState(device, 0, 1); &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Step Four: Close and Delete====&lt;br /&gt;
&lt;br /&gt;
At the end of your program, don’t forget to call {{Code|CPhidget_close()}} and {{Code|CPhidget_delete()}} to free any locks on the Phidget that the {{Code|CPhidget_open()}} call put in place!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=objc&amp;gt;&lt;br /&gt;
  CPhidget_close((CPhidgetHandle)ifkit);&lt;br /&gt;
  CPhidget_delete((CPhidgetHandle)ifkit);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;complete&#039;&#039; set of functions you have available for all Phidgets can be found in the [http://www.phidgets.com/documentation/Phidget21_C_Doc.zip C API]. You can also find more description on any device-specific function either in the [[Device List|Device API]] page for calls available only on your specific Phidget.&lt;br /&gt;
&lt;br /&gt;
==Common Problems and Solutions/Workarounds==&lt;/div&gt;</summary>
		<author><name>Djrudiak</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=Language_-_Visual_Basic_.NET&amp;diff=19145</id>
		<title>Language - Visual Basic .NET</title>
		<link rel="alternate" type="text/html" href="https://www.phidgets.com/docs21/index.php?title=Language_-_Visual_Basic_.NET&amp;diff=19145"/>
		<updated>2012-04-20T16:40:07Z</updated>

		<summary type="html">&lt;p&gt;Djrudiak: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Language]]&lt;br /&gt;
{{OSLang|[[File:icon-Visual Basic Net.png|64x64px|link=|alt=]]|Visual Basic .NET, developed by [http://www.microsoft.com Microsoft] is a modern object oriented programming language and the successor to [[Language - Visual Basic 6.0 | Visual Basic 6.0]].}}&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
{{LanguageSupport|Visual Basic .NET|the complete Phidget API, including events|all Phidget devices.|the .NET or Mono framework. Both of the frameworks are supported on Windows. For Linux and OS X, only the Mono framework can be used. We provide instructions on how to set up your environment/compilers for [[#Visual Studio 2005/2008/2010 | Visual Studio 2005/2008/2010]], [[#Visual Studio 2003 | Visual Studio 2003]], [[#MonoDevelop | MonoDevelop]] and the [[#Mono | Mono command line compilers]]|}}&lt;br /&gt;
&lt;br /&gt;
==Quick Downloads==&lt;br /&gt;
{{QuickDownloads|Visual Basic .NET|&lt;br /&gt;
{{APIQuickDownloads|http://www.phidgets.com/documentation/Phidget21.NET.zip .NET}}|&lt;br /&gt;
{{ExampleQuickDownloads|http://www.phidgets.com/downloads/examples/VBNET_2.1.8.20120216.zip|}}|&lt;br /&gt;
{{ExtraLibraryQuickDownloads|http://www.phidgets.com/downloads/libraries/phidget21-x86_2.1.8.20110615.zip|.NET Framework Files|}}&lt;br /&gt;
{{WindowsQuickDownloads}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Getting started with Visual Basic .NET==&lt;br /&gt;
&lt;br /&gt;
If you are new to writing code for Phidgets, we recommend starting by running, then modifying existing examples. This will allow you to:&lt;br /&gt;
{{ExampleCodeReasons}}&lt;br /&gt;
&lt;br /&gt;
Instructions are divided up by operating system. Choose:&lt;br /&gt;
*[[#Windows(2000/XP/Vista/7)|Windows 2000 / XP / Vista / 7]]&lt;br /&gt;
*[[#OS X |OS X]]&lt;br /&gt;
*[[#Linux | Linux]] (including PhidgetSBC)&lt;br /&gt;
&lt;br /&gt;
==Windows (2000/XP/Vista/7)==&lt;br /&gt;
&lt;br /&gt;
===Description of Library Files===&lt;br /&gt;
Visual Basic .NET programs on Windows depend on the following files, which the installers above put onto your system:&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|phidget21.dll}}&amp;lt;/b&amp;gt; contains the actual Phidget library, which is used at run-time.  By default, it is placed in {{Code|C:\Windows\System32}}.&lt;br /&gt;
You will also need one of the following two files, depending on the .NET framework version you are targeting:&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|Phidget21.NET.dll}}&amp;lt;/b&amp;gt; is the Phidget library for .NET framework &amp;lt;i&amp;gt;&amp;lt;b&amp;gt;2.0&amp;lt;/b&amp;gt;&amp;lt;/i&amp;gt; or higher. Your compiler has to know where this file is. By default, it is placed into {{Code|C:\Program Files\Phidgets}}. You can either point your compiler to that location, or copy and link to it in a directory for your project workspace. &lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|Phidget21.NET1.1.dll}}&amp;lt;/b&amp;gt; is the Phidget library for .NET framework &amp;lt;i&amp;gt;&amp;lt;b&amp;gt;1.1&amp;lt;/b&amp;gt;&amp;lt;/i&amp;gt;. Your compiler has to know where this file is. By default, is is placed into {{Code|C:\Program Files\Phidgets}}. You can either point your compiler to that location, or copy and link to it in a directory for your project workspace. &lt;br /&gt;
You can optionally install the following files:&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|Phidget21.NET.XML}}&amp;lt;/b&amp;gt; provides the IntelliSense in-line documentation for the .NET library in Visual Studio/MonoDevelop. This documentation is also visible in the Object Browser in Visual Studio. By default, it is placed into {{Code|C:\Program Files\Phidgets}}. &lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|Policy.2.1.Phidget21.NET.dll}}&amp;lt;/b&amp;gt; is the policy assembly for {{Code|Phidget21.NET.dll}}. Our installer places this file in the Global Assembly Cache(GAC) directory. It directs any programs compiled against version 2.1.0 or higher of {{Code|Phidget21.NET.dll}} to use the most recent installed version. &lt;br /&gt;
&lt;br /&gt;
If you do not want to use our installer, you can download the five [http://www.phidgets.com/downloads/libraries/Phidget21-windevel_2.1.8.20111220.zip files].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Running the examples and writing your own code can be fairly environment-specific, so we include instructions for [[#Visual Studio 2005/2008/2010 | Visual Studio 2005/2008/2010]], [[#Visual Studio 2003 | Visual Studio 2003]], [[#MonoDevelop | MonoDevelop]] and the [[#Mono | Mono command line compiler]].&lt;br /&gt;
&lt;br /&gt;
===Visual Studio 2005/2008/2010===&lt;br /&gt;
&lt;br /&gt;
Microsoft makes free versions of Visual Studio available known as Express Editions.  The Express editions are suitable for most applications, but are limited in features for more complex applications. Please see [http://www.microsoft.com/visualstudio Microsoft Visual Studio] for more information.&lt;br /&gt;
&lt;br /&gt;
=====Use Our Examples=====&lt;br /&gt;
&lt;br /&gt;
Please start by downloading the [http://www.phidgets.com/downloads/examples/VBNET_2.1.8.20120131.zip examples] and unpack them into a folder.  While these examples were written in Visual Studio 2005 and Visual Studio 2008, Visual Studio 2010 will easily open and upgrade them with the Visual Studio Conversion Wizard.&lt;br /&gt;
&lt;br /&gt;
[[File:VS2005 Conversion Wizard.PNG|link=|alt=Conversion Wizard]]&lt;br /&gt;
&lt;br /&gt;
To load all projects in Visual Studio, go to File &amp;amp;rarr; Open &amp;amp;rarr; Project, and open {{Code|AllExamples/AllExamples.sln}} or {{Code|AllExamples/AllExamples_vs2008.sln}} for Visual Studio 2005 and 2008, respectively.&lt;br /&gt;
&lt;br /&gt;
This will load all of the examples available for Visual Basic .NET, and then you can set your main project to be the one that matches your device.  If you aren&#039;t sure what the software example for your device is called, check the software object listed in the [[Device List | Getting Started guide for your device]].&lt;br /&gt;
&lt;br /&gt;
The only thing left to do is to run the examples! Click on Debug &amp;amp;rarr; Start Debugging. Please note that the projects, by default try to find the {{Code|Phidget21.NET.dll}} in {{Code|C:\Program Files\Phidgets}}. If you have it installed in another location, please change the path to the file&#039;s location accordingly. If you are receiving an error message regarding that the type Phidget is not defined, please re-add the reference to {{Code|Phidget21.NET.dll}}. Please see the [[#Write Your Own Code | Write Your Own Code ]] section for details. &lt;br /&gt;
&lt;br /&gt;
[[File:VBNET VS2005 Run.PNG|link=|alt=Run]]&lt;br /&gt;
&lt;br /&gt;
Once you have the Visual Basic .NET examples running, we have a [[#Follow the Examples|teaching]] section below to help you follow them.&lt;br /&gt;
&lt;br /&gt;
=====Write Your Own Code=====&lt;br /&gt;
&lt;br /&gt;
When you are building a project from scratch, or adding Phidget function calls to an existing project, you&#039;ll need to configure your environment to properly link the Phidget .NET library. To begin: &lt;br /&gt;
&lt;br /&gt;
1. Generate a new Visual Basic .NET Console Application project with a descriptive name such as PhidgetTest. &lt;br /&gt;
&lt;br /&gt;
[[File:VBNET VS2005 New Project.PNG|link=|alt=New Project]]&lt;br /&gt;
&lt;br /&gt;
2. Add a reference to the Phidget .NET library.&lt;br /&gt;
&lt;br /&gt;
[[File:VBNET VS2005 Add Reference 1.PNG|link=|alt=Add Reference]]&lt;br /&gt;
&lt;br /&gt;
3. Under the .NET tab, select {{Code|Phidget21.NET.dll}}.&lt;br /&gt;
If you used our installer, these files are installed in {{Code|C:\Program Files\Phidgets}}, by default. If it does not appear in this list, then you can browse to the Phidget Framework installation directory and add the file.&lt;br /&gt;
&lt;br /&gt;
[[File:VBNET VS2005 Add Reference 2.PNG|link=|alt=Add Reference]]&lt;br /&gt;
&lt;br /&gt;
The project now has access to the Phidget function calls and you are ready to begin coding.&lt;br /&gt;
&lt;br /&gt;
The same [[#Follow the Examples|teaching ]] section which describes the examples also has further resources for programming your Phidget.&lt;br /&gt;
&lt;br /&gt;
===Visual Studio 2003===&lt;br /&gt;
&lt;br /&gt;
=====Use Our Examples=====&lt;br /&gt;
&lt;br /&gt;
As the Visual Basic .NET examples were written in Visual Studio 2005 and 2008, Visual Studio 2003 is not able to open the examples. Furthermore, it will be difficult to import the examples into your Visual Studio 2003 project as you will need to recreate the GUI components. Fortunately, taking a look at the source code will give you valuable programming insight. We have a [[#Follow the Examples|teaching ]] section below to help you follow them.&lt;br /&gt;
&lt;br /&gt;
=====Write Your Own Code=====&lt;br /&gt;
&lt;br /&gt;
When you are building a project from scratch, or adding Phidget function calls to an existing project, you&#039;ll need to configure your development environment to properly link the Phidget .NET library. &lt;br /&gt;
&lt;br /&gt;
1. Generate a new Visual Basic Console Application project with a descriptive name such as PhidgetTest. &lt;br /&gt;
&lt;br /&gt;
[[File:VBNET VS2003 New Project.PNG|link=|alt=New Project]]&lt;br /&gt;
&lt;br /&gt;
2. Add a reference to the Phidget .NET library.&lt;br /&gt;
&lt;br /&gt;
[[File:VBNET VS2003 Add Reference 1.PNG|link=|alt=Add Reference]]&lt;br /&gt;
&lt;br /&gt;
3. Under the .NET tab, select {{Code|Phidget21.NET1.1.dll}}.&lt;br /&gt;
If you used our installer, these files are installed in {{Code|C:\Program Files\Phidgets}}, by default. If it does not appear in this list, then you can browse to the Phidget Framework installation directory and add the file.&lt;br /&gt;
&lt;br /&gt;
[[File:VBNET VS2003 Add Reference 2.PNG|link=|alt=Add Reference]]&lt;br /&gt;
&lt;br /&gt;
The project now has access to the Phidget21 function calls and you are ready to begin coding.&lt;br /&gt;
&lt;br /&gt;
The [[#Follow the Examples|teaching ]] section also has further resources for programming your Phidget.&lt;br /&gt;
&lt;br /&gt;
===Mono===&lt;br /&gt;
&lt;br /&gt;
This section will provide instructions on how to compile using the {{Code|vbnc}} compiler.&lt;br /&gt;
&lt;br /&gt;
=====Use Our Examples=====&lt;br /&gt;
&lt;br /&gt;
We do not have Visual Basic .NET examples for the Mono framework. Fortunately, you can take a look at the source code for our [http://www.phidgets.com/downloads/examples/CSharp_2.1.8.20110615.zip Visual Studio 2005 and 2008 examples] for valuable programming insight. We have a [[#Follow the Examples|teaching ]] section below to help you follow them.&lt;br /&gt;
&lt;br /&gt;
=====Write Your Own Code=====&lt;br /&gt;
&lt;br /&gt;
When you are building a project from scratch, or adding Phidget function calls to an existing project, you&#039;ll need to configure your compiler to properly link the Phidget .NET library.&lt;br /&gt;
&lt;br /&gt;
Place the {{Code|Phidget21.NET.dll}} in the same directory as your source code. &lt;br /&gt;
To compile and build an executable, run:&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=bash&amp;gt;&lt;br /&gt;
vbnc /out:example.exe /r:Phidget21.NET.dll Example.vb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Afterwards, you will have an executable named {{Code|example.exe}} that you can run. Type the following to run the program:&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=bash&amp;gt;&lt;br /&gt;
mono example.exe&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The [[#Follow the Examples|teaching]] section also has further resources for programming your Phidget.&lt;br /&gt;
&lt;br /&gt;
===MonoDevelop===&lt;br /&gt;
&lt;br /&gt;
=====Use Our Examples=====&lt;br /&gt;
&lt;br /&gt;
Download the [http://www.phidgets.com/downloads/examples/VBNET_2.1.8.20120131.zip examples] and unpack them into a folder. Here, you can find example programs for all the devices. These examples were written in Visual Studio 2005 and 2008, but are also compatible with MonoDevelop. Please note that the examples are only designed to be ran under the .NET framework. The examples are not compatible with the Mono framework. Despite this, if you are using the Mono framework, you can take a look at the source code for our [http://www.phidgets.com/downloads/examples/CSharp_2.1.8.20110615.zip Visual Studio examples] for valuable programming insight. We have a [[#Follow the Examples|teaching ]] section below to help you follow them.&lt;br /&gt;
&lt;br /&gt;
The rest of this section will explain the steps needed to run our examples under the .NET framework. To load all projects in MonoDevelop, go to File &amp;amp;rarr; Open, and open {{Code|AllExamples/AllExamples.sln}}&lt;br /&gt;
&lt;br /&gt;
This will load all of the examples available for Visual Basic .NET, and then you can set your main project to be the one that matches your device.  If you aren&#039;t sure what the software example for your device is called, check the software object listed in the [[Device List | Getting Started guide for your device]].&lt;br /&gt;
&lt;br /&gt;
[[File:VBNET Win MonoDevelop Startup Project.PNG|link=|alt=Start Up Project]]&lt;br /&gt;
&lt;br /&gt;
The only thing left to do is to run the examples! Right click the project, and click on {{Code|Run With}} and select the Microsoft .NET framework. Please note that the projects, by default try to find the {{Code|Phidget21.NET.dll}} in the {{Code|C\Program Files\Phidgets}}. If you have it installed in another location, please change the path to the file&#039;s location accordingly. If you are receiving an error message regarding that the Phidget is not defined, please re-add the reference to {{Code|Phidget21.NET.dll}}. Please see the [[#Write Your Own Code 4 | Write Your Own Code]] section for details. &lt;br /&gt;
&lt;br /&gt;
[[File:VBNET Win MonoDevelop Run.PNG|link=|alt=Run]]&lt;br /&gt;
&lt;br /&gt;
Once you have the Visual Basic .NET examples running, we have a [[#Follow the Examples|teaching]] section below to help you follow them.&lt;br /&gt;
&lt;br /&gt;
=====Write Your Own Code=====&lt;br /&gt;
&lt;br /&gt;
When you are building a project from scratch, or adding Phidget function calls to an existing project, you&#039;ll need to configure your  development environment to properly link the Phidget .NET library. To begin:&lt;br /&gt;
&lt;br /&gt;
1. Create a new Visual Basic .NET console project with a descriptive name such as PhidgetTest.&lt;br /&gt;
&lt;br /&gt;
[[File:VBNET Win MonoDevelop New Project.PNG|link=|alt=New Project]]&lt;br /&gt;
&lt;br /&gt;
2. Add a reference to the Phidget .NET library. &lt;br /&gt;
&lt;br /&gt;
[[File:VBNET Win MonoDevelop Add Reference 1.PNG|link=|alt=Add Reference]]&lt;br /&gt;
&lt;br /&gt;
3. Select {{Code|Phidget21.NET.dll}}. If you used our installer, by default, this file is placed in {{Code|C:\Program Files\Phidgets}}. If it is in another location, please change the path to the file&#039;s location accordingly. &lt;br /&gt;
&lt;br /&gt;
[[File:VBNET Win MonoDevelop Add Reference 2.PNG|link=|alt=Add Reference]]&lt;br /&gt;
&lt;br /&gt;
The project now has access to the Phidget function calls and you are ready to begin coding.&lt;br /&gt;
&lt;br /&gt;
The same [[#Follow the Examples|teaching]] section which describes the examples also has further resources for programming your Phidget.&lt;br /&gt;
&lt;br /&gt;
==OS X==&lt;br /&gt;
&lt;br /&gt;
Visual Basic .NET has excellent support on OS X through the Mono framework. &lt;br /&gt;
&lt;br /&gt;
The first step in using Visual Basic .NET on Mac is to install the Phidget libraries.  Compile and install them as explained on the [[Device List|getting started guide for your device]].  Then, the [[OS - OS X]] page also describes the different Phidget files, their installed locations, and their roles....&lt;br /&gt;
&lt;br /&gt;
==Linux==&lt;br /&gt;
&lt;br /&gt;
Visual Basic .NET has support on Linux through the Mono framework.  &lt;br /&gt;
&lt;br /&gt;
The first step in using Visual Basic .NET on Linux is to install the Phidget libraries.  Compile and install them as explained on the main [[OS - Linux | Linux page]].  That Linux page also describes the different Phidget files, their installed locations, and their roles.&lt;br /&gt;
&lt;br /&gt;
==Follow the Examples==&lt;br /&gt;
&lt;br /&gt;
By following the instructions for your operating system and compiler above, you probably now have a working example and want to understand it better so you can change it to do what you want.  This teaching section has resources for you to learn from the examples and write your own.&lt;br /&gt;
&lt;br /&gt;
Next, comes our API information.  These resources outline the Phidget .NET functions:&lt;br /&gt;
&lt;br /&gt;
{{UsingAPhidgetInCodeGeneral|both of which are available in .NET|[http://www.phidgets.com/documentation/Phidget21.NET.zip .NET API]}}&lt;br /&gt;
&lt;br /&gt;
===Example Flow===&lt;br /&gt;
&lt;br /&gt;
{{ExamplePseudocode|In Visual Basic .NET, you can name these &#039;&#039;&#039;event&#039;&#039;&#039; functions whatever you like.  You will then pass them as function pointers to the Phidget library below in the Main Code section.  This hooks them into the actual events when they occur. &amp;lt;br&amp;gt; &lt;br /&gt;
In the example code, the event functions common to all Phidgets are called things like &#039;&#039;&#039;AttachHandler()&#039;&#039;&#039; and &#039;&#039;&#039;DetachHandler()&#039;&#039;&#039;, etc.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Some event functions will be specific to each device, like when a tag is read on an RFID board, or when a sensor value changes on an Interface Kit.&lt;br /&gt;
Other functions are given in the examples to show you more detail on using your Phidget.  For example, &#039;&#039;&#039;DeviceInitialize()&#039;&#039;&#039; will show what needs to be set up for your Phidget before using it.&lt;br /&gt;
|Creating a Phidget software object in Visual Basic .NET is specific to the Phidget.  For a Phidget Spatial, for example, this would involve creating a {{Code|Spatial}} object.  The examples show how to do this and other API functions.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
The object provides device specific methods and properties which are available from the API for your specific Phidget.|&lt;br /&gt;
[http://www.phidgets.com/documentation/Phidget21.NET.zip .NET API]}}&lt;br /&gt;
&lt;br /&gt;
==Code Snippets==&lt;br /&gt;
&lt;br /&gt;
==Common Problems and Solutions/Workarounds==&lt;br /&gt;
&lt;br /&gt;
Here you can put various frequent problems and our recommended solutions.&lt;/div&gt;</summary>
		<author><name>Djrudiak</name></author>
	</entry>
	<entry>
		<id>https://www.phidgets.com/docs21/index.php?title=Language_-_Visual_Basic_6.0&amp;diff=19144</id>
		<title>Language - Visual Basic 6.0</title>
		<link rel="alternate" type="text/html" href="https://www.phidgets.com/docs21/index.php?title=Language_-_Visual_Basic_6.0&amp;diff=19144"/>
		<updated>2012-04-20T16:39:03Z</updated>

		<summary type="html">&lt;p&gt;Djrudiak: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Language]]&lt;br /&gt;
{{OSLang|[[File:icon-Visual Basic.png|64x64px|link=|alt=]]|Visual Basic 6.0, developed by [http://www.microsoft.com Microsoft] is a high level programming language that uses the COM programming model.}}&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
{{LanguageSupport|Visual Basic 6.0|the complete Phidget API, including events|all Phidget devices.| the Microsoft Visual Basic 6 IDE|}}&lt;br /&gt;
&lt;br /&gt;
==Quick Downloads==&lt;br /&gt;
{{QuickDownloads|Visual Basic 6.0|&lt;br /&gt;
{{APIQuickDownloads|http://www.phidgets.com/documentation/COM_API_Manual.pdf COM}}|&lt;br /&gt;
{{ExampleQuickDownloads|http://www.phidgets.com/downloads/examples/VB6_2.1.8.20120131.zip|}}|&lt;br /&gt;
{{WindowsQuickDownloads}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Getting started with Visual Basic 6.0==&lt;br /&gt;
&lt;br /&gt;
If you are new to writing code for Phidgets, we recommend starting by running, then modifying existing examples. This will allow you to:&lt;br /&gt;
{{ExampleCodeReasons}}&lt;br /&gt;
&lt;br /&gt;
==Windows (2000/XP/Vista/7)==&lt;br /&gt;
&lt;br /&gt;
===Description of Library Files===&lt;br /&gt;
Visual Basic 6.0 programs on Windows depend on two files, which the installers in [[#Libraries and Drivers|Quick Downloads]] put onto your system:&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|phidget21.dll}}&amp;lt;/b&amp;gt; contains the actual Phidget library, which is used at run-time.  By default, it is placed in {{Code|C:\Windows\System32}}.&lt;br /&gt;
* &amp;lt;b&amp;gt;{{Code|Phidget21COM.dll}}&amp;lt;/b&amp;gt; is the Component Object Model(COM) library and provides your project access to the Phidget ActiveX objects.  Your compiler has to know where this file is, by default our installer places this file into {{Code|C:\Program Files\Phidgets}}, so you can either point your compiler to that location, or copy and link to it in a directory for your project workspace. If you are manually installing this file, you must register it through command line by running: {{Code|regsvr32 Phidget21COM.dll}}.&lt;br /&gt;
&lt;br /&gt;
If you do not want to use our installer, you can download both [http://www.phidgets.com/downloads/libraries/phidget21-x86_2.1.8.20110615.zip files] and manually install them where you want; refer to our [[OS_-_Windows#Manual_File_Installation | Manual Installation Instructions]].&lt;br /&gt;
&lt;br /&gt;
We include instructions on [[#Use Our Examples | using our examples]] and [[#Write Your Own Code | writing your own code]] for the Microsoft Visual Basic 6.0 IDE.&lt;br /&gt;
&lt;br /&gt;
====Visual Basic 6.0====&lt;br /&gt;
&lt;br /&gt;
=====Use Our Examples=====&lt;br /&gt;
&lt;br /&gt;
To run the examples, you first download the [http://www.phidgets.com/downloads/examples/VB6_2.1.8.20120131.zip examples] and unpack them into a folder. Here, you can find example programs for all the devices. If you aren&#039;t sure what the software example for your device is called, check the software object listed in the [[Device List | Getting Started guide for your device]].&lt;br /&gt;
&lt;br /&gt;
1. Open up the {{Code|.vbp}} project into the Visual Basic IDE.&lt;br /&gt;
&lt;br /&gt;
2. Next, navigate to Project &amp;amp;rarr; Components to ensure that your project has access to the Phidget ActiveX objects&lt;br /&gt;
&lt;br /&gt;
[[File:VB6 Components.PNG|link=|alt=Components]]&lt;br /&gt;
&lt;br /&gt;
3. The Components menu will show up. Ensure that the Phidget COM library is selected. If it is not, then browse for {{Code|Phidget21COM.dll}} and add it. By default, it is placed in {{Code|C:\Program Files\Phidgets}}. Accept the changes. &lt;br /&gt;
&lt;br /&gt;
[[File:VB6 Library.PNG|link=|alt=Library]]&lt;br /&gt;
&lt;br /&gt;
4. Navigate to Project &amp;amp;rarr; References and ensure that the Phidget COM library is selected.&lt;br /&gt;
&lt;br /&gt;
[[File:VB6 References.PNG|link=|alt=References]]&lt;br /&gt;
&lt;br /&gt;
5. The only thing left to do is to run the examples! Click on Run &amp;amp;rarr; Start. &lt;br /&gt;
&lt;br /&gt;
[[File:VB6 Run.PNG|link=|alt=Run]]&lt;br /&gt;
&lt;br /&gt;
Once you have the Visual Basic 6.0 examples running, we have a [[#Follow the Examples|teaching]] section below to help you follow them.&lt;br /&gt;
&lt;br /&gt;
=====Write Your Own Code=====&lt;br /&gt;
&lt;br /&gt;
When you are building a project from scratch, or adding Phidget function calls to an existing project, you&#039;ll need to configure your development environment to properly link the Phidget COM library. To begin: &lt;br /&gt;
&lt;br /&gt;
1. Generate a new Standard EXE project.&lt;br /&gt;
&lt;br /&gt;
[[File:VB6 New Project.PNG|link=|alt=New Project]]&lt;br /&gt;
&lt;br /&gt;
2. Next, navigate to Project &amp;amp;rarr; Components to add the Phidget ActiveX objects into your project.&lt;br /&gt;
&lt;br /&gt;
[[File:VB6 Components.PNG|link=|alt=Components]]&lt;br /&gt;
&lt;br /&gt;
3. The Components menu will show up. Browse for {{Code|Phidget21COM.dll}} and add it. By default, it is placed in {{Code|C:\Program Files\Phidgets}}. Accept the changes. &lt;br /&gt;
&lt;br /&gt;
[[File:VB6 Library.PNG|link=|alt=Library]]&lt;br /&gt;
&lt;br /&gt;
4. Navigate to Project &amp;amp;rarr; References and ensure that the Phidget COM library is selected.&lt;br /&gt;
&lt;br /&gt;
[[File:VB6 References.PNG|link=|alt=References]]&lt;br /&gt;
&lt;br /&gt;
5. Navigate to Project &amp;amp;rarr; Project1 Properties, select the {{Code|Make}} tab and ensure that the {{Code|Remove information about unused ActiveX Controls}} checkbox is unchecked.&lt;br /&gt;
&lt;br /&gt;
[[File:VB6 Unused ActiveX Controls.PNG|link=|alt=Unused ActiveX Controls]]&lt;br /&gt;
&lt;br /&gt;
6. Then, you will need to declare and initialize the Phidget ActiveX object for your device. &lt;br /&gt;
&lt;br /&gt;
The simplest method is to place the Phidget ActiveX object from the toolbox directly onto your form. If the toolbox is not present on your screen, navigate to View &amp;amp;rarr; Toolbox to show the toolbar. Next, find the ActiveX object for your device in the toolbox, and double click it to add it to the form. &lt;br /&gt;
&lt;br /&gt;
[[File:VB6 Toolbox ActiveX.PNG|link=|alt=Accessing Phidget ActiveX objects from the toolbox]]&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can dynamically create the Phidget ActiveX object in code. For example, for an PhidgetInterfaceKit, you would type:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=vb&amp;gt;&lt;br /&gt;
Dim WithEvents PhidgetInterfaceKit As PhidgetInterfaceKit&lt;br /&gt;
&lt;br /&gt;
Private Sub Form_Load()&lt;br /&gt;
   ...&lt;br /&gt;
   Set PhidgetInterfaceKit = Controls.Add(&amp;quot;Phidget21COM.PhidgetInterfaceKit&amp;quot;, &amp;quot;PhidgetInterfaceKit&amp;quot;)&lt;br /&gt;
   ...&lt;br /&gt;
End Sub&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The object name for each type of Phidget is listed in the [http://www.phidgets.com/documentation/COM_API_Manual.pdf COM API Manual]. Please see the [http://www.phidgets.com/downloads/examples/VB6_2.1.8.20120131.zip examples] on how to add a reference to your particular Phidget.&lt;br /&gt;
&lt;br /&gt;
The project now has access to the Phidget function calls and you are ready to begin coding.&lt;br /&gt;
&lt;br /&gt;
The same [[#Follow the Examples|teaching]] section which describes the examples also has further resources for programming your Phidget.&lt;br /&gt;
&lt;br /&gt;
==Follow the Examples==&lt;br /&gt;
&lt;br /&gt;
By following the instructions for your operating system and compiler above, you probably now have a working example and want to understand it better so you can change it to do what you want.  This teaching section has resources for you to learn from the examples and write your own.&lt;br /&gt;
&lt;br /&gt;
Next comes our API information, with syntax for all of our functions:&lt;br /&gt;
&lt;br /&gt;
{{UsingAPhidgetInCodeGeneral|both of which are available in Visual Basic 6.0|[http://www.phidgets.com/documentation/COM_API_Manual.pdf COM API Manual]}}&lt;br /&gt;
&lt;br /&gt;
===Example Flow===&lt;br /&gt;
&lt;br /&gt;
{{ExamplePseudocode|In Visual Basic 6.0, you can name these &#039;&#039;&#039;event&#039;&#039;&#039; functions whatever you like.  You will then pass them as function pointers to the Phidget library below in the Main Code section.  This hooks them into the actual events when they occur. &amp;lt;br&amp;gt; &lt;br /&gt;
In the example code, the event functions common to all Phidgets are called things like &#039;&#039;&#039;AttachHandler()&#039;&#039;&#039; and &#039;&#039;&#039;DetachHandler()&#039;&#039;&#039;, etc.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Some event functions will be specific to each device, like when a tag is read on an RFID board, or when a sensor value changes on an Interface Kit.&lt;br /&gt;
Other functions are given in the examples to show you more detail on using your Phidget.  For example, &#039;&#039;&#039;DeviceInitialize()&#039;&#039;&#039; will show what needs to be set up for your Phidget before using it.&lt;br /&gt;
|Creating a Phidget software object in Visual Basic 6.0 is specific to the Phidget.  For a Phidget Spatial, for example, this would involve creating a PhidgetSpatial object.  The examples show how to do this and other API functions|&lt;br /&gt;
[http://www.phidgets.com/documentation/COM_API_Manual.pdf COM API Manual]}}&lt;br /&gt;
&lt;br /&gt;
==Common Problems and Solutions/Workarounds==&lt;br /&gt;
{{ProblemSolution|Windows|My application does not compile when a function contains more than one parameter.}}&lt;br /&gt;
&lt;br /&gt;
In Visual Basic 6.0, the common way to handle multiple parameters is to not enclose the parameters with brackets. For example, instead of:&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=vb&amp;gt;&lt;br /&gt;
Object.getProperty(Parameter1, Parameter2)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should write:&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=vb&amp;gt;&lt;br /&gt;
Object.getProperty Parameter1, Parameter2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you wish, you can run the function with the parameters enclosed in brackets if you explicitly use the {{Code|Call}} keyword when running the function. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;source&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=vb&amp;gt;&lt;br /&gt;
Call Object.getProperty(Parameter1, Parameter2)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;/div&gt;</summary>
		<author><name>Djrudiak</name></author>
	</entry>
</feed>