For eBay Purchase Click Here For Led Labs For Hobby Or Education

Led Labs
Led Labs
  • Home
  • Assembly AND PARTS LIST
  • PROJECTS
  • BUY
  • EMF, MONOSTABLE, COUNTER
  • PIC BASIC EXAMPLE PROGRAM
  • LOGIC GATE EXPERIMENT
  • LDR AND VCO VIDEO
  • LAB VIDEOS
  • MORE
    • ARDUINO
    • CONNECTION TO WS2811 LEDS
    • 24 BIT SHIFT REG CODE
    • 24 BIT SHIFT REG CODE (2)
    • USING SHIFT REGISTERS
    • DRIVING A STEPPER MOTOR
    • CASCADED DOT MATRIX DISP
    • LED LABS SILK SCREEN
    • SOME EXPLAINED SCHEMATICS
    • LOGIC TRUTH TABLES
    • LEDLABS VIDEO
    • LED LAB & GOLDEN SPIRAL
    • SIGNAL DEGRADATION
    • TRANSISTOR OUTPUT TEST
    • LOGIC GATES
    • CHOOSING POTENTIOMETERS
    • LOTTERY GENERATOR IDEA
  • More
    • Home
    • Assembly AND PARTS LIST
    • PROJECTS
    • BUY
    • EMF, MONOSTABLE, COUNTER
    • PIC BASIC EXAMPLE PROGRAM
    • LOGIC GATE EXPERIMENT
    • LDR AND VCO VIDEO
    • LAB VIDEOS
    • MORE
      • ARDUINO
      • CONNECTION TO WS2811 LEDS
      • 24 BIT SHIFT REG CODE
      • 24 BIT SHIFT REG CODE (2)
      • USING SHIFT REGISTERS
      • DRIVING A STEPPER MOTOR
      • CASCADED DOT MATRIX DISP
      • LED LABS SILK SCREEN
      • SOME EXPLAINED SCHEMATICS
      • LOGIC TRUTH TABLES
      • LEDLABS VIDEO
      • LED LAB & GOLDEN SPIRAL
      • SIGNAL DEGRADATION
      • TRANSISTOR OUTPUT TEST
      • LOGIC GATES
      • CHOOSING POTENTIOMETERS
      • LOTTERY GENERATOR IDEA
  • Home
  • Assembly AND PARTS LIST
  • PROJECTS
  • BUY
  • EMF, MONOSTABLE, COUNTER
  • PIC BASIC EXAMPLE PROGRAM
  • LOGIC GATE EXPERIMENT
  • LDR AND VCO VIDEO
  • LAB VIDEOS
  • MORE
    • ARDUINO
    • CONNECTION TO WS2811 LEDS
    • 24 BIT SHIFT REG CODE
    • 24 BIT SHIFT REG CODE (2)
    • USING SHIFT REGISTERS
    • DRIVING A STEPPER MOTOR
    • CASCADED DOT MATRIX DISP
    • LED LABS SILK SCREEN
    • SOME EXPLAINED SCHEMATICS
    • LOGIC TRUTH TABLES
    • LEDLABS VIDEO
    • LED LAB & GOLDEN SPIRAL
    • SIGNAL DEGRADATION
    • TRANSISTOR OUTPUT TEST
    • LOGIC GATES
    • CHOOSING POTENTIOMETERS
    • LOTTERY GENERATOR IDEA

SHIFT REGISTER LED DISPLAY CODE (2)

COPY & PASTE CODE INTO ARDUINO SOFTWARE ENVIRONMENT

 

//....................................................SHIFT REGISTER 2 PROGRAM………………………………………..


//……copy and paste code into arduino ide a free software environment

//........that can be downloaded to use



//..      THE ATTINY85 WAS USED TO TEST THIS EFFECT AND USES PIN 0,1,2 AS DEFINED

 //…   .BELOW IN THE TOP OF THE CODE

//.........IT IS A SMALL SIZE AND CAN DRIVE THE SHIFT REGISTERS LIKE THE ATMEGA328PU 

//.........IF THIS METHOD IS USED, IT FREES UP THE ATMEGA ON BOARD TO MAYBE DRIVE THE //….....DOT MATRIX DISPLAYS


