sequential led can it be done with arduino

I want to have a circuit when p/b is pressed 24 leds scroll from both sides to a certain point ie from left hand side one led scrolls to say the 8th led and stops,at the same time from the right hand side 24th led scrolls to the 8th led also. then if I press the p/b again, this time scrolls from the left to the 16th led and from the right scrolls 8 places to the 16th led.project like

can it be done with arduino

Yes.

24 is kind of a lot of LEDs. While the larger Arduinos such as the Due and Mega do have this many output pins, you can't drive that many LEDs simultaneously, due to the current limitation of the chip. If you want to have them all on at the same time then you will need an LED driver.

There's some nice chips available like the MAX6971 that will drive a lot of LEDs and you only need to use 3 Arduino pins to control an unlimited number of the chips.

You may also consider addressable LEDs like the WS812 which can be bought in strips. Then you can change colours as each LED has full RGB control.

I already have a custom made board with three shift registers unl2803 and a attiny4313 and 3 ahc573, which with the code I have, it works perfectly to scroll left to right just need someone to tell me how to modify the code?

/*
  Predator Testing
 */

// predator board Test Routines

//setup PORTB which is used to drive the data latches
// NOTE OUTPUT = 1  NOT like PIC's

  #define DataPort   PORTB
  #define StrobePort PORTD
  #define DOWN     0
  #define UP       1

    int PortBdirection = 0xFF;
    int PortDdirection = 0xF9; // B1111 1001;  // bits 1,2 are button inputs

    int Strobe1High    = 0x08;  // B0000 1000; // PD3 High
    int Strobe2High    = 0x10;  // B0001 0000; // PD4 High
    int Strobe3High    = 0x20;  // B0010 0000; // PD5 High
    int Strobe_All     = 0x38;  // B0011 1000; // All High

    int DataHold1 = 0;
    int DataHold2 = 0;
    int DataHold3 = 0; // all output data hold registers to zero
    
    int TestData = 0;

   // These data are used by the Larson/Kitt/Cylon Scanner
   
//    int Direction1 = DOWN;
//                int Direction2 = DOWN;
//                int Direction3 = DOWN;
//       #define Larson1  3
//       #define Larson2  5
//       #define Larson3  7
       
//                int Cylon1 = Larson1;
//                int Cylon2 = Larson2;
//                int Cylon3 = Larson3;
  // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

          int StartBank = 1; // needed for scan 24

    // all below for PWM trial
    
//    int PWMperiod = 0; // this number represents the entire period of the PWM waveform
//    int PWMdone   = 0; // return value of PWM cycle
//    int PWMlo   = 0; // this is the PWM low time counter
//    int PWMhi   = 0; // this is the PWM high time counter
//    int PWMloVal  = 0; // this is the starting low value
//    int PWMhiVal  = 0; // this is the starting high value


// ############ Functions HERE ##################################
//          Location  D C B A   D C B A
//            Value   (V) 0 0 1 1   0 1 1 1
//            Pattern (P) 0 1 1 0   0 1 1 0
//
// Step 1 Temp = V AND P    0 0 1 0   0 1 1 0
// Step 2 Clear = Temp EOR V  0 0 0 1   0 0 0 1
//
// STEP 3 Set   = Clear EOR P 0 1 1 1   0 1 1 0

int Fn_LatchData1(void)
{
  DataPort = DataHold1;
  StrobePort = (StrobePort ^ Strobe1High); // toggle Latch 1 to High EOR
  StrobePort = (StrobePort ^ Strobe1High); // toggle Latch 1 to Low  EOR
  return 0;
}
//
int Fn_LatchData2(void)
{
  DataPort = DataHold2;
  StrobePort = (StrobePort ^ Strobe2High); // toggle Latch 1 to High EOR
  StrobePort = (StrobePort ^ Strobe2High); // toggle Latch 1 to Low  EOR
  return 0;
}
//
int Fn_LatchData3(void)
{
  DataPort = DataHold3;
  StrobePort = (StrobePort ^ Strobe3High); // toggle Latch 1 to High EOR
  StrobePort = (StrobePort ^ Strobe3High); // toggle Latch 1 to Low  EOR
  return 0;
}
//
int Fn_LatchAll(int LocalData)
{
  DataPort = LocalData;
  StrobePort = (StrobePort ^ Strobe_All); // toggle All Latches to High EOR
  StrobePort = (StrobePort ^ Strobe_All); // toggle All Latches to Low  EOR
  return 0;
}
//==========================================
int Fn_Scan24(void)
{
  if (1 == StartBank)
  {
    if (128 == DataHold1)
    {
      DataHold1 = 0; // clear this bank
      DataHold2 = 1; // start the next bank
      StartBank = 2; // select next bank
      return 0;
    }
    else
    {
      // DataHold1 = DataHold1 << 1;
      DataHold1 <<= 1;
      return 0;
    }
  }
  
  //
    if (2 == StartBank)
    {
      if (128 == DataHold2)
      {
        DataHold2 = 0; // clear this bank
        DataHold3 = 1; // start the next bank
        StartBank = 3; // select next bank
        return 0;
      }
      else
      {
        // DataHold2 = DataHold2 << 1;
        DataHold2 <<= 1;
        return 0;
      }
    }
  //
    if (3 == StartBank)
    {
      if (128 == DataHold3)
      {
        DataHold1 = 1; // restart the scan
        DataHold2 = 0; // clear middle bank
        DataHold3 = 0; // .. and this one
        StartBank = 1; // select next bank

        delay(100); // The delay Between passes. NOTE, leaved BIT24 ON
        return 0;
      }
      else
      {
        // DataHold3 = DataHold3 << 1;
        DataHold3 <<= 1;
        return 0;
      }
    } 
  return 0;
}

