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

button can't work #1

Open
sxj123 opened this issue Dec 17, 2016 · 2 comments
Open

button can't work #1

sxj123 opened this issue Dec 17, 2016 · 2 comments

Comments

@sxj123
Copy link

sxj123 commented Dec 17, 2016

this is my button.js:
var Cylon = require('cylon');

Cylon.robot({
connections: {
pcduino: { adaptor: 'pcduino }
},

devices: {
button: { driver: 'button', pin: 2 }
},

work: function(my) {
my.button.on('push', function() {
console.log("Button pushed!");
});
}
}).start();
$node button.js
TypeError:Cylon.IO.Utils.every is not a function
Why? Is the pin.js file wrong?Looking forward to your reply.

@alexwang2013
Copy link
Owner

alexwang2013 commented Dec 18, 2016

Hi, sxj123

instead of using driver button, you can use driver led, like the following
devices: {
led: { driver: 'led', pin: 2 }
},

as instead of using event push, you can inspect pin and use the following
digitalWrite
digitalRead
setHigh
setLow

if there is still problem, please give feedback :)

@sxj123
Copy link
Author

sxj123 commented Dec 18, 2016

Hi,alex:
this is the led blink code:
`'use strict';
var Cylon = require("cylon");

Cylon.robot({
connections: {
pcduino: { adaptor: 'pcduino' }
},

devices: {
	led: { driver: 'led', pin: 10 }
},

work: function(my) {
	every((1).second(), my.led.toggle);
}	

}).start();
` and it works.
button and led both call for digital interface, the led blink can work, why button can't?
In order to let the terminal show "button pushed" when the button is pushed, how to write the code in the work part? I don't know how to use the function code to implement this function. Could you please help?
Looking forward to your reply! Thanks so much!

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