Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error in sample code #64

Open
alfalabs opened this issue Mar 27, 2017 · 1 comment
Open

error in sample code #64

alfalabs opened this issue Mar 27, 2017 · 1 comment

Comments

@alfalabs
Copy link

alfalabs commented Mar 27, 2017

@RIAEvangelist
This API is great!
There is a small problem with sample code in docs: https://github.com/RIAEvangelist/node-phidget-API/blob/master/docs/Phidget.md
here is a fix:

// var Phidget = require('phidgetapi').Phidget;
// var IK888=new phidget();// <--- in original code phidget() function is undefined
var IK888 = require('phidgetapi').Phidget(); 

IK888.on("error", function(data){ console.log('error ',data); });

IK888.on('phidgetReady', function(){
        console.log('IK888 phidget ready');
        console.log(IK888.data);

        IK888.set({
                type:'Output',
                key:'0',
                value:'1'
            });

        IK888.on('changed', update );
    }
);

var update = function(data){
    console.log('phidget state changed');
    console.log('data ',data);

    if(data.type=='Sensor'){
        
        IK888.set({
                type:'Output',
                key:'0',
                value:'1'
            });

        setTimeout( function(){
               // phidget.set({ <-- in original code phidget var is undefined
                IK888.set({ 
                        type:'Output',
                        key:'0',
                        value:'0'
                    });
            },
            200
        );
    }
};

/*
* Connect to Phidget
*/
IK888.connect({type: 'PhidgetInterfaceKit' });
@RIAEvangelist
Copy link
Owner

RIAEvangelist commented Mar 28, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants