Whenever all of the seatpads are "open", the Arduino reads arbitrary values. Sometimes, when one seat is closed, neighboring seats are read as on (digitalRead) which I assume is because the wires are interfering with each other.
Is there a way to make the seats grounded or something so that the readings from the inputs would be reliable? I cannot alter the seat pads, so said fix would have to be within my circuit. I made PCBs, but I don't really know what I'm doing, so I may have to get them redone anyway (only 10 of them.) I am fairly new to Arduino, so constructive criticism would be appreciated.
Am I allowed to post files of my PCB on the forum, or just screen shots?
The end goal is to use digitalInturrpts on each pin instead of digitalRead
From what you are describing I am assuming a seat is a switch (never read that term before). Not knowing your circuit I cannot really suggest either a pull up or pull down. When the "seats" are open that tells me you have an open line. That would explain what you are seeing. My way of doing it would be to put a pull up resistor on the switch and use ground on the other side so when the switch is closed the line to the Arduino is grounded. That will invert your logic but that is an easy fix in software. Maybe ~500 Ohm would work OK.
"Floating" inputs on the are undefined and they might read high or low. They are also very-high impedance which makes open/floating inputs very sensitive to electro-magnetic noise pick-up and that can make them switch randomly between high & low.
Clarification: Seat pads are effectively momentary switches that are normally closed, and open when the person sits. When the switch is closed, the corresponding Arduino pin is connected to +5v, so High?
Also: it is basically impossible for me to modify the pads themselves. Not because I’m unable, but because they are quite expensive, and I want to be able to buy more and use them with out modification.
Ok, pull-up/pull-down resistors…
You just connect pins 1-5 to ground each with a pull-down, and then it shouldn't stay floating?
@DVDdoug I am very interested in a software only approach if possible. Could you elaborate on:
@SteveMann This is a hardware question, but I did forget to state the pinMode: all pins relevant to the seats are set to input
Here's what happens:
Someone wants to do two things at once.
Aha, I can do that by making one thing an interrupt.
Oh, but wait a minute, nothing works.
I find out it's because interrupts are disabled during an interrupt service routine.
I realize (or I'm told) I can set a flag in the interrupt and poll it in the main program.
I then realize that the polling is as slow as the loop() is.
I then realize I could have just polled the switch in the first place.
First picture is just the Arduino and PS/2 connector, second is the entire pcb. Not sure the best way to upload the whole file. If that's needed, a link on how to do it would be nice.
I don't think the rest of it is relevant, but it's there. Each of the ICs are Shift Registers with resistors next to them. Each of the Sets of 4 through holes are 5mm RGB LEDs. The Sets of 3 through-holes are sliding switches. If I have to order new PCBs, does anyone know of an actual LED driver with resitors and/or brightness regulation that has 7 RGB outputs, or can be run in series? Not a necessity, but I'm sure there's a better way to do it.
Pins of PS/2:
3 1 2 4
5 ----- 6
D1 is the 2nd pin from the left on the bottom row of pins.
Yes, I did, but I didn't throughly test the bread board.... whoops... 33 Nano's "+5v" pin isn't 5v, despite trying different input voltages through the VIN... my 5V rail is connected straight to the VIN which is regulated to 5V.
If I were to get the PCB remade (sounds like I will), how might I get the components already soldered on? I saw SMD Service on JLC where I got the last PCBs, but I don't know how to add SMD components using Diptrace. Do I need a new program, or can I keep using Diptrace?
Assuming I set each of the 5 seats to "INPUT_PULLUP", there aren't any obvious issues that I should have, are there? I'll have to switch the "common" pin on the PS/2 to GND instead of 5V, but I can just break the trace and connect to the GND rail.