LED GLOBE

here is the new code:

#include <avr/pgmspace.h>
#include <SPI.h>
//Pin connected to ST_CP of 74HC595
int latchPin = 10;
int i= 0;
int indexCount;
byte val;

PROGMEM prog_uchar array[] = {0x6D, 0xDB, 0xB6 };  


void setup(){
  Serial.begin(9600);
  pinMode(latchPin, OUTPUT);
  digitalWrite(latchPin, HIGH);
  SPI.begin();
}
void loop()
{
for(int i=0; i<3; i++)
{
val = pgm_read_byte_near(array + i);
PORTB=PORTB&0B11111011;
  SPI.transfer(val);
  PORTB=PORTB|0B00000100;
  delay(1000);
}
}



 PROGMEM prog_uchar array[]=  {0x6D, 0xDB, 0xB6, 0x6D, 0x6D,
                              0xD6, 0x6D, 0xDB, 0xB6, 0xB6,
                              0xDB, 0xB6, 0x6D, 0xDB, 0xDB
                              };

ok so now that we have 1 shift register and 3 LEDs working, we will be moving on to 5 shift registers.

so one question: how do we use a pointer to shift through and shift out each row of the last array that you see in the code? Is there a specific method or are we implementing this correctly?

I showed how to use a pointer (countIndex) in the code I posted. You have the count - 0, 1,2,3,4 multplied by how much data you send out - in your most recent, 5. So the value read out is from 0*5 +0, 0*5 +1, 0*5 +2, 0*5 +3, 0*5 +4, then index goes up by 1: 1*5 +0, 1*5 +1, 1*5 +2, 1*5 +3, 1*5 +4, then index goes up by 1: 2*5 +0, 2*5 +1, 2*5 +2, 2*5 +3, 2*5 +4, then index goes up by 1: See how that is working?

Thank you for your help CrossRoads. You have been great with the code and advice.

We finished up the LED portion of the code but I still I have some questions about how to use this the blink without delay style timing. As far as my knowledge goes, CurrentTime holds how many microseconds have passed since the program started. After seeing that, there are 3 other different time-related variables that we declared that are being used. Can you explain and expand on these?

here is the code so you don’t have to scroll for it:

void loop(){
currentTime = micros();
elapsedTime = currentTime - nextTime;
if (elapsedTime >= duration){
nextTime = nextTime + duration;
indexCount = indexCount +1;
if (indexCount == 89){indexCount = 0;}
digitalWrite(csPin, LOW);
SPI.transfer(dataArray[(indexCount * 34) +0]); // so 0,1,2,3 ... up to  31,32,33
SPI.transfer(dataArray[(indexCount * 34) +1]); // then 34,35,36, ... up to  65,66,67 
SPI.transfer(dataArray[(indexCount * 34) +2]); // then 68,69,70 ... up to 97,98,99 
SPI.transfer(dataArray[(indexCount * 34) +3]);
:
:
SPI.transfer(dataArray[(indexCount * 34) +32]);
SPI.transfer(dataArray[(indexCount * 34) +33]);
digitalWrite(csPin, HIGH);
} // end time check
} // end loop

currentTime = micros(); // capture the current ‘time’ - micros() is a free running, ever increasing #
elapsedTime = currentTime - nextTime; // calculate how much time has passed since prior update
if (elapsedTime >= duration){ // enough time passed? Now do something
nextTime = nextTime + duration; // set up the time for the next occurrence to happen

Mr. modulator thank you so much for sharing you precious knowledge. this could not had never be possible with out your help. :slight_smile: