Program
for LED blinking:
/*
connect PORT0 P0.16 – P0.15 to LEDs*/
#include<LPC213X.H>
void delay(int);
main()
{
PINSEL0=0X00000000; // port0 is configured as GPIOs
IODIR0=0X0000F000; // P0.12 to P0.16 acts as output
while(1)
{
IOSET0=0X0000F000; //
Port0 P0.12 to P0.15 Enabled/high(On)
delay(10);
IOCLR0=0X0000F000; //Port0
P0.12 to P0.15 Disable/low (Off)
delay(10);
}
}
void delay(int i)// For delay
{
int j,k;
for(j=0;j<i;j++)
for(k=0;k<100;k++);
}
Proteus connection diagram for LED blinking:
Connect PORT0 P0.12
P0.13 P0.14 P0.15 to LEDs and the other end to Ground.
/* Don’t forget to connect VBAT 3v*/
0 comments:
Post a Comment