testpattern

This commit is contained in:
robelix 2018-01-14 21:28:36 +01:00
parent 9dceb4a7f8
commit ef8db2deba

View file

@ -29,9 +29,9 @@ MIC = Input from microphone amplifier (LM358)
*/ */
#define LATCHPIN 6 #define LATCHPIN 5
#define DATAPIN 4 #define DATAPIN 4
#define CLOCKPIN 5 #define CLOCKPIN 6
byte ledsData[8]; byte ledsData[8];
byte currentled = 0; byte currentled = 0;
@ -56,10 +56,12 @@ void writexy(byte x, byte y) {
writebuffer(lednr); writebuffer(lednr);
} }
byte rowmask[8] = {5,3,1,0,2,4,6,7};
void pushout() { void pushout() {
digitalWrite(LATCHPIN, LOW); digitalWrite(LATCHPIN, LOW);
for(int i = 8-1; i>=0; i--) { for(int i = 8-1; i>=0; i--) {
shiftOut(DATAPIN, CLOCKPIN, MSBFIRST, ledsData[i]); byte row = rowmask[i];
shiftOut(DATAPIN, CLOCKPIN, MSBFIRST, ledsData[row]);
} }
digitalWrite(LATCHPIN, HIGH); digitalWrite(LATCHPIN, HIGH);
} }
@ -71,18 +73,38 @@ void setup() {
clear(); clear();
pushout(); pushout();
} }
byte currentcol=1;
bool direction = true;
void loop() { void loop() {
clear(); clear();
writebuffer(currentled);
// x-line
for(byte i=0; i<8; i++) {
writexy(i,currentcol-1);
}
// y line
for(byte i=0; i<8; i++) {
writexy(currentcol-1,i);
}
pushout(); pushout();
currentled++; if(direction) {
if (currentled >=64) { currentcol++;
currentled = 0; } else {
currentcol--;
}
if (currentcol >8) {
currentcol = 7;
direction = false;
}
if (currentcol <=0) {
currentcol=2;
direction = true;
} }
delay(100); delay(100);
} }