synth/uart/ledctrl.c
2021-03-13 15:49:28 -08:00

27 lines
346 B
C

#include "led.h"
#include "uart.h"
#define uart0 ((struct uart*)0xc010)
int main() {
int c;
int led = 0;
while (1) {
led_write(1 << led);
c = uart_read(uart0);
if (c == 'a') {
led++;
} else if (c == 'd') {
led--;
}
if (led == 8) {
led = 0;
} else if (led < 0) {
led = 7;
}
}
}