Here's what I have so far. Although I can't figure out how to do a few light patterns. One being LEDs lighting up at random and the other looking like this..
00000000
10000001
01000010
00100100
00011000
10011001
01011010
00111100
10111101
01111110
11111111
I'd also like to figure out how to make it select at random a pattern to display rather than repeating the same order that they're in, in the script. This is part of a larger project that'll have several of these, but once I can figure out the code for one I can just add on to that.
// Set Pins
int latchPin = 8;
int clockPin = 12;
int dataPin = 11;
// create variables
int ispeed;
int output;
boolean up;
void setup() {
// initialise pin states
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
}
void loop() {
// initialise variable states
up = true;
output = 1;
ispeed = 40;
// scanner style led scrolling
for (int j = 0; j < 253; j++){
// count from 0 to 255 and display the number
// on the LEDs
// take the latchPin low so
// the LEDs don't change while you're sending in bits:
digitalWrite(latchPin, LOW);
// shift out the bits:
shiftOut(dataPin, clockPin, MSBFIRST, output);
//take the latch pin high so the LEDs will light up:
digitalWrite(latchPin, HIGH);
// pause before next value:
if (up){output = output << 1;}
else {output = output >> 1;}
if ((output == 0b10000000) || (output == 0b00000001)){up = !up;}
delay(ispeed);
}
// refresh rate example
for (int j = 0; j < 200; j++){
// count from 0 to 255 and display the number
// on the LEDs
output = 1;
for (int i = 0; i < 8; i++) {
// take the latchPin low so
// the LEDs don't change while you're sending in bits:
digitalWrite(latchPin, LOW);
// shift out the bits:
shiftOut(dataPin, clockPin, MSBFIRST, output);
//take the latch pin high so the LEDs will light up:
digitalWrite(latchPin, HIGH);
// pause before next value:
output = output << 1;
delay(ispeed);
}
if(ispeed > 1){ispeed = ispeed-1;}
}
// binary counter
ispeed = 50;
for (output = 0; output < 256; output++){
// take the latchPin low so
// the LEDs don't change while you're sending in bits:
digitalWrite(latchPin, LOW);
// shift out the bits:
shiftOut(dataPin, clockPin, MSBFIRST, output);
//take the latch pin high so the LEDs will light up:
digitalWrite(latchPin, HIGH);
// pause before next value:
delay(ispeed);
}
}
EDIT
Also I have an issue with one of the patterns I already have. (i'll list the code after) Basically the LEDs blink increasingly faster until it's just "on". Problem is that all of the LEDs stay on for a good second and that kinda kills the flow of the other patterns. Any way I can stop it at a certain feq. or something like that?
// refresh rate example
for (int j = 0; j < 200; j++){
// count from 0 to 255 and display the number
// on the LEDs
output = 1;
for (int i = 0; i < 8; i++) {
// take the latchPin low so
// the LEDs don't change while you're sending in bits:
digitalWrite(latchPin, LOW);
// shift out the bits:
shiftOut(dataPin, clockPin, MSBFIRST, output);
//take the latch pin high so the LEDs will light up:
digitalWrite(latchPin, HIGH);
// pause before next value:
output = output << 1;
delay(ispeed);
}
if(ispeed > 1){ispeed = ispeed-1;}
}