I am new at programming and i am writing my project sketches in modules to get each working before putting it all together. I have an arduino uno, a protoshield board stacked on the uno. I also have a 2 channel relay like this : http://www.ebay.com/itm/like/140764956257?lpid=82&chn=ps&ul_noapp=true
One sketch takes 5 values from a remote light sensitive resistor, averages them and displays the result on a serial monitor. The code works fine and it loops continuously when plugged into the usb cable. If I have load the sketch via a usb cable, and then disconnect the usb cable with a 12v external power supply plugged into the arduino, the sketch stops. All the components for this sketch are mounted on the protoshield.
Another module turns a relay off and on, and the relay has a different external power supply. The relay is wired isloated from the arduino. (The jumper between the JDVCC-VCC terminals is off) . Its wired like the diagram in this link: http://yourduino.com/sunshop//index.php?l=product_detail&p=201 The arduino runs the relay board but the external power supply runs the relays themselves.
I have a light bulb connected to the relay. In this case, I load the arduino board with the usb cable, and it works fine. The light bulb goes off and on. I can then pull the usb cable with the 12 volt external power supply plugged into the board ( JDVCC and GND) and the sketch continues to operate normally.
I am not trying to operate both sketches at the same time. I have the protoshield stacked on the arduino and I know the 5v is available to the protoshield because I have used the 5v pins for other sketches powering an lcd. Any ideas on why a sketch with components on a protoshield would run fine on usb power but not on 12v external power? Thanks