Comments (3)
I found a way to get this working. Here's more context and some follow-up questions:
I expected the following code to work:
const expander = new five.Expander({
controller: "MCP23017",
address: 0x21,
});
const virtual = new five.Board.Virtual(expander);
const button = new five.Button({
board: virtual,
isPullup: true,
pin: 5,
});
However, this only configures the pin to be an input pin, without the internal pull-up resistor enabled. Looking through the code, I saw that the MCP23017 code does have support for controlling the pull-up registers and I was able to get the button to work with the following code:
const expander = new five.Expander({
controller: "MCP23017",
address: 0x21,
});
const virtual = new five.Board.Virtual(expander);
// ADDED COMMAND
expander.pullUp(5, virtual.io.HIGH)
const button = new five.Button({
board: virtual,
isPullup: true,
pin: 5,
});
So I have two questions:
- Is the expectation that the first block of code should have worked?
- If the button API alone is not expected to work, is my current approach correct or am I reaching too far into the internals?
from johnny-five.
I think if you got the workaround and its really work and makes you happy then don't ask unnecessary questions :-)
p.s. thank you for sharing your solution! 👍🏻
from johnny-five.
These are not unnecessary questions. Having to use a workaround does not make me happy and I believe this is a bug in J5.
from johnny-five.
Related Issues (20)
- Using PWM and AC DImmer RobotDyn
- Cannot Input Mode Pin 12, 14, 15. ESP8266 HOT 2
- Refactor DS18B20 Temperature Conversion Time Handling
- Usage with Electron of latest J5 versions? HOT 6
- Status of Release?
- Using a Coin selector
- CAN bus with mcp2515 support, and other libraries
- MKR 1010 board HOT 1
- INPUT_PULLUP on digital input pin HOT 12
- I2C Scanner?
- Unable to use Led.Digits with Multple Boards HOT 4
- Stop stepper while running HOT 2
- Servo animation enqueue is buggy HOT 6
- Calling animation.next inside onloop callback is not working.
- Sensor disable only works once. HOT 3
- Is there a way to use multiple I2C LCD's HOT 2
- RaspberryPi issue HOT 3
- Intermittent Error Code 31 in GetOverlappedResult
- Arduino Mega Link Bork'd HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from johnny-five.