#include "mbed.h" Ticker tick; DigitalOut row[] = {PTB18, PTB19, PTC0, PTC4, PTC6, PTC7, PTC10, PTC11}; // 1 = zap DigitalOut red[] = {PTC9, PTC8, PTA5, PTA4, PTA12, PTD3, PTA2, PTA1}; // 0 = zap DigitalOut green[] = {PTC13, PTC16, PTA7, PTA6, PTA14, PTA15, PTA16, PTA17}; // 0 = zap DigitalOut blue[] = {PTA13, PTD2, PTD4, PTD6, PTD7, PTB9, PTE0, PTE1}; // 0 = zap int redpic[8][8] = {{0,0,0,0,1,1,1,1}, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, {1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1}}; int greenpic[8][8] = {{0,0,1,1,0,0,1,1}, {0,0,0,0,0,0,0,0}, {1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1}, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, {1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1}}; int bluepic[8][8] = {{0,1,0,1,0,1,0,1}, {1,1,1,1,1,1,1,1}, {0,0,0,0,0,0,0,0}, {1,1,1,1,1,1,1,1}, {0,0,0,0,0,0,0,0}, {1,1,1,1,1,1,1,1}, {0,0,0,0,0,0,0,0}, {1,1,1,1,1,1,1,1}}; float wtime = 0.1; // cas mezi barvama (ms) void clean() { for(int i=0; i<8; i++) { row[i] = 0; } } int rndcolor() { int num = rand() % 100; if(num > 50) return 1; else return 0; } void randomizer() { for(int i=0; i<8; i++) { for(int j=0; j<8; j++) { redpic[i][j] = rndcolor(); greenpic[i][j] = rndcolor(); bluepic[i][j] = rndcolor(); } } } int main() { randomizer(); tick.attach(&randomizer, 0.15); while (true) { for(int i=0; i<8; i++) { clean(); row[i] = 1; // set red for(int j=0; j<8; j++) { red[j] = redpic[i][j]; //red[j] = rndcolor(); } wait_ms(wtime); // clean red for(int j=0; j<8; j++) { red[j] = 1; } // set green for(int j=0; j<8; j++) { green[j] = greenpic[i][j]; //green[j] = rndcolor(); } wait_ms(wtime); // clean green for(int j=0; j<8; j++) { green[j] = 1; } // set blue for(int j=0; j<8; j++) { blue[j] = bluepic[i][j]; //blue[j] = rndcolor(); } wait_ms(wtime); // clean blue for(int j=0; j<8; j++) { blue[j] = 1; } } } }