Code:
int main()
{
//Declare the variables for the main function here
int k = 3;
int j = 0;
int i = 0;
initialize_IO_ports();
//put the infinite loop here
while(1)
{
if( k == 3)
{
delay_ms(3000);
for(j=0; j<1000;j++)
{
RC0 = 1; // inputs for bi-directional DC motor circuit
RC1 = 0;
delay_ms(6000); // run forward for 6 secs
}
delay_ms(5000); //wait for 5 seconds -- HALT--No running
i = 0; // insert value
if(i == 0)
{
delay_ms(3000); //wait for sometime
for(j=0;j<1000;j++)
{
RC0 = 0;
RC1 = 1;
delay_ms(6000); // run backward for 6 secs
}
}
}
else
{
RC0 = 0;
RC1 = 0;
}
}; // end of while
return(1);
} // end ofmain
Hi all,
This is my PIC c code for H bridge motor driver.Manually, my H bridge motor driver works well.But when i use it with PIC, the motor runs continuously in one direction.
1) When the input is 1 , the motor should start after 3 secs and run forward for 6 secs
2) should stop now for 3 secs and run backward for 6 secs and stop.
Please help me !
Thanks