Comments (12)
Setting pin mode is something you would handle with the IO, so it's not a Johnny-Five thing really, but you can access the IO through the Johnny-Five Board instance:
import { board } from "johnny-five";
const board = new five.Board();
board.on("ready", function() {
board.io.pinmode(3, board.io.MODES.PULLUP);
});
You say that you see that example all over the place. Can you point me to that? I've seen a few people ask questions like this, and I'm curious where it's all coming from.
from johnny-five.
I tried your code, it does not seem to work.
I believe a lot of programmers use INPUT_PULLUP instead of regular INPUT mode, as to avoid the noise in having something similar to a floating pin.
Some examples:
- https://forum.arduino.cc/t/digital-pins-register-confusion-input_pullup-high-and-low/179087/3
- https://youtu.be/wxjerCHCEMg?t=187
- https://youtu.be/OZGMLOwHYf8?t=251
from johnny-five.
To clarify, I am not using it for a button. I am using it and almost all other digital pins to read from an external source.
from johnny-five.
Can you share your code?
from johnny-five.
Can you share your code?
const five = require("johnny-five");
const board = new five.Board();
board.on("ready", function () {
board.io.pinMode(31, board.io.MODES.PULLUP);
const sensor = new five.Sensor.Digital({
pin: 31,
});
sensor.on("change", function () {
console.log("Pin value", this.value);
});
});
The thing is the wire connecting to that pin will sometimes have to be "loose" making it a floating pin. And I need the resistor to "filter out" all the noise.
from johnny-five.
I can't test (I'm at work), but I suspect initializing a sensor on that pin will reset it to a normal input. Have you tried setting the pin mode after instantiating the sensor?
from johnny-five.
It doesn't seem to work even with just using pinInput.read()
from johnny-five.
In my experience, I've been able to proceed using the Button library https://github.com/rwaldron/johnny-five/blob/main/docs/button-pullup.md
isPullup: true
This has been working for some time on my codebase. I've been able to test it 2 days ago and it was working but when i switched back to the code related to this part, it now glitch
button.on("up", function() {
led.off();
});
triggers constantly, so this is not fixed. The doc seems to write that yes, but when you read at the code, all it it doing is sending a write command to LOW on that pinβ¦
from johnny-five.
I should mention that I had some problems that looks like similar to this one in the topic.
But finally we're figured out that root cause of the problem was in failed arduino pin.
I've rechecked this a couple of times and problem with pin is now confirmed
from johnny-five.
I suggest in case of any troubles to check all of the modes of a button: isPullup
, isPulldown
and invert
and play with every of those modes to be sure.
from johnny-five.
I should mention that I had some problems that looks like similar to this one in the topic. But finally we're figured out that root cause of the problem was in failed arduino pin. I've rechecked this a couple of times and problem with pin is now confirmed
U mean your arduino is damaged ?
I suggest in case of any troubles to check all of the modes of a button:
isPullup
,isPulldown
andinvert
and play with every of those modes to be sure.
What is is supposed to change ? Its only server code and if its related to the pin physically I'm not sure things will
from johnny-five.
U mean your arduino is damaged ?
Yes
What is is supposed to change ? Its only server code and if its related to the pin physically I'm not sure things will
What you mean in "server code"?
from johnny-five.
Related Issues (20)
- Novice ask next how to upload js to hardware HOT 7
- Using PWM and AC DImmer RobotDyn
- Cannot Input Mode Pin 12, 14, 15. ESP8266 HOT 4
- 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
- I2C Scanner?
- Input pull-up doesn't work on expanders HOT 1
- 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
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.