Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void (*spustProgram[])(int) = {
- bila,
- cervena,
- modra,
- zelena,
- zluta
- };
- int poleProgramu[22][3] = {
- { 4, 4, 4 },
- { 4, 3, 1 },
- { 2, 3, 4 },
- { 3, 2, 3 },
- { 2, 1, 4 },
- { 1, 1, 4 },
- { 2, 2, 2 },
- { 3, 3, 3 },
- { 1, 1, 1 },
- { 2, 2, 1 },
- { 2, 2, 3 },
- { 2, 3, 2 },
- { 3, 1, 4 },
- { 1, 4, 3 },
- { 3, 1, 2 },
- { 2, 4, 1 },
- { 1, 2, 4 },
- { 2, 1, 3 },
- { 1, 2, 0 },
- { 0, 4, 2 },
- { 2, 3, 0 },
- { 2, 2, 0 }
- };
- int programF2(int program, int poc)
- {
- if (poc < (pocetLED + 1)) {
- // pokud je pocet kroku mensi nez diody budeme vse rozinat
- if (poc > -1 and poc < 80) {
- (*spustProgram[poleProgramu[program][0]])(poc);
- } else if (poc > 79 and poc < 115) {
- (*spustProgram[poleProgramu[program][1]])(poc);
- } else {
- (*spustProgram[poleProgramu[program][2]])(poc);
- }
- } else if (poc > (pocetLED * 2) and poc < ((pocetLED + 1) * 3)) {
- // pokud je pocet vetsi a zaroven mensi nez 2x pocet pak budeme zhasinat
- zhasni(poc - (pocetLED * 2) - 1);
- } else if (poc > (pocetLED * 3 + 1)) {
- zmena = 1;
- }
- return zmena;
- }
- void loop() {
- Serial.print("Krok: ");
- Serial.print(poc);
- Serial.print(" program: ");
- Serial.print(program);
- //zmena = programF(program, poc);
- zmena = programF2(program, poc);
- Serial.print(" zmena: ");
- Serial.println(zmena);
- if (zmena == 1) {
- zmena = 0;
- poc = -1;
- if (program > 25) {
- program = 1;
- } else {
- program++;
- }
- }
- poc++;
- delay(50);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement