Created
May 9, 2016 00:06
-
-
Save agaikwad123/e67db2e3053de360f6dd69ef27f7fe2a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Port1 pins P1.24 to P1.31 and the these pins are configured as General Purpose output pins. | |
#include<lpc2148.H> //LPC2148 Header | |
void delay() | |
{ | |
for(int i=0x00;i<=0xff;i++) | |
for(int j=0x00;j<=0xFf;j++) ; // Delay program | |
} | |
void main() | |
{ | |
PINSEL2 = 0X00000000; // Set P1.24 TO P1.31 as GPIO | |
IO1DIR = 0XFF000000; //Port pins P1.24 to P 1.31 Configured as Output port. | |
while(1) //Infinite loop | |
{ | |
IO1SET=0XFF000000; // Pins P1.24 to P1.31 goes to high state | |
delay(); | |
IO1CLR=0XFF000000; // Pins P1.24 to P1.31 goes to low state | |
delay() ; | |
} | |
} | |
PROGRAM – 2 | |
This program glows LEDs alternately by sending 55H and AAH through the port1 Pins. | |
# include <LPC214X.H> //LPC2148 HEADER | |
void delay(void) // Delay Program | |
{ | |
unsigned int i; | |
i=0xffffff; | |
while(i--); | |
} | |
int main(void) | |
{ | |
PINSEL2=0x0000; // Port 1 is I/O | |
IODIR1 = 0XFF <<24 ; // Port Pins P1.24 to P1.31 as Output Pins | |
while(1) // Infinite loop | |
{ | |
IOSET1=0X55<<25 ; // P1.25,P1.27,P1.29 & P1.31 LEDs will Glow | |
delay() ; // Call delay function | |
IOCLR1= 0X55 <<25 ; // P1.25,P1.27,P1.29 &P1.31 LEDs will be off | |
IOSET1=0XAA<<24 ; //P1.24,P1.26,P1.28 &P1.30 LEDs are Glow | |
delay () ; // Call delay function | |
IOCLR1=0XAA<<24 ; // P1.24,P1.26,P1.28 &P1.30 LEDs are off | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# include <LPC214X.H> //LPC2148 HEADER | |
# define relay 1<<30 // ASSIGN P0.30 Pin to RELAY input PIN | |
void DELAY(void) // Delay function | |
{ | |
unsigned int i; | |
i=0xffffff; | |
while(i--) ; | |
} | |
int main(void) // Main program | |
{ | |
IODIR0=1<<30 ; // P0.30 Port Pin as Outport | |
while(1) //INFINITE LOOP | |
{ | |
IOSET0=1<<30 ; //SWITCH OFF RELAY | |
DELAY() ; //CALL DELAY | |
IOCLR0=1<<30 ; // SWITCH ON RELAY | |
DELAY() ; // CALL DELAY | |
} // REPEAT LOOP | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# include <LPC214X.H> // LPC2148 HEADER | |
void delay_ms() ; // Delay function | |
void main() ; // Main program starts | |
{ | |
PINSEL2 = 0X00000000; // Set P1.19 TO P1.22 as GPIO | |
IO1DIR=0x000000F0 ; // Set Port 1 as out port | |
while(1) // Infinite Loop | |
{ | |
IO1PIN = 0X00000090; // Send the code1 for phase 1 | |
delay_ms() ; // Call Delay | |
IO0PIN = 0X00000050 ; // Send the code 2 for phase 2 | |
delay_ms() ; // Call Delay | |
IO1PIN = 0X00000060 ; // Send the code 3 for phase 3 | |
delay_ms() ; // Call Delay | |
IO1PIN = 0X000000A0 ; // Send the code 3 for phase 3 | |
delay_ms() ; // Call Delay | |
} | |
} | |
void delay_ms() // Delay function program | |
{ | |
int i,j ; | |
for(i=0;i<0x0a;i++) | |
for (j=0;j<750;j++) ; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment