#include "mbed.h" #include "TextLCD.h" BusIn input (p5,p6,p7,p9); BusOut outputs(LED1,LED2,LED3,LED4); TextLCD lcd(p28,p27,p26,p25,p24,p23); DigitalIn a(p5),b(p6),c(p7),d(p9); int i; int Output; char ST=1; int main() { a.mode(PullUp); b.mode(PullUp); c.mode(PullUp); d.mode(PullUp); while (1) { i=input; switch(ST) { case 0: Output=0x01; lcd.printf("state 0\n"); if(((i&0x01)==0x00)||((i&0x06)==0x02)) ST=1; else if((i&0x03)==0x01) ST=3; break; case 1: Output=0x03; lcd.printf("state 1\n"); if((i&0x07)==0x01) ST=2; break; case 2: Output=0x07; lcd.printf("state 2\n"); if((i&0x03)==0x00) ST=5; break; case 3: Output=0x0c; lcd.printf("state 3\n"); if((i&0x07)==0x03) ST=4; break; case 4: lcd.printf("state 4\n"); if((i&0x03)==0x01) ST=5; else if((i&0x01)==0x00) ST=1; break; case 5: Output=0x0f; lcd.printf("state 5\n"); if((i&0x0f)==0x07) ST=0; break; } outputs = Output; } }