ecto / duino

:bulb: Arduino framework for node.js
958 stars 214 forks source link

Button events are backwards #10

Closed rwaldron closed 12 years ago

rwaldron commented 12 years ago

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 commented 12 years ago

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 commented 12 years ago

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

rwaldron commented 12 years ago

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 commented 12 years ago

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