About
include<lpc214x.h>
define LED1_ON() IO1SET = (1<<16);
define LED1_OFF() IO1CLR = (1<<16);
define LED2_ON() IO1SET = (1<<17);
define LED2_OFF() IO1CLR = (1<<17);
define LED3_ON() IO1SET = (1<<18);
define LED3_OFF() IO1CLR = (1<<18);
define LED4_ON() IO1SET = (1<<19);
define LED4_OFF() IO1CLR = (1<<19);
define BUZZER_ON() IO0CLR = (1<<11);
define BUZZER_OFF() IO0SET = (1<<11);
void delay(unsigned char n){ unsigned int i; for(;n>0;n--){ for(i=0;i<60000;i++); } }
void gap(){ LED1_OFF(); LED2_OFF(); LED3_OFF(); LED4_OFF(); BUZZER_OFF(); delay(500); }
void validate(int a, int b){ if(a==b){ LED1_OFF(); LED2_OFF(); LED3_OFF(); LED4_OFF(); LED1_ON(); BUZZER_OFF(); } else{ LED1_ON(); LED2_ON(); LED3_ON(); LED4_ON(); BUZZER_ON(); } }
int main(void){ int a,b; PINSEL0 = 0x00000000; PINSEL1 = 0x00000000; PINSEL2 = 0x00000000; IO1DIR = (1<<16) | (1<<17) | (1<<18) | (1<<19); IO0DIR = (1<<11); while(1){ a = 0; b = 0; validate(a,b); delay(250); gap(); a = 0; b = 1; validate(a,b); delay(250); gap(); a = 1; b = 0; validate(a,b); delay(250); gap(); a = 1; b = 1; validate(a,b); delay(250); gap(); } }
enter code here