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 events are backwards #10

Closed
rwaldron opened this issue Mar 13, 2012 · 4 comments
Closed

Button events are backwards #10

rwaldron opened this issue Mar 13, 2012 · 4 comments

Comments

@rwaldron
Copy link
Contributor

In lib/board.js:

// 1 is up
// 0 is down
if (m[1] == '1' && self.down) {
  self.down = false;
  self.emit('up');
}
if (m[1] == '0' && !self.down) {
  self.down = true;
  self.emit('down');
}

...which is backwards; button "up/unpressed" will be LOW/0/gnd and button "down/pressed" will be HIGH/1/5v

@rwaldron
Copy link
Contributor Author

See also: http://arduino.cc/it/Tutorial/Button

When the pushbutton is open (unpressed) there is no connection between the two legs of the pushbutton, so the pin is connected to ground (through the pull-down resistor) and we read a LOW. When the button is closed (pressed), it makes a connection between its two legs, connecting the pin to 5 volts, so that we read a HIGH.

@rwaldron
Copy link
Contributor Author

Looks like this was fixed in the repo, but not pushed to npm?

@rwaldron
Copy link
Contributor Author

Sorry, I realize now that this ticket was completel obnoxious. If I'd bothered to look at the commit history, I would've seen that the last commit fixed this, unfortunately it just says "Merge pull request #6 from richkzad/patch-1…" on the main project page.

@ecto
Copy link
Owner

ecto commented Mar 13, 2012

No worries, I wanted to document this but I've been insanely busy. Thanks for your help man!

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