Hi guys, first of all sorry if I've choose the wrong category and use wrong terms, I'm very noob with eletronics (I'm just a web developer) and not a native english speaker.
I'm trying to create a chessboard with a matrix of 64 reed switchs, first I'm trying with only four. The problem that I'm facing is that when the reed is closed I receive 1 as value for my input, good, but when it is open I start to receive randons 0 or 1. I understood the concept that disconnect is not equal to 0 but how can I solve it? I dont use gnd and 5v from arduino just input and output. I read about pullup mode of pins but Johnny-five seens to not have it. someone can help me? Other question if I dont do nothing and try to solve it in code, like... "if it stays 1 for 500ms it is closed, if not it is opened, is that a problem for the circuit? I mean can something stop to work?
my code is that
const five = require('johnny-five')
const board = new five.Board({ timeout: 3600 })
board.on('ready', function () {
const pin2 = new five.Pin({
pin: 2,
mode: 0,
})
const pin5 = new five.Pin({
pin: 5,
mode: 1,
})
pin2.high()
pin5.read(function (error, value) {
console.log(value)
})
})
If your chess pieces have magnets in them, you did not tell us how the reed switches are controlled, then any movement of a chess piece will cause any switches in it's path to close and open.
Not much you can do about that.
Paul
I used diodes to prevent that problem. It should work like a keyboard, the problem is when without a piece there it shows random 1 or 0 insted of a 0, that is problem I'm trying to solve =/
I'm so sorry for the bad way I tried to explain my problem
The good news is that I solved it. The 'pull up resistors' was the key as @PerryBebbington said
"Johnny five" is a javascript library to comunnicate with arduino from nodeJs. I learned how to set up "INPUT_PULLUP" mode from it and leard how this works and every thing is fine now, thank for all the help and again, sorry for the way I tried to explain, it is a kind hard to do begin so noob at eletronics and bad english speaker