Program : For infinite alternate blinking of led.
/*---------program by Shreya Rajput-----*/
#include <LPC214X.H>
void delay(int x);
int main()
{
IO0DIR = 0XFFFFFFFF; //setting all the pins as output
while(1) //infinite loop
{
IO0SET |=(1<<3); //setting pin P0.3 high
delay(5000);
IO0CLR |=(1<<3); //setting pin P0.3 low
delay(5000);
}
return 0;
}
void delay(int x) //delay function
{
unsigned k,c;
for(k=x;k>0;k--) //in arm with for you cannot leave statement empty
{
for(c=0;c<x;c++);
}
}
This is a simple led blinking program for single pin.Similarly, use can use for more than one pin.
See, delay is must. As speed of processors are so fast that you won't be able notice the blinking
NOTE: For infite loop ,you can also use for(;;) instead of while(1)
/*---------program by Shreya Rajput-----*/
#include <LPC214X.H>
void delay(int x);
int main()
{
IO0DIR = 0XFFFFFFFF; //setting all the pins as output
while(1) //infinite loop
{
IO0SET |=(1<<3); //setting pin P0.3 high
delay(5000);
IO0CLR |=(1<<3); //setting pin P0.3 low
delay(5000);
}
return 0;
}
void delay(int x) //delay function
{
unsigned k,c;
for(k=x;k>0;k--) //in arm with for you cannot leave statement empty
{
for(c=0;c<x;c++);
}
}
This is a simple led blinking program for single pin.Similarly, use can use for more than one pin.
See, delay is must. As speed of processors are so fast that you won't be able notice the blinking
NOTE: For infite loop ,you can also use for(;;) instead of while(1)