summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--_3x3Matrix.pde60
2 files changed, 62 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..5ca0973
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+.DS_Store
+
diff --git a/_3x3Matrix.pde b/_3x3Matrix.pde
new file mode 100644
index 0000000..6a2a147
--- /dev/null
+++ b/_3x3Matrix.pde
@@ -0,0 +1,60 @@
+/*
+ Blink
+ Turns on an LED on for one second, then off for one second, repeatedly.
+
+ This example code is in the public domain.
+ */
+#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.
+ // Pin 13 has an LED connected on most Arduino boards:
+ 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);
+}