digitalWite problem

Please explain why this part of my sketch only works on pin 6 when run. I was expecting it to work on all. They all have been activated output prior to this code

  digitalWrite(6, HIGH);    // Turns ON Relay 3  on digital pin 6 (blue) 
  digitalWrite(7, HIGH);    // Turns ON Relay 2 on digital pin 7 (yellow)
  digitalWrite(8, HIGH);    // Turns ON Relay 1 on digital pin 8  (red)   
  delay(200);                //length of purge
  digitalWrite(6, LOW);     // Turns OFF Relay 3 on digital pin 6
  digitalWrite(7, LOW);     // Turns OFF Relay 2 on digital pin 7  
  digitalWrite(8, LOW);     // Turns OFF Relay 1 on digital pin 8

What's attached to those pins? If there are really relays attached, they may be drawing too much current.

They all have been activated output prior to this code

If that's the case then that code should work.

What is connected to the pins? Hopefully not relays directly.


Rob

The pins are connected to a relay shield. If each of the pins are switch on then off in turn it works, but not switching all on then all off

How is the shield powered? Maybe switching all on at once causes a spike in the power supply.

Try switching them all on but with a delay (say 500mS) between each one.


Rob

the Arduino is powered via usb 5 volt. The shield is powered by a separate 9 volt supply and the relays attached to the shield by a separate 12volt supply. If there is no problem with the code I will experiment with some leds tomorrow. Thanks