Bit's setting of a variable

I've been looking at this for a bit now and can't figure a good way yo write it

Say I have pins 2,3,4,5,6,7,8,9

So i place them in array

int myPins[] = {2, 3, 4, 5, 6, 7, 8, 9};

This the problem I need to set them in one run 0b11010000;
then have it set the whole set like digitalWrite does just one

Take a look here for details on Port Manipulation.

Not really what im looking for

int myPins[] = {2, 3, 4, 5, 6, 7, 8, 9};

some thing like 
myPins = 0b11101010;
digitalWrite(x,myPins);

Code to make that work I been all nigh trying to figure it out
I can't set it like one at time it lights the whole row and one time till set.

I did just that in the lampControl function in this sketch.

/*
    Greggs Flasher v.29
    A Flasher control unit for Greg's antique sign

    INPUTS:
       Digital:
         1 button to change the pattern
       Analog:
         1 pot. to control the rate of flashing

    OUTPUTS:
       Digital:
         5 relays that control 5 - 12v AC lamps

    Les Hawkins 8/5/2017
*/

#include <EEPROM.h>

//********* I/O PINS ***********

// INPUT
const byte BUTTON = 2;
const byte POT_PIN = A0;

// OUTPUT
const byte LAMP[5] = {3, 4, 5, 6, 7};

//***** GLOBAL VARIABLES *******

byte pattern;  // <<<<<<<<<<<<< HAVEN'T YET FIGURED OUT A GOOD WAY TO MAKE THESE VARIABLES LOCAL (encapsulation) <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
byte oldPattern;  // <<<<<<<<<<<<<<<<<<<<<<<< Maybe pointers or referances??? need to study this more <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
int eepromAddress;


void setup()  //___________________________BEGIN setup()____________________________________________________________________________
{
//  Serial.begin (115200);

  for (byte i = 0; i < 5; i++)
  {
    pinMode (LAMP[i], OUTPUT);
    digitalWrite(LAMP[i], HIGH);
  }

  pinMode (BUTTON, INPUT_PULLUP);

  while (EEPROM.read(eepromAddress) == 0xff)
  {
    eepromAddress++;
  }
  pattern = EEPROM.read(eepromAddress);
  oldPattern = pattern;

//  Serial.print ("Starting PATTERN = ");
//  Serial.println (pattern);
}


void loop()  //________________________________________BEGIN loop()____________________________________________________________________________
{

  pattern += buttonCheck();

  if (pattern > 6)
  {
    pattern = 0;
  }

  lampControl();
}


byte buttonCheck()  //___________________________BEGIN buttonCheck()____________________________________________________________________________
//  ******************** Read the button every 10 ms and store results in a ring buffer
{
  static byte buttonBuffer;   // ring buffer to store last 8 buttonReads
  byte buttonPressedMask = 0x07;  // used to check if the FIRST 3 bits of buttonBuffer are 1's  ( 0x07 == B00000111 )
  static bool buttonIsNowPressed = false;
  byte buttonState = 0;
  
  static const unsigned long bC_interval = 10;
  static unsigned long bC_startTime;
  unsigned long bC_currentTime = millis();

  if (bC_currentTime - bC_startTime >= bC_interval)
  {
    bC_startTime += bC_interval;  // reset Timer

    if (digitalRead (BUTTON))  // button IS NOT pressed so shift a 0 into the buffer
    {
      buttonBuffer = buttonBuffer << 1;
    }
    else                 // button IS pressed so shift in a 1
    {
      buttonBuffer = (buttonBuffer << 1) + 1;
    }

    if (buttonIsNowPressed == false)
    {
      if ((buttonBuffer & buttonPressedMask) == buttonPressedMask)  // if the first 3 bits are 1"s button is debounced pressed
      {
        buttonIsNowPressed = true;
        buttonState = 1;  // button has just been pressed
      }
    }
    else
    {
      byte releaseBuffer = buttonBuffer;
      releaseBuffer << 3; // 
      
      if (releaseBuffer == 0)  // if all bits are 0's button is debounced released
      {
        buttonIsNowPressed = false;
      }
    }
  }
  return buttonState;
}


void lampControl() //___________________________BEGIN lampControl()____________________________________________________________________________
{
  const byte PatternData[] [13] =   
  {  // First Element indicates # of PatternSteps, Following Elements indicate pattern to be displayed for that patternStep
    {11, B00000, B10000, B11000, B11100, B11110, B11111, B01111, B00111, B00011, B00001, B00000},          // Follow The Leader
    {10, B10000, B11000, B01100, B00110, B00011, B00001, B00011, B00110, B01100, B11000},                  // Scanner
    {10, B01111, B00111, B10011, B11001, B11100, B11110, B11100, B11001, B10011, B00111},                  // Reverse scanner
    {12, B00000, B10000, B11000, B11100, B11110, B11111, B11111, B11110, B11100, B11000, B10000, B00000},  // Up n Down
    {2, B10101, B01010},                                                                                   // Alternating
    {2,B11100, B00111},                                                                                    // Alternating sides
    {1, B11111}                                                                                            // All ON
  };
  static byte patternStep = 1;  // Index for patternData [] []
  byte numSteps = 0; // Array Element contianing number of patternSteps for current pattern
  
  unsigned long lC_interval = analogRead (POT_PIN);
  lC_interval = map(lC_interval, 0, 1023, 300, 3000);  // interval range = 300ms - 3 sec.

  static unsigned long lC_startTime;
  unsigned long lC_currentTime = millis();

  if (oldPattern != pattern)
  {
    patternStep = 1;
    oldPattern = pattern;
    updateEEPROM();
  }

  if (lC_currentTime - lC_startTime >= lC_interval)  // <<<<<<<<<<<< Maybe move this Timing sequence to loop() <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  { //                                                  <<<<<<<<<<<< and call lampControl() only when sequence expires <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    lC_startTime += lC_interval;

//    Serial.print ("STEP ");
//    Serial.println (patternStep);
//    Serial.print ("OUTPUT = ");


    byte bitMask = 0x01;
    for (byte i = 0; i < 5; i++)       // Output lamp Pattern for Current patternStep
    {
      if ((bitMask & PatternData [pattern] [patternStep]) == 0)
      {
        digitalWrite (LAMP[i], HIGH);  // Turn lamp OFF - Relays are active LOW

 //       Serial.print ("0");
      }
      else
      {
        digitalWrite (LAMP[i], LOW);   // Turn lamp ON - Relays are active LOW

 //       Serial.print ("1");
      }
      bitMask = bitMask << 1;
    }                                  // END lamp Output

//    Serial.println (".");

    patternStep++;
    if (patternStep > PatternData [pattern] [numSteps])
    {
      patternStep = 1;
    }
//    Serial.print ("        PATTERN = ");
//    Serial.println (pattern);
  }
}


void updateEEPROM()  //___________________________BEGIN updateEEPROM()____________________________________________________________________________
{
  int oldEepromAddress = eepromAddress;  //<<<<<< Is this an acceptable wear leveling algorythm? <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  eepromAddress++;
  if (eepromAddress > 1023)
  {
    eepromAddress = 0;
  }
  EEPROM.write (eepromAddress, pattern);  // write pattern to new address
  EEPROM.write (oldEepromAddress, 0xff);  // erase previous address by writing 1's
}

be80be:
Not really what im looking for

int myPins[] = {2, 3, 4, 5, 6, 7, 8, 9};

some thing like
myPins = 0b11101010;
digitalWrite(x,myPins);




Code to make that work I been all nigh trying to figure it out 
I can't set it like one at time it lights the whole row and one time till set.
myPinValues=0b11101010;

for(byte i = 0; i<8;i++) {
    digitalWrite(myPins[i],(myPinValues>>i)&1); 
}

But this is relatively slow, because digitalWrite itself is slow (mostly because of looking up the port and pin within the port). It’s 4.5uS or so for a write according to the benchmarks thread on a 16MHz uno.

If you were to choose all the pins to be on the same port, you could then do a single direct port write and write all the pins, eg:
PORTB=0b11101010;

Except, on the '328p boards, there aren’t more than 6 usable pins on a single port (the only port with all 8 pins is PD, but PD uses pins 0 and 1 for serial). The situation is better on most other AVRs.

I use direct port manipulation extensively, particularly since I use ATTiny chips very often, and the flash on those is very limited; I am pretty sure it is exactly what you need, just not as easy to use as you’d like.

That's what i was looking as i need 2 ports with 8 pins lol

You can piece together a function to write pins from multiple ports:

Say you had it on PD 2~7 and PC4 and PC5:

PORTD=(MyPinValues&0b11111100);
PORTC=(MyPinValues&0b00000011)<<4;

You’re gonna be really tight on pins driving that from an Uno.

A 1284p (or 644/324 - the smaller memory versions) has 32 output pins in 4 complete ports, and both serial ports are on PORTD, so you’ve got 3 unencumbered ports.

be80be:
That’s what i was looking as i need 2 ports with 8 pins lol

You have not told us why you cannot use digitalWrite to set one output bit after the other. It only takes a few µs to execute and the question is: why is this not fast enough?

I got a 1284p

Why is it not fast enough I have 64 leds you see ghosting or a whole line looks on.

I can write a port with a pic looks like arduino could but then I looked real good there not really enough pins per port I'm try the ports with the 1284p