/relay-controller

This's relay controller for Raspberry Pi

Primary LanguageJavaScript

relay-controller

This's relay controller for Raspberry Pi

The initial version

It can control open,close,toggle,openAt,closeAt and toggleAt

First

  1. Install gpio-admin form https://github.com/quick2wire/quick2wire-gpio-admin
  2. Install relay-controller npm install relay-controller

USE

  1. relay.open(pin,[times],[callback])
    • open relay
    • times Time delay opening
    • callback will return status
  2. relay.close(pin,[times],[callback])
    • close relay
    • times Timing closure
    • callback
  3. relay.toggle(pin,[callback])
    • toggle relay open or close
    • callback will return relay status
  4. relay.openAt(pin,times,[callback])
  5. relay.closeAt(pin,times,[callback])
  6. relay.toggleAt(pin,object,[callback])
    • toggle relay open pr close timing
    • object {time:1000,number:10}
    • callback will return relay status

Explain

var relay = require("relay-controller").relay;
var pin = 21;

To open relay ...

relay.open(pin,function(status){
	console.log(status);
})

Timing close

relay.closeAt(pin,1000,function(){
	console.log("close...");
})

Or

relay.close(pin,1000,function(){
	console.log("close...");
})