#define C_MOTOR 1 . volatile char cmd = 0; volatile char command = 0; volatile unsigned char command1 = ' '; volatile unsigned char command2 = ' '; . ISR(USART_RXC_vect) { cmd++; unsigned char rec = uartReceive(); . if (cmd == 1) { command1 = rec; } else if (cmd == 2) { command2 = rec; } else if (rec == '\n') { command = 0; . // LEFT MOTOR or other command switch (command1) { case 'F': leftSpeed(255); command = C_MOTOR; break; case 'S': leftSpeed(0); command = C_MOTOR; break; case 'B': leftSpeed(-255); command = C_MOTOR; break; } . // RIGHT MOTOR if (command == C_MOTOR) { switch (command2) { case 'F': rightSpeed(255); break; case 'S': rightSpeed(0); break; case 'B': rightSpeed(-255); break; } } } } redOn(); while (!readButton()); redOff(); int speed = 200; . while (1) { if (BLACK(LINE3)) { leftSpeed(speed); rightSpeed(speed); } else if (BLACK(LINE5)) { leftSpeed(speed); rightSpeed(-speed); } else if (BLACK(LINE1)) { leftSpeed(-speed); rightSpeed(speed); } else if (BLACK(LINE4)) { leftSpeed(speed); rightSpeed(0); } else if (BLACK(LINE2)) { leftSpeed(0); rightSpeed(speed); } else { leftSpeed(speed); rightSpeed(speed); } } // Uložení příznaku do EEPROM eeprom_write_byte((unsigned char*)0x00, 0x01); wdt_enable(WDTO_30MS); // Watchdog reset while (1); // Nekonečná smyčka