I'm experimenting with an Arduino Mega, using it to test some relay logic. The Arduino is powered from my benchtop power supply via the Vin and GND pins.
I have digital output pins connected to some 2N2222 transistors to drive the relays. Here is a rough schematic:
The relays are four DPDT relays configured as a full adder.
The problem occurs when I try to reset the Arduino by removing the the power. When I disconnect the +5v pin, the Arduino stays on and the relays stay energized. If I short the +5v pin to ground, that successfully resets the Arduino and the relays turn off.
How is the Arduino receiving power when +5v is disconnected? Does it have something to do with the transistors? How can I ensure that the Arduino is only turned on when I want?
EDIT It looks like this was a PEBCAK error; I had the Arduino board resting on top of my breadboard where some detritus was apparently shorting one of the power pins on the bottom! Problem is fixed now.