This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en:iot:examples:matrix [2020/03/23 12:33] – heikopikner | en:iot:examples:matrix [Unknown date] (current) – external edit (Unknown date) 127.0.0.1 | ||
|---|---|---|---|
| Line 4: | Line 4: | ||
| Needed libraries: | Needed libraries: | ||
| - | < | + | < |
| For learning how to use the IoT Matrix you can try out the example and tasks. | For learning how to use the IoT Matrix you can try out the example and tasks. | ||
| Line 13: | Line 13: | ||
| // Librarys that the IoT Matrix uses | // Librarys that the IoT Matrix uses | ||
| #include < | #include < | ||
| - | #include < | ||
| #include < | #include < | ||
| #include < | #include < | ||
| #include < | #include < | ||
| + | #include < | ||
| MLED matrix(7); //set intensity=7 (maximum) | MLED matrix(7); //set intensity=7 (maximum) | ||
| Line 23: | Line 23: | ||
| Serial.begin(9600); | Serial.begin(9600); | ||
| Serial.println(" | Serial.println(" | ||
| - | |||
| - | iot.printConfig(); | ||
| - | iot.setup(); | ||
| - | |||
| - | |||
| } | } | ||
| void loop() { | void loop() { | ||
| - | |||
| - | iot.handle(); | ||
| - | |||
| matrix.clear(); | matrix.clear(); | ||
| matrix.drawRect(0, | matrix.drawRect(0, | ||
| Line 49: | Line 41: | ||
| {{: | {{: | ||
| - | Tic-Tac-Toe | + | Trips-traps-trull |
| <code c> | <code c> | ||
| #include < | #include < | ||
| - | #include < | ||
| #include < | #include < | ||
| #include < | #include < | ||
| #include < | #include < | ||
| + | #include < | ||
| MLED matrix(7); | MLED matrix(7); | ||
| Line 63: | Line 55: | ||
| Serial.begin(9600); | Serial.begin(9600); | ||
| Serial.println(" | Serial.println(" | ||
| - | |||
| - | iot.printConfig(); | ||
| - | iot.setup(); | ||
| } | } | ||
| void loop() { | void loop() { | ||
| - | iot.handle(); | ||
| matrix.clear(); | matrix.clear(); | ||
| for (int i = 0; i <= 7; i++) { | for (int i = 0; i <= 7; i++) { | ||
| Line 97: | Line 85: | ||
| {{: | {{: | ||
| - | Make everything covered one by one in a circular way | + | Ringiratast ekraani täitmine |
| <code c> | <code c> | ||
| #include < | #include < | ||
| - | #include < | ||
| #include < | #include < | ||
| #include < | #include < | ||
| #include < | #include < | ||
| + | #include < | ||
| MLED matrix(7); | MLED matrix(7); | ||
| Line 111: | Line 99: | ||
| Serial.begin(9600); | Serial.begin(9600); | ||
| Serial.println(" | Serial.println(" | ||
| - | |||
| - | iot.printConfig(); | ||
| - | iot.setup(); | ||
| } | } | ||
| - | int drawRight(int a, int b, int c) { | + | void drawRight(int a, int b, int c) { |
| for (int i = c; i <= a+c; i++) { | for (int i = c; i <= a+c; i++) { | ||
| matrix.drawRect(i, | matrix.drawRect(i, | ||
| Line 124: | Line 109: | ||
| } | } | ||
| - | int drawDown(int a, int b) { | + | void drawDown(int a, int b) { |
| for (int i = b; i <= a; i++) { | for (int i = b; i <= a; i++) { | ||
| matrix.drawRect(a, | matrix.drawRect(a, | ||
| Line 132: | Line 117: | ||
| } | } | ||
| - | int drawLeft(int a, int b) { | + | void drawLeft(int a, int b) { |
| int e = 0; | int e = 0; | ||
| for (int i = 0; i <= a; i++) { | for (int i = 0; i <= a; i++) { | ||
| Line 142: | Line 127: | ||
| } | } | ||
| - | int drawUp(int a, int b, int c) { | + | void drawUp(int a, int b, int c) { |
| for (int i = 0; i <= a; i++) { | for (int i = 0; i <= a; i++) { | ||
| matrix.drawRect(c, | matrix.drawRect(c, | ||
| Line 151: | Line 136: | ||
| void loop() { | void loop() { | ||
| - | iot.handle(); | ||
| matrix.clear(); | matrix.clear(); | ||
| drawRight(7, | drawRight(7, | ||