parrallel output on digital pins

I'm working on a solar charge controller.
And am wondering how to get the digital pins to output a value.
I can use digitalWrite to address one pin at a time but can I change all the pins at once?
For instance when the solar panel voltage at the battery exceeds 14.8 I'd like the value to increase until the voltage is at 14.8.
Example:The first load is 1 amp, the next is 2, 3rd load is 4, largest load is 8 amps.
There must be some way I can use these binary values.
One relay on each digital pin and the load can increase by 1 amp each step.

Using the ++ to increase the value of these digits if the voltage is high and -- to decrease the value as the voltage decreases.
If I could put the digital value onto the digital pins it would turn on the appropriate load.
Is there a way to do this or do I need an array and a for loop to change the digital outputs one at a time?

/*
  Diversion regulators help charge and protect batteries by reading the voltage of a solar panel
 and keeping it at or below the limit by diverting the extra power to a load.
 Input from analog pin 0 controls output on digital pins 13, 12 and 11.
 The goal is to hold the battery at 14.8 for 3 hours, then drop it to 13.2 for the rest of the day.
 
 The circuit:
 * A voltage divider provides a percentage of the total voltage.
 * one resistor to ground
 * the other resistor to source voltage
 * Both resistors are connected together and this center tap is connected to the analog pin0
 * 4 different loads are used to hold the voltage near the required voltage
 */

int lowPin = 13;      // dump a small load to maintain desired level
int midPin = 12;       // dump a bigger load
int highPin = 11;      // dump a large load, might not be used
int sensorPin = A0;    // select the input pin for the voltage divider
int sensorValue = 0;  
int load = 0;
int battLevel = 14.8;    //voltage goal, this variable will 14.8 or 13.2 
int time = 0;
int timeout = 300;    //

void setup() {
  // declare the digital pins as OUTPUTs:
  pinMode(lowPin, OUTPUT);
  pinMode(midPin, OUTPUT);
  pinMode(highPin, OUTPUT);
  time = 0;
  sensorValue = analogRead(sensorPin);
}

void loop () {
  if (sensorValue < 12.8) {        // if the sun has gone down long enough for the batteries to drop below 12.8 volts
    battLevel = 14.8;              // the goal becomes 14.8
  }

  if (sensorValue > battLevel) {   // if the battery level goes above 14.8
    time = 0;                      // it should try to hold it there for 3 hours
    loadLevel ();                  // it goes to the load level function
  }
  battLevel = 13.2;                // timed out on the 14.8 start the float charge
  loadLevel ();                    // loadLevel function holds it at 13.2 indefinately
}
void loadLevel() {
  if (sensorValue > battLevel) {   // appropriate loads get applied to keep it at 14.8 or 13.2
    load++;                        // voltage too high add another load 
    delay (50);                       
    time++;
    if (sensorValue < battLevel) {
      load--;                        // voltage too low, remove a load
      delay (50);                    //
      time++;
      if (battLevel == 14.8 && time > timeout) {
        return;
      }
    }
  }
}

There are things wrong with your code. For instance :

You only read the level on sensorPin once and that is in setup(). This does not allow monitoring of the voltage except at that moment.

int battLevel = 14.8;    //voltage goal, this variable will 14.8 or 13.2

An int is an integer. 14.8 and 13.2 aren't integers

graphing:
And am wondering how to get the digital pins to output a value.
I can use digitalWrite to address one pin at a time but can I change all the pins at once?
For instance when the solar panel voltage at the battery exceeds 14.8 I'd like the value to increase until the voltage is at 14.8.

You will have to explain in a lot more detail what you wan to do. What will the pins be connected to so that they can control the voltage? Best thing would be to draw a diagram and post a photo of it.

...R

Some of this may help you.

The "voltage divider" circuit your using, if sized properly, will let you read the system voltage but the value from the analog input will be a number from 0 to 1023. You will have to use some testing to calibrate what value corresponds to your desired voltage level(s). It may be easier after you know these numbers just to do your control logic using them.

If you feel that you want to continue using the common Battery voltage charge values try using a multiple of 10, so 12.8 becomes 128 and so on or simply declare them to be "float" rather than "int".

ALSO Put the
sensorValue = analogRead(sensorPin);
into the void loop() portion of your sketch. This is the part of your program that goes over and over again and you will have refreshed readings each time the loop runs.

