Basic
Building block of any controller is GPIO, I am demonstrating a simple example
to take binary input and set binary output accordingly
#include
<LPC214x.H>
#define
LED (1 << 17)
#define SWITCH (1 << 16)
int main
(void)
{
IO1DIR |=
LED; //set
pin P1.17 direction as output
IO1DIR
&=~ SWITCH; //set
pin P1.16 direction as input
while (1) //run continuously
{
(IO1PIN &
SWITCH) ?(IO1SET = LED):(IO1CLR = LED);
//Set the output
status according to input using ? operator
}
}
No comments:
Post a Comment