Humidity/Temperature Sensor sample code

Legacy support with Phidget21
CharlyKhul
Phidgetsian
Posts: 5
Joined: Fri Jul 29, 2011 7:24 pm
Contact:

Humidity/Temperature Sensor sample code

Postby CharlyKhul » Fri Jul 29, 2011 7:44 pm

Hello,

I'm a beginner and i have just received my sensor but i can't find
any code sample for AS3 and the 1125 - Humidity/Temperature Sensor.
The Card i connect, folder com ok, webservice ok,
but there is no "sensor change" when i use "trace".

If some one can help me?
Thanks a lot!

CharlyKhul
Phidgetsian
Posts: 5
Joined: Fri Jul 29, 2011 7:24 pm
Contact:

Re: Humidity/Temperature Sensor sample code

Postby CharlyKhul » Sun Jul 31, 2011 12:43 pm

hi all,

I found a solution :

Code: Select all

import com.phidgets.*;
import com.phidgets.events.*;


var phid:PhidgetInterfaceKit;
phid = new PhidgetInterfaceKit();

phid.open("localhost", 5001,"", 176028);

phid.addEventListener(PhidgetEvent.CONNECT,onConnect);
phid.addEventListener(PhidgetEvent.DISCONNECT, onDisconnect);

function onConnect(evt:PhidgetEvent):void {
ipc.text = "Interface : connecté.";
}

function onDisconnect(evt:PhidgetEvent):void {
trace(evt);
}


phid.addEventListener(PhidgetDataEvent.SENSOR_CHANGE, mudaValor);
function mudaValor(evt:PhidgetDataEvent):void {
var sensor6 = phid.getSensorValue(6);
var sensor7 = phid.getSensorValue(7);
var temperature = (sensor7*0.22222)-61.11;
temperature = Math.floor(temperature*100)/100;
temp.text = "Temperature : "+temperature+" C°";
var hygrometrie = (sensor6*0.1906)-40.2;
hygrometrie = Math.floor(hygrometrie*100)/100;
hyg.text = "Hygrométrie : "+hygrometrie+" %";
trace (sensor6);
trace (sensor7);
}


But now i am trying to find some code for the relay.

If some one have an idea :D

erik
King of the Lab
Posts: 476
Joined: Fri Mar 06, 2009 12:42 pm
Location: Calgary, Canada
Contact:

Re: Humidity/Temperature Sensor sample code

Postby erik » Tue Aug 02, 2011 8:27 am

The relay is also considered an InterfaceKit so you simply need to create another instance of InterfaceKit using the unique serial number and follow the same set-up of listeners, etc. By setting the outputs of the InterfaceKit, the associated relay will toggle.


Return to “ActionScript 3.0 - Flash CS3 / Flex / AIR”

Who is online

Users browsing this forum: No registered users and 1 guest