Regards

All good points.
I posted the beginnings of a sketch so everyone would have some idea what direction I am going. I hope we can pick it apart later.
Trying to write a program for a simple solar panel diversion regulator that uses one of the many relay boards already available. A solar charge controller that runs pumps, compressors or fans,.. something useful when the battery is full or as it's charging.
I was planning on starting a DIY with a list of the goals, where we could all work together and figure out the best way to take. I'm sure together it will even go a different direction like using states.
I'm sure we can come up with something better than what I have here. I'm just using this to help me learn to write programs and ran into a question.

That question is can I turn more than one digital output pin high or low at the same time?

Can I put the value 3 (0011) on the digital pins?
That would turn on a 2 loads possibly equaling 3 amps.

Or do I need to use a for loop with an array and digitalWrite the value (HIGH/LOW) in each individual address of an array to each pin?

can I turn more than one digital output pin high or low at the same time?

Yes using port manipulation, but is time that critical in your application that turning them on sequentially with a few microseconds delay would matter ? We are, after all, talking about relays here.

Can I put the value 3 (0011) on the digital pins?

By definition a single digital pin is either on or off. If you mean that with 4 pins a value of 3 would turn on 2 of them, then yes you can. Use bitRead() to find the state of each bit in the variable and if it is 1 turn on the associated pin. A for loop would be good for that.

graphing:
That question is can I turn more than one digital output pin high or low at the same time?

Your question is focused on some specific idea that you have in your mind and have not explained to us.

I think it would be more useful if you tell us WHAT you want to happen rather than asking very narrow questions about HOW to apply a specific solution. There may be a better (and simpler) way.

...R

UKHeliBob:
Yes using port manipulation, but is time that critical in your application that turning them on sequentially with a few microseconds delay would matter ? We are, after all, talking about relays here.By definition a single digital pin is either on or off. If you mean that with 4 pins a value of 3 would turn on 2 of them, then yes you can. Use bitRead() to find the state of each bit in the variable and if it is 1 turn on the associated pin. A for loop would be good for that.

Thanks, for understanding the question.
I'll research bitRead and find out how that works.
True there is no hurry and turning on one at a time will work.
I was curious if there is a way to use less code.
Hoping for some sort of digitalPut command that would put the entire digital value of a variable onto the digital pins at once.

The only circuit is a voltage divider connected to an analog pin and some relays connected to the digital pins.
So I don't know if I should start a DIY charge controller thread in the project fora,....
or in programming, since programming is the only real hurdle.
Suggestions??

When I do; the goals will be well listed.
As well as the components used.

graphing:
So I don't know if I should start a DIY charge controller thread in the project fora,....

My strong preference is "one project, one Thread" (this one) as it makes it easy for everyone to access all of the information.

...R

I'll research bitRead and find out how that works.
True there is no hurry and turning on one at a time will work.

Something to get you started

void setup()
{
  Serial.begin(115200);
}

void loop()
{
  if (Serial.available())
  {
    byte inValue = Serial.read() - '0';
    for (int p = 7; p >= 0; p--)
    {
      if (bitRead(inValue, p))
    {
      Serial.print("on  ");
      }
      else
      {
        Serial.print("off ");
      }
    }
      Serial.println();
  }
}

I will leave you to add code to turn the output pins on or off. The p variable in the for loop would be useful as an index to an array of output pin numbers.

An alternative to this approach would be to use a shift register. Shift the input value into the SR and its 8 output pins will be turned on or off depending on the corresponding bit value of the input variable. This really would change the state of all of the outputs at the same time.

UKHeliBob:
Yes using port manipulation, but is time that critical in your application that turning them on sequentially with a few microseconds delay would matter ? We are, after all, talking about relays here.By definition a single digital pin is either on or off. If you mean that with 4 pins a value of 3 would turn on 2 of them, then yes you can. Use bitRead() to find the state of each bit in the variable and if it is 1 turn on the associated pin. A for loop would be good for that.

So my search for parallel outputs didn't go well.
That's why I started this post.
It seems a better search term is:
port manipulation
Thanks for the tip.
Some of the results:
http://tronixstuff.com/2011/10/22/tutorial-arduino-port-manipulation/

http://forum.arduino.cc/index.php?topic=278648.0