CODE:
/**********************************************************************
NAME:MOHSIN KHAN
DC MOTOR CONTROL USING PIC18F4550 IN A OPEN
LOOP
**********************************************************************/
#include<p18f452.h>
#pragma config WDT=OFF
#pragma config OSC=HS,OSCS=OFF
#pragma config BORV=45,PWRT=ON,BOR=ON
#define SW0 PORTBbits.RB0
#define SW1 PORTBbits.RB1
#define EN PORTCbits.RC0
#define MTR PORTCbits.RC1
void delay(unsigned int d);
void main()
{
TRISD=0xC0; //RD7 as input
TRISC=0x00; //RC1 as output
MTR=0;
if(SW0==1&&SW1==1)
{
EN=1;
MTR=1;
}
else
if(SW0==0&&SW1==1)
{
EN=1;
MTR=1;
delay(20);
MTR=0;
delay(80);
}
else
if(SW0==1&& SW1==0)
{
EN=1;
MTR=1;
delay(50);
MTR=0;
delay(20);
}
else
{
MTR=0;
}
}
void delay(unsigned int d)
{
unsignedinti,j;
for(i=0;i<1200;i++)
for(j=0;j<d;j++);
}
RESULT:
1 Comment:
thanks.....
Post a Comment