About
Binary
include <lpc214x.h>
define LED1_ON() IO1SET = (1 << 16)
define LED2_ON() IO1SET = (1 << 17)
define LED3_ON() IO1SET = (1 << 18)
define LED4_ON() IO1SET = (1 << 19)
define LED1_OFF() IO1CLR = (1 << 16)
define LED2_OFF() IO1CLR = (1 << 17)
define LED3_OFF() IO1CLR = (1 << 18)
define LED4_OFF() IO1CLR = (1 << 19)
define BUZZER_ON() IO0CLR = (1 << 11)
define BUZZER_OFF() IO0SET = (1 << 11)
void Delay(unsigned char j) { unsigned int i; for (; j > 0; j--) { for (i = 0; i < 60000; i++); } } void binary_led() { int i, temp, rem, count = 0; for (i = 0; i < 16; i++) { temp = i; count = 0; while (temp > 0) { rem = temp % 2; temp = temp / 2; count = count + 1; if (rem == 1) { if (count == 1) LED4_ON(); if (count == 2) LED3_ON(); if (count == 3) LED2_ON(); if (count == 4) LED1_ON(); } else { if (count == 1) LED4_OFF(); if (count == 2) LED3_OFF(); if (count == 3) LED2_OFF(); if (count == 4) LED1_OFF(); } } Delay(250); BUZZER_ON(); Delay(10); BUZZER_OFF(); } }
int main(void) { PINSEL0 = 0x00000000; PINSEL1 = 0x00000000; PINSEL2 = 0x00000000;
IO1DIR = (1 << 19) | (1 << 18) | (1 << 17) | (1 << 16);
IO0DIR = (1 << 11);
binary_led();
return (0);
}
Buzzer
include <lpc214x.h>
define BUZZER_ON() IO0CLR = (1 << 11)
define BUZZER_OFF() IO0SET = (1 << 11)
void Delay(unsigned char j) { unsigned int i; for (; j > 0; j--) { for (i = 0; i < 60000; i++); } }
int main(void) { PINSEL0 = 0x00000000;
IO0DIR = (1 << 11);
while (1)
{
BUZZER_ON();
Delay(10);
BUZZER_OFF();
Delay(10);
}
}
LedChase
include <lpc214x.h>
define LED1_ON() IO1SET = (1 << 16)
define LED2_ON() IO1SET = (1 << 17)
define LED3_ON() IO1SET = (1 << 18)
define LED4_ON() IO1SET = (1 << 19)
define LED1_OFF() IO1CLR = (1 << 16)
define LED2_OFF() IO1CLR = (1 << 17)
define LED3_OFF() IO1CLR = (1 << 18)
define LED4_OFF() IO1CLR = (1 << 19)
void Delay(unsigned char j) { unsigned int i; for (; j > 0; j--) { for (i = 0; i < 60000; i++); } }
int main(void) { PINSEL0 = 0x00000000; PINSEL1 = 0x00000000; PINSEL2 = 0x00000000;
IO1DIR = (1 << 19) | (1 << 18) | (1 << 17) | (1 << 16);
while (1) { LED1_ON(); Delay(25); LED1_OFF(); LED2_ON(); Delay(25); LED2_OFF(); LED3_ON(); Delay(25); LED3_OFF(); LED4_ON(); Delay(25); LED4_OFF(); } return (0); }
Passwd
include <lpc214x.h>
define BUZZER_ON() IO0CLR = (1 << 11)
define BUZZER_OFF() IO0SET = (1 << 11)
define LED1_ON() IO1SET = (1 << 16)
define LED2_ON() IO1SET = (1 << 17)
define LED3_ON() IO1SET = (1 << 18)
define LED4_ON() IO1SET = (1 << 19)
void Delay(unsigned char j) { unsigned int i; for (; j > 0; j--) { for (i = 0; i < 60000; i++) ; } } void allLED_ON() { LED1_ON(); LED2_ON(); LED3_ON(); LED4_ON(); } int pd = 1234;
int main(void) { PINSEL0 = 0x00000000; PINSEL1 = 0x00000000; PINSEL2 = 0x00000000;
IO1DIR = (1 << 19) | (1 << 18) | (1 << 17) | (1 << 16); IO0DIR = (1 << 11);
if (pd == 123) { LED1_ON(); BUZZER_OFF(); } else { allLED_ON(); BUZZER_ON(); } }
Switch
include <lpc214x.h>
define LED1_ON() IO1SET=(1<<16)
define LED2_ON() IO1SET=(1<<17)
define LED3_ON() IO1SET=(1<<18)
define LED4_ON() IO1SET=(1<<19)
define LED1_OFF() IO1CLR=(1<<16)
define LED2_OFF() IO1CLR=(1<<17)
define LED3_OFF() IO1CLR=(1<<18)
define LED4_OFF() IO1CLR=(1<<19)
define SW1 (IO0PIN & 0x00008000)
define SW2 (IO0PIN & 0x00002000)
define SW3 (IO0PIN & 0x00001000)
define SW4 (IO0PIN & 0x40000000)
int main(void)
{
PINSEL0 = 0x00000000;
PINSEL1 = 0x00000000;
PINSEL2 = 0x00000000;
IO0DIR = (0<<12) | (0<<13) | (0<<15) | (0<<30); IO1DIR = (1<<19) | (1<<18) | (1<<17) | (1<<16);
while(1)
{
if(!SW1) {LED1_ON();}
else {LED1_OFF();}
if(!SW2) {LED2_ON();}
else {LED2_OFF();}
if(!SW3) {LED3_ON();}
else {LED3_OFF();}
if(!SW4) {LED4_ON();}
else {LED4_OFF();}
} }
Traffic
include <lpc214x.h>
define BUZZER_ON() IO0CLR = (1 << 11)
define BUZZER_OFF() IO0SET = (1 << 11)
define LED1_ON() IO1SET = (1 << 16)
define LED2_ON() IO1SET = (1 << 17)
define LED3_ON() IO1SET = (1 << 18)
define LED4_ON() IO1SET = (1 << 19)
void Delay(unsigned char j) { unsigned int i; for (; j > 0; j--) { for (i = 0; i < 60000; i++) ; } } void AllED_ON() { LED1_ON(); LED2_ON(); LED3_ON(); LED4_ON(); }
int i = 0; int j = 0; int main(void) { PINSEL0 = 0x00000000; PINSEL1 = 0x00000000; PINSEL2 = 0x00000000;
IO1DIR = (1 << 19) | (1 << 18) | (1 << 17) | (1 << 16);
IO0DIR = (1 << 11);
for (i = 0; i < 3; i++)
{
IO1SET = (1 << 16 + i);
for (j = 0; j < i + 1; j++)
{
BUZZER_ON();
Delay(50);
BUZZER_OFF();
Delay(50);
}
IO1CLR = (1 << 16 + i);
BUZZER_OFF();
Delay(200);
}
}