manvindar
Member level 1
i am new to ARM processors and want to write a simple code like monitoring pin P0.8 and if its high then LED should glow at Pin P0.22
how about to do that?
how about to do that?
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
#include <LPC21xx.h>
#define led (1<<22)
#define sw (1<<8)
int main (void)
{ PINSEL0=sw;
IODIR0=0xFFFFFFF; if (sw == 1)
IOSET0 = (1<<22);
else
IOCLR0 = (1<<22);
}
#include <LPC21xx.h>
#define led (1<<22) // Led is bit 22
#define sw (1<<8) // Switch is bit 8
int main (void)
{
IODIR0 &= ~sw; // Set as inputs
IODIR0 |= led; // Set as outputs
while(1)
{
if (IOPIN0 & sw) // Check switch state, reflect to led
IOSET0 = led;
else
IOCLR0 = led;
}
}
whats wrong with this code???
Code:#include <LPC21xx.h> #define led (1<<22) // Led is bit 22 #define sw (1<<8) // Switch is bit 8 int main (void) { IODIR0 &= ~sw; // Set as inputs IODIR0 |= led; // Set as outputs while(1) { if (IOPIN0 & sw) // Check switch state, reflect to led IOSET0 = led; else IOCLR0 = led; } }
[
..actually the led is embedded in dev board and its connected to the other way......
sry the code is correct..actually the led is embedded in dev board and its connected to the other way......