//..USING THE ATMEGA ON BOARD SIMPLY CHANGE THE PINS FROM 0,1,2 DATA PIN,

//..LATCH PIN, CLOCK PIN TO 9,10,11 IN THE CODE OR USE STANDARD SPI PINS

//.10,11,13 ALL PINS AVAILABLE ON LEDLABS ATMEGA SECTION

//..spi pins , clock 13,11 data in, and 10, latch/strobe,   .IF USING THESE SPI PINS       


//..THESE ROUTINES CAN ALSO BE STROBED WITH SOUND,

//..DOWNLOAD THE CODE TO ATMEGA328P OR ATTINY85 OR PREFERRED MICRO AND TEST //.FUNCTIONALITY


//. DISCONNECT THE STROBE PIN GOING TO THE SHIFT REGISTERS AND CONNECT THE PWM //..FROM MIC BASS MODULE

//..ADJUST PWM FOR CORRECT AMBIENT SOUND LEVEL TO MAKE IT SOUND ACTIVATED

//..TRY ADDING THE LATCH OUT OF THE MONOSTABLE BY PWM AS INPUT HERE AND LATCH  //.OUT OF THIS TO STROBE IN

//..SETTING FOR A SECOND OR SO, THIS KEEPS THE PROGRAM CODE RUNNING AT THE 

//..SAIID INTERVALS, IT IS QUITE POSSIBLE THAT THE LATCH OUT OF THE MONOSTABLE //..WOULD REQUIRE INVERTING FIRST BY USING ONE OF THE HEX INVERTERS IN THE

//..SCHMITT TRIGGER SECTION, THEN CONNECTING TO THE STROBE IN OF THE SHIFT //..REGISTER.

//..IF THE PWM IS SET UP  TO MATCH THE SOUND/MUSIC WELL THIS SHOULD NOT BE //../NECESSARY

//..THE INVERSION THROUGH THE HEX INVERTER MAY YIELD BETTER RESULTS.

//..ALTHOUGH THE MONOSTABLE LATCH OUT AFTER INVERSION FROM THE HEX INVERTER //...WITH A 1-2 SECOND DELAY

//..ALSO GIVES A GOOD EFFECT. IT IS A LOT LESS OF STOP START OF THE PROGRAM

//..AS A SECOND OR SO CAN BE VIEWED OF THE CODE (LED DISPLAY) WHEN TRIGGERED

//..THESE ARE JUST EXPERIMENTAL IDEAS, AND NO CODING IS WRITTEN INTO THE

//..PROGRAM TO MAKE IT SOUND ACTIVATED



//Define which pins will be used for the Shift Register

int dataPin = 0; // Change these pins for arduino atmega328p to 9,10,11

int latchPin = 1;  // LATCH IS SAME AS STROBE MARKED ON LEDLAB SHIFT INPUT

int clockPin = 2;


int counter = 0;


int seq1[14] = {1,2,4,8,16,32,64,128,64,32,16,8,4,2}; //The array for storing the // byte2  value

int seq2[14] = {128,64,32,16,8,4,2,1,2,4,8,16,32,64}; //The array for

int seq3[8] = {1,2,4,8,16,32,64,128}; //The array for storing the // byte #1 value

int seq4[8] = {128,64,32,16,8,4,2,1};

int seq5[3] = {1,8,64,}; 

int seq6[3] = {1,8,64,}; 

int seq7[3] = {64,8,1,}; 


void setup()

{

pinMode(dataPin, OUTPUT); //Configure each IO Pin

pinMode(latchPin, OUTPUT);

pinMode(clockPin, OUTPUT);

}

void loop()

