summaryrefslogtreecommitdiffstats
path: root/Matrix-3x3
diff options
context:
space:
mode:
authorAlexander Kauerz <kauerz@informatik.uni-luebeck.de>2011-11-03 23:56:11 +0100
committerAlexander Kauerz <kauerz@informatik.uni-luebeck.de>2011-11-03 23:56:11 +0100
commitbac1743da50411c6bacdeebdd6a6347bdd59f34e (patch)
tree599b0c4a03f0b3f6012aae8559797b94a1e014f7 /Matrix-3x3
parentf59e8c3198e883cc2608ca560d6d58fb202a087b (diff)
downloadledmatrix-bac1743da50411c6bacdeebdd6a6347bdd59f34e.tar
ledmatrix-bac1743da50411c6bacdeebdd6a6347bdd59f34e.zip
Ordnerstruktur angepasst.
Diffstat (limited to 'Matrix-3x3')
-rw-r--r--Matrix-3x3/Matrix-3x3.pde57
1 files changed, 57 insertions, 0 deletions
diff --git a/Matrix-3x3/Matrix-3x3.pde b/Matrix-3x3/Matrix-3x3.pde
new file mode 100644
index 0000000..eea52e5
--- /dev/null
+++ b/Matrix-3x3/Matrix-3x3.pde
@@ -0,0 +1,57 @@
+/*
+ Blink
+
+ */
+#define ROW 3
+#define COL 0
+#define ROWCNT 3
+#define COLCNT 3
+
+#define DELAY 3
+
+int frame[3][3] = {
+ {0, 0, 0},
+ {0, 0, 0},
+ {0, 0, 0},
+};
+
+int framenr = 0;
+int rownr = 0;
+void setup() {
+ // initialize the digital pin as an output.
+ int i;
+ for (i = 0;i < ROWCNT; i++)
+ pinMode(ROW + i, OUTPUT);
+ for (i = 0;i < COLCNT; i++)
+ pinMode(COL + i, OUTPUT);
+}
+
+void nextFrame() {
+ frame[0][0] = (framenr % 100) < 50;
+ frame[0][1] = (framenr % 100) < 50;
+ frame[0][2] = (framenr % 100) < 50;
+ frame[1][0] = (framenr % 100) < 50;
+ frame[1][1] = (framenr % 100) >= 50;
+ frame[1][2] = (framenr % 100) < 50;
+ frame[2][0] = (framenr % 100) < 50;
+ frame[2][1] = (framenr % 100) < 50;
+ frame[2][2] = (framenr % 100) < 50;
+}
+
+void loop() {
+ int i;
+
+ rownr = ( rownr + 1 ) % ROWCNT;
+
+ if (rownr == 0) {
+ framenr++;
+ nextFrame();
+ }
+
+ for (i = 0; i < COLCNT; i++) {
+ digitalWrite(COL + i, frame[rownr][i]);
+ }
+ digitalWrite(ROW + rownr, HIGH);
+ delay(DELAY);
+ digitalWrite(ROW + rownr, LOW);
+}