From ef8db2debaef8a15c1a121e476b705eec2c80274 Mon Sep 17 00:00:00 2001 From: robelix Date: Sun, 14 Jan 2018 21:28:36 +0100 Subject: [PATCH] testpattern --- src/main.cpp | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 3e9d52a..dfd6804 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -29,9 +29,9 @@ MIC = Input from microphone amplifier (LM358) */ -#define LATCHPIN 6 +#define LATCHPIN 5 #define DATAPIN 4 -#define CLOCKPIN 5 +#define CLOCKPIN 6 byte ledsData[8]; byte currentled = 0; @@ -56,10 +56,12 @@ void writexy(byte x, byte y) { writebuffer(lednr); } +byte rowmask[8] = {5,3,1,0,2,4,6,7}; void pushout() { digitalWrite(LATCHPIN, LOW); 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); } @@ -71,18 +73,38 @@ void setup() { clear(); pushout(); - } + +byte currentcol=1; +bool direction = true; + void loop() { 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(); - currentled++; - if (currentled >=64) { - currentled = 0; + if(direction) { + currentcol++; + } else { + currentcol--; + } + if (currentcol >8) { + currentcol = 7; + direction = false; + } + if (currentcol <=0) { + currentcol=2; + direction = true; } delay(100); }