{

for (counter = 0; counter <10; counter++)

{

for (int x = 0; x < 14; x++) //Array Index

{

digitalWrite(latchPin, LOW); //Pull latch LOW to start sending data

shiftOut(dataPin, clockPin, MSBFIRST, seq1[x]); //Send the data byte 1

//shiftOut(dataPin, clockPin, MSBFIRST, seq2[x]); //Send the data byte 2

digitalWrite(latchPin, HIGH); //Pull latch HIGH to stop sending data

delay(65);

}

}


for (counter = 0; counter <10; counter++)

{

for (int x = 0; x < 14; x++) //Array Index

{

digitalWrite(latchPin, LOW); //Pull latch LOW to start sending data

shiftOut(dataPin, clockPin, MSBFIRST, seq1[x]); //Send the data byte 1

//shiftOut(dataPin, clockPin, MSBFIRST, seq2[x]); //Send the data byte 2

digitalWrite(latchPin, HIGH); //Pull latch HIGH to stop sending data

delay(50);


}

}

for (counter = 0; counter <10; counter++)

{

for (int x = 0; x < 14; x++) //Array Index

{

digitalWrite(latchPin, LOW); //Pull latch LOW to start sending data

shiftOut(dataPin, clockPin, MSBFIRST, seq1[x]); //Send the data byte 1

//shiftOut(dataPin, clockPin, MSBFIRST, seq2[x]); //Send the data byte 2

digitalWrite(latchPin, HIGH); //Pull latch HIGH to stop sending data

delay(35);


}

}

for (counter = 0; counter <10; counter++)

{

for (int x = 0; x < 8; x++) //Array Index

{

digitalWrite(latchPin, LOW); //Pull latch LOW to start sending data

shiftOut(dataPin, clockPin, MSBFIRST, seq3[x]); //Send the data byte 1

//shiftOut(dataPin, clockPin, MSBFIRST, seq4[x]); //Send the data byte 2

digitalWrite(latchPin, HIGH); //Pull latch HIGH to stop sending data

delay(35);


}

}

for (counter = 0; counter <10; counter++)

{

for (int x = 0; x < 8; x++) //Array Index

{

digitalWrite(latchPin, LOW); //Pull latch LOW to start sending data

shiftOut(dataPin, clockPin, MSBFIRST, seq3[x]); //Send the data byte 1

//shiftOut(dataPin, clockPin, MSBFIRST, seq4[x]); //Send the data byte 2

digitalWrite(latchPin, HIGH); //Pull latch HIGH to stop sending data

delay(65);


}

}

for (counter = 0; counter <10; counter++)

{

for (int x = 0; x < 8; x++) //Array Index

{

digitalWrite(latchPin, LOW); //Pull latch LOW to start sending data

shiftOut(dataPin, clockPin, MSBFIRST, seq3[x]); //Send the data byte 1

//shiftOut(dataPin, clockPin, MSBFIRST, seq4[x]); //Send the data byte 2

digitalWrite(latchPin, HIGH); //Pull latch HIGH to stop sending data

delay(85);

}

}


for (counter = 0; counter <6; counter++)

{

for (int x = 0; x < 8; x++) //Array Index

{

digitalWrite(latchPin, LOW); //Pull latch LOW to start sending data

shiftOut(dataPin, clockPin, MSBFIRST, seq3[x]); //Send the data byte 1

//shiftOut(dataPin, clockPin, MSBFIRST, seq4[x]); //Send the data byte 2

digitalWrite(latchPin, HIGH); //Pull latch HIGH to stop sending data

delay(100);

}

}

for (counter = 0; counter <6; counter++)

{

for (int x = 0; x < 8; x++) //Array Index

{

digitalWrite(latchPin, LOW); //Pull latch LOW to start sending data

shiftOut(dataPin, clockPin, MSBFIRST, seq4[x]); //Send the data byte 1

//shiftOut(dataPin, clockPin, MSBFIRST, seq4[x]); //Send the data byte 2

digitalWrite(latchPin, HIGH); //Pull latch HIGH to stop sending data

delay(100);


}

}

for (counter = 0; counter <10; counter++)

{

for (int x = 0; x < 8; x++) //Array Index

{

digitalWrite(latchPin, LOW); //Pull latch LOW to start sending data

shiftOut(dataPin, clockPin, MSBFIRST, seq4[x]); //Send the data byte 1

//shiftOut(dataPin, clockPin, MSBFIRST, seq4[x]); //Send the data byte 2

digitalWrite(latchPin, HIGH); //Pull latch HIGH to stop sending data

delay(85);


}

}

for (counter = 0; counter <10; counter++)

{

for (int x = 0; x < 8; x++) //Array Index

{

digitalWrite(latchPin, LOW); //Pull latch LOW to start sending data

shiftOut(dataPin, clockPin, MSBFIRST, seq4[x]); //Send the data byte 1

//shiftOut(dataPin, clockPin, MSBFIRST, seq4[x]); //Send the data byte 2

digitalWrite(latchPin, HIGH); //Pull latch HIGH to stop sending data

delay(65);


}

}

for (counter = 0; counter <10; counter++)

{

for (int x = 0; x < 8; x++) //Array Index

{

digitalWrite(latchPin, LOW); //Pull latch LOW to start sending data

shiftOut(dataPin, clockPin, MSBFIRST, seq4[x]); //Send the data byte 1

//shiftOut(dataPin, clockPin, MSBFIRST, seq4[x]); //Send the data byte 2

digitalWrite(latchPin, HIGH); //Pull latch HIGH to stop sending data

delay(35);


}

}

for (counter = 0; counter <10; counter++)

{

for (int x = 0; x < 14; x++) //Array Index

{

digitalWrite(latchPin, LOW); //Pull latch LOW to start sending data

shiftOut(dataPin, clockPin, MSBFIRST, seq1[x]); //Send the data byte 1

shiftOut(dataPin, clockPin, MSBFIRST, seq2[x]); //Send the data byte 2

digitalWrite(latchPin, HIGH); //Pull latch HIGH to stop sending data

delay(65);

}

}


for (counter = 0; counter <10; counter++)

{

for (int x = 0; x < 3; x++) //Array Index

{

digitalWrite(latchPin, LOW); //Pull latch LOW to start sending data

shiftOut(dataPin, clockPin, MSBFIRST, seq5[x]); //Send the data byte 1

//shiftOut(dataPin, clockPin, MSBFIRST, seq4[x]); //Send the data byte 2

digitalWrite(latchPin, HIGH); //Pull latch HIGH to stop sending data

delay(35);

}

}


for (counter = 0; counter <10; counter++)

{

for (int x = 0; x < 3; x++) //Array Index

{

digitalWrite(latchPin, LOW); //Pull latch LOW to start sending data

shiftOut(dataPin, clockPin, MSBFIRST, seq5[x]); //Send the data byte 1

//shiftOut(dataPin, clockPin, MSBFIRST, seq4[x]); //Send the data byte 2

digitalWrite(latchPin, HIGH); //Pull latch HIGH to stop sending data

delay(55);


}

}

for (counter = 0; counter <10; counter++)

{

for (int x = 0; x < 3; x++) //Array Index

{

digitalWrite(latchPin, LOW); //Pull latch LOW to start sending data

shiftOut(dataPin, clockPin, MSBFIRST, seq5[x]); //Send the data byte 1

//shiftOut(dataPin, clockPin, MSBFIRST, seq4[x]); //Send the data byte 2

digitalWrite(latchPin, HIGH); //Pull latch HIGH to stop sending data

delay(75);


}

}

for (counter = 0; counter <10; counter++)

{

for (int x = 0; x < 3; x++) //Array Index

{

digitalWrite(latchPin, LOW); //Pull latch LOW to start sending data

shiftOut(dataPin, clockPin, MSBFIRST, seq5[x]); //Send the data byte 1

//shiftOut(dataPin, clockPin, MSBFIRST, seq4[x]); //Send the data byte 2

digitalWrite(latchPin, HIGH); //Pull latch HIGH to stop sending data

delay(100);


}

}

for (counter = 0; counter <10; counter++)  //........................reverse

{

for (int x = 0; x < 3; x++) //Array Index

{

digitalWrite(latchPin, LOW); //Pull latch LOW to start sending data

shiftOut(dataPin, clockPin, MSBFIRST, seq7[x]); //Send the data byte 1

//shiftOut(dataPin, clockPin, MSBFIRST, seq4[x]); //Send the data byte 2

digitalWrite(latchPin, HIGH); //Pull latch HIGH to stop sending data

delay(100);


}

}

for (counter = 0; counter <10; counter++)

{

for (int x = 0; x < 8; x++) //Array Index

{

digitalWrite(latchPin, LOW); //Pull latch LOW to start sending data

shiftOut(dataPin, clockPin, MSBFIRST, seq6[x]); //Send the data byte 1

//shiftOut(dataPin, clockPin, MSBFIRST, seq4[x]); //Send the data byte 2

digitalWrite(latchPin, HIGH); //Pull latch HIGH to stop sending data

delay(100);


}

}

for (counter = 0; counter <10; counter++)

{

for (int x = 0; x < 8; x++) //Array Index

{

digitalWrite(latchPin, LOW); //Pull latch LOW to start sending data

shiftOut(dataPin, clockPin, MSBFIRST, seq6[x]); //Send the data byte 1

//shiftOut(dataPin, clockPin, MSBFIRST, seq4[x]); //Send the data byte 2

digitalWrite(latchPin, HIGH); //Pull latch HIGH to stop sending data

delay(35);


}

}

for (counter = 0; counter <10; counter++)

{

for (int x = 0; x < 8; x++) //Array Index

{

digitalWrite(latchPin, LOW); //Pull latch LOW to start sending data

shiftOut(dataPin, clockPin, MSBFIRST, seq6[x]); //Send the data byte 1

//shiftOut(dataPin, clockPin, MSBFIRST, seq4[x]); //Send the data byte 2

digitalWrite(latchPin, HIGH); //Pull latch HIGH to stop sending data

delay(55);


}

}

for (counter = 0; counter <10; counter++)

{

for (int x = 0; x < 8; x++) //Array Index

{

digitalWrite(latchPin, LOW); //Pull latch LOW to start sending data

shiftOut(dataPin, clockPin, MSBFIRST, seq6[x]); //Send the data byte 1

//shiftOut(dataPin, clockPin, MSBFIRST, seq4[x]); //Send the data byte 2

digitalWrite(latchPin, HIGH); //Pull latch HIGH to stop sending data

delay(75);


}

}

for (counter = 0; counter <5; counter++)

{

for (int x = 0; x < 8; x++) //Array Index

{

digitalWrite(latchPin, LOW); //Pull latch LOW to start sending data

shiftOut(dataPin, clockPin, MSBFIRST, seq6[x]); //Send the data byte 1

//shiftOut(dataPin, clockPin, MSBFIRST, seq4[x]); //Send the data byte 2

digitalWrite(latchPin, HIGH); //Pull latch HIGH to stop sending data

delay(100);


}

}

for (counter = 0; counter <5; counter++)

{

for (int x = 0; x < 8; x++) //Array Index

{

digitalWrite(latchPin, LOW); //Pull latch LOW to start sending data

shiftOut(dataPin, clockPin, MSBFIRST, seq6[x]); //Send the data byte 1

//shiftOut(dataPin, clockPin, MSBFIRST, seq4[x]); //Send the data byte 2

digitalWrite(latchPin, HIGH); //Pull latch HIGH to stop sending data

delay(130);


}

}

for (counter = 0; counter <50; counter++)

{

for (int x = 0; x < 8; x++) //Array Index

{

digitalWrite(latchPin, LOW); //Pull latch LOW to start sending data

shiftOut(dataPin, clockPin, MSBFIRST, seq1[x]); //Send the data byte 1

//shiftOut(dataPin, clockPin, MSBFIRST, seq4[x]); //Send the data byte 2

digitalWrite(latchPin, HIGH); //Pull latch HIGH to stop sending data

delay(5);


}

}

for (counter = 0; counter <50; counter++)

{

for (int x = 0; x < 8; x++) //Array Index

{

digitalWrite(latchPin, LOW); //Pull latch LOW to start sending data

shiftOut(dataPin, clockPin, MSBFIRST, seq3[x]); //Send the data byte 1

//shiftOut(dataPin, clockPin, MSBFIRST, seq4[x]); //Send the data byte 2

digitalWrite(latchPin, HIGH); //Pull latch HIGH to stop sending data

delay(15);


}

}

for (counter = 0; counter <50; counter++)

{

for (int x = 0; x < 8; x++) //Array Index

{

digitalWrite(latchPin, LOW); //Pull latch LOW to start sending data

shiftOut(dataPin, clockPin, MSBFIRST, seq3[x]); //Send the data byte 1

//shiftOut(dataPin, clockPin, MSBFIRST, seq4[x]); //Send the data byte 2

digitalWrite(latchPin, HIGH); //Pull latch HIGH to stop sending data

delay(20);


}

}

}

Copyright © 2025 Led Labs - All Rights Reserved.