I had a coding issue revolving around adding start and stop button, to replace a toggle switch, in my project. That has been resolved but has led to some very strange behavior. It was suggested I post the problem here so here goes. At the bottom is a link to the entire programming thread that got me to this point. Below is a summary of the problem.
Components are a Uno R3, an 8 channel relay board (using 5 of the relays), a 12 volt power supply outputting 12.27 volts. The power supply is typically powering 12 volt air solenoids via the relays as well as the Uno using the external power jack although, as you'll see below, I've tried several other combinations. At first I thought I may have damaged the Uno by making connections while it was powered up and possibly shorting something out. However I replaced the board and was diligent about not doing that and have the same issues with the second board.
Here's what's happening:
With only the processor powered by the usb (connected to my laptop) and both the start and stop buttons hooked up, and no 12 volt to the relays, everything appears to function correctly. The start button will start the system and the leds on the relays confirm the correct sequencing. Pressing the stop button will stop the system. All is right with the world except, of course, the solenoids and air cylinders aren't doing anything because there is no power to the solenoids.
With the processor and the relays powered by my 12 volt power supply and the stop button disconnected from the pin (currently pin 9) the start button starts the system and the relays, solenoids, and air cylinders all function correctly. The system will run the programmed number of cycles (currently 25) and then stop.
With the processor and the relays powered by my 12 volt power supply and the stop button connected to the pin (currently pin 9) the start button starts the system then random things happen. Typically it runs part of a cycle, firing a couple of cylinders, then stops. Pressing reset then start yields similar, but not necessarily exactly the same, results. It will run anywhere from a partial to full cycle then stop. I've confirmed the stop switch is not faulty and have even disconnect the other side of it from ground and get the same results. Going a step further simply plugging a jumper into pin 9, with nothing connected to or touching the other end, causes the same results.
And I have the same results as the last paragraph if I power the processor from the laptop and the relays from the 12 volt supply.
So why is one button (or more correctly one pin connection) messing everything up? The start button is on pin 12 and the stop button has been tried on pins 11, 10, & 9, on 2 different boards with no success.
I originally had the on/off toggle switch from the previous version connected to the ground pin on the digital side, next to pin 13. That is also where I currently have the start button grounded. I soldered up a male to multi female jumper so I could also connect the stop button there. The relay board ground is connected to the ground on the opposite side of the board as well as pins 2 through 6.
Thank you for any help you can offer!