interupt

Joined
Dec 2, 2010
Messages
1
Reaction score
0
im trying to put a interupt on a pic 16f877 but i keep getting error messages. can somebody help me


#include "mxapi.h"


void main(void)
{
if(RB2 == HIGH)
{
TRISB3 = 0;
TRISB2 = INPUT;
TRISB0 = 0;
TRISB7 = 1; //Set up Port B7 as an input
RB0 = LOW;
while(1==1)
{
if(RB7==1) //If Port B7 is high
{
move(400,1000,2000); //Stop moving
}
else if(RB7==0) //If Port B7 is low
{
move(20,2000,1000); //Move forward 1
}
}
}
}




void move(int count, int left_pulse, int right_pulse)
{
int i;
for(i=0; i<count; i++) //Pass count to the for loop
{
RB3 = 1;
delay_us(left_pulse); //Wait for left_pulse microseconds
RB3 = 0;
RB0 = 1;
delay_us(right_pulse); //Wait for right_pulse microseconds
RB0 = 0;
delay_ms(50);
}
}


void main(void)
{
TRISB3 = 0;
TRISB0 = 0;
RB3 = 0;
RB0 = 0;
move(150,2000,1000); //Call the move function
move(25,2000,2000); //Call the move function
move(150,2000,1000); //Call the move function
move(25,1000,1000); //Call the move function
move(100,2000,1000); //Call the move function


end();
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top