/*

int Fn_SetPWMperiod(int temp)
{
  PWMperiod = temp; // set the overall PWM period
  return 0;
}

int Fn_SetPWMto(int temp)
{
  PWMhiVal = temp;  // PWM start to this value
  PWMhi = temp;   // Set the hi timer to this value
  PWMloVal = PWMperiod - temp;      // PWM lo start time to overall period - high time
  PWMlo = PWMloVal; // Set the lo timer value
  return 0;
}

int Fn_DoPWM(void)
{
  
  if (0 == PWMlo && 0 == PWMhi)
  {
    PWMlo = PWMloVal;
    PWMhi = PWMhiVal;
    return 1; // flag cycle complete
  }

  //doPWM high time
  if (PWMhi != 0) // if we have high time left to run, do it
  {
    DataHold1 = 0xFF; // all pins high
    PWMhi --; // decrement high timer
  }
  else
  {
    DataHold1 = 0x00; // all pins low
    PWMlo --; // decrement low timer
  }
  Fn_LatchData1();
  return 0;
}

int Fn_Police(int temp)
{
  switch (temp)
  {
      case 0:
      case 2:
      case 4:
      DataPort = 0xF0;
      break;
      
      case 1:
      case 3:
      case 6:
      case 8:
      case 10:
      case 18:
      DataPort = 0x00;
      break;

      case 5:
      case 7:
      case 9:
      DataPort = 0x0F;
      break;
      
      case 11:
      case 17:
      DataPort = 0x18;
      break;
      
      case 12:
      case 16:
      DataPort = 0x24;
      break;
      
      case 13:
      case 15:
      DataPort = 0x42;
      break;
      case 14:
      DataPort = 0x81;
      break;
 
      default:
      DataPort = 0x00;     
  }
  return 0;
}

*/

int Fn_ClearAllPorts(void)
{
  StrobePort = 0;
  Fn_LatchAll(0);
  return 0;
}


// the setup function runs once when you press reset or power the board
void setup()
{

  DDRB = PortBdirection;
  PORTB = 0x00; // B0000 0000; // sets digital pins low

  // set up PortD, used as input and latch strobe outputs.
  DDRD = 0xF9;  // B1111 1001;  // bits 1,2 are button inputs
  DDRD = PortDdirection;
  PORTD = 0x00; // B0000 0000;  // force all output pins low


  Fn_LatchAll(0);
//  DataHold1 = 2;
//  DataHold2 = 1;
//  DataHold3 = 4;
//  Direction1 = UP;

// Code below is for PWM routines
//  Fn_SetPWMperiod(80);
//  Fn_SetPWMto(0);
//  PWMdone = 0;

 // StrobePort = (StrobePort ^ Strobe_All); // toggle All Latches to High EOR

  Fn_ClearAllPorts();
  
  // Larson Scanner
  
  DataHold1 = 2;
  DataHold2 = 1;
  DataHold3 = 4;
//  Direction1 = UP;

}

// the loop function runs over and over again forever
void loop()

{ 
//   Fn_ClearAllPorts();
 
// for  (int count = 1; count <= 500; count++)

  {
    Fn_Scan24();
    Fn_LatchData1();
    Fn_LatchData2();
    Fn_LatchData3();
                delay(5);
  }    
}

Witholding information like that makes us less likely to want to help. Read the "how to use this forum" guidelines.

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Can you tell us your electronics, programming, Arduino, hardware experience?

Thanks.. Tom.. :slight_smile: