Problem getting pins to start off LOW

My sketch is simply having pins as outputs with them going HIGH or LOW. My issue is that I'm trying to start the Loop with all of the pins LOW. I have tried numerous ways and cannot seem to achieve them all starting LOW. They all want to start HIGH. I've checked out numerous articles & books with no luck. Can you suggest what I should do? Here is a snapshot of the sketch. This is on a Mega board. void setup() { pinMode(22, OUTPUT); pinMode(6, OUTPUT); pinMode(7, OUTPUT); pinMode(8, OUTPUT); pinMode(26, OUTPUT); pinMode(31, OUTPUT); pinMode(33, OUTPUT); pinMode(35, OUTPUT); pinMode(37, OUTPUT); pinMode(39, OUTPUT); pinMode(41, OUTPUT); pinMode(43, OUTPUT); pinMode(45, OUTPUT); pinMode(47, OUTPUT); pinMode(49, OUTPUT); pinMode(51, OUTPUT); pinMode(53, OUTPUT); }

void loop() { digitalWrite(6, LOW); digitalWrite(7, LOW); digitalWrite(8, LOW); digitalWrite(22, LOW); digitalWrite(26, LOW); digitalWrite(31, LOW); digitalWrite(33, LOW); digitalWrite(35, LOW); digitalWrite(37, LOW); digitalWrite(39, LOW); digitalWrite(41, LOW); digitalWrite(43, LOW); digitalWrite(45, LOW); digitalWrite(47, LOW); digitalWrite(49, LOW); digitalWrite(51, LOW); digitalWrite(53, LOW); delay(1000); digitalWrite(6, HIGH); delay(500); digitalWrite(26, HIGH); delay(1000); digitalWrite(31, HIGH); delay(3000); digitalWrite(33, HIGH); delay(5000); digitalWrite(35, HIGH); delay(6500); digitalWrite(37, HIGH); delay(7000); digitalWrite(39, HIGH); delay(6000); digitalWrite(41, HIGH); delay(7500); digitalWrite(22, HIGH); delay(1000); digitalWrite(31, LOW); delay(5000); digitalWrite(39, LOW); delay(7500);

Yup, that starts them out all LOW at the beginning of the loop. What makes you think they're not LOW? What are you seeing that convinces you otherwise? What is connected to them and how?

Please read the "How To Use This Forum" post at the top of any of the boards and learn the forum rules about posting code. You are breaking them now. You will also get tips on how to get good help without wasting a bunch of time. Why anyone would start using something without reading the instructions first is beyond me, but it's OK. Go read them now and do better next time.

Until you change them to OUTPUT, the pins will be INPUT. This causes them to float. To keep them from floating HIGH you should add a (roughly) 10 kOhm pull-down resistor to each output pin.

johnwasser: Until you change them to OUTPUT, the pins will be INPUT. This causes them to float. To keep them from floating HIGH you should add a (roughly) 10 kOhm pull-down resistor to each output pin.

He put them all to OUTPUT in setup as far s I can see. They're all being sent LOW with digitalWrite, so I suppose his issue is in whatever is connected to them.

The pins feed relays that control lights. I know they are all starting off HIGH because the lights start off by being ON instead of OFF.

That don't mean the pins are high necessarily. They could be active low relays. That's what you get on most of these relay shields and such.

Show us what you have and how you have it wired.

I didn't have any 10K but wired some 1K resistors just after the pins. The program still starts off with all the pins HIGH. I've tried before setting them all HIGH to begin to see if this would have the LOW affect on them, and still the same results of all starting off HIGH.

I think you've got an issue with your wiring that is confusing you into thinking that. I asked you to show it but you refuse. So there's not much anyone can do to help you until you do. If you come back to post again and don't have a schematic and a description of the components then just save yourself the trouble and don't bother.

Was answering the other person who mentioned resistors. How would I attach either a photo or a schematic drawing on this format?

Thanks for the input. Problem solved. Just accommodating the fact that the pins naturally start HIGH, and dealing with that in the program.

cdhc6slyc: Thanks for the input. Problem solved. Just accommodating the fact that the pins naturally start HIGH, and dealing with that in the program.

It would still be interesting for us (not so much you, since you're happy with the way it works now ;) ), to see evidence that they do start high. If the relays are active low modules as suggested, you may think the pins are high simply because the relays are active but it's a low doing that.

Easy way to prove it is to grab an led (with series resistor) and put the anode in a pin set to output with the cathode to ground and see if it's on before you digitalWrite() the pin one way or the other. Or stick your voltmeter in the pin and see what it says.

I just ran the below Uno code, and the pins are definitely low until until I digitalWrite() them high. I checked that with a voltmeter, and leds with the anode on the pin and cathode to ground. The leds are off to start and come on with the digitalWrite()s to high.

It might also be the way you have your load wired with the relay's NC and NO pins.

void setup()
{
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  delay(5000);
  digitalWrite(2, HIGH);
  digitalWrite(3, HIGH);
  digitalWrite(4, HIGH);
  digitalWrite(5, HIGH);
  digitalWrite(6, HIGH);
}//setup

void loop()
{

}//loop

Perhaps someone who knows their way round the source code could point us to the appropriate part?

cdhc6slyc: Thanks for the input. Problem solved. Just accommodating the fact that the pins naturally start HIGH, and dealing with that in the program.

You still haven't proven to use that they start HIGH. So please don't state that they are "naturally HIGH".