Input to output with reed switch with johnny-five

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() (error, 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.

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 =/

thanks :slight_smile:

Well, if we could see your actual code we might decipher what it is that your are doing and why it is not working. :roll_eyes:

Additionally, a proper description of the whole assembly ± detailed photos.

Jonny five? Am I the only person who does not know what that strange expression means?

Your description screams 'no pull up resistors', but without more information it's impossible to say for sure.

It sure does, but I was getting to that obliquely. A proper description is a fundamental requirement. :face_with_raised_eyebrow:

1 Like

I'm so sorry for the bad way I tried to explain my problem :frowning:

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

1 Like

I may not completely understand what you want here but
How to write Timers and Delays in Arduino
includes an example sketch for
Delay execution until condition has been true for X secs


This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.