adalah
Newbie level 6
www.ermirco.com/blog
hi all..
i need some help about my code.
hope all the members can help me to solve the problems..
i'm using :
MikroC,
PIC16F877A,
3 servomotor.
my problems is:
the command for servo1pos3() is working,
but the program is not move to the next step which is command for servo3pos1().
this my attachment about the circuit and programming.
hi all..
i need some help about my code.
hope all the members can help me to solve the problems..
i'm using :
MikroC,
PIC16F877A,
3 servomotor.
#define leftsensor porta.f0
#define rightsensor porta.f2
#define start porta.f4
#define reset porta.f5
#define servo1 portb.f0
#define servo2 portb.f2
#define servo3 portb.f4
int i, cnt ;
void interrupt(void)
{
cnt++;
if ( cnt == 200)
{
cnt = 0;
portb = 0xff;
}
INTCON = 0x20;
}
void LCDfoward();
void walkfoward();
void servo1pos3();
void servo3pos1();
// main program...
void main(){
TRISA=0Xff;
TRISC=0;
PORTA=0;
PORTC=0;
while(1){
if(start == 0){
walkfoward();
}
}
//return;
}
void walkfoward(void)
{
LCDfoward();
servo1pos3();
delay_ms(1000);
servo3pos1();
delay_ms(1000);
}
char *text = "move";
void LCDfoward(void){
TRISC = 0;
Lcd_Init(&PORTC);
Lcd_Cmd (Lcd_CLEAR);
Lcd_Cmd (Lcd_CURSOR_OFF);
Lcd_Out (1, 6, text);
Lcd_Out (2, 5, "foward");
}//~!
void servo1pos3(void)
{
OPTION_REG = 0b10000000; // Assign prescaler to TMR0
TRISB = 0; // PORTB is output
PORTB = 0XFF; // Initialize PORTB
INTCON = 0xA0; // Enable TMRO interrupt
cnt = 0; // Initialize cnt
do
{
if (cnt == 20){
PORTB.f0 = 0;
cnt = 0;
delay_ms(1000); // Toggle PORTB LEDs
}
} while(1);
}//~!
void servo3pos1(void)
{
OPTION_REG = 0b10000000; // Assign prescaler to TMR0
TRISB = 0; // PORTB is output
PORTB = 0XFF; // Initialize PORTB
INTCON = 0xA0; // Enable TMRO interrupt
cnt = 0; // Initialize cnt
do
{
if (cnt == 10){
PORTB.f4 = 0; // Toggle PORTB LEDs
cnt = 0;
delay_ms(1000);
}
} while(1);
}//~!
my problems is:
the command for servo1pos3() is working,
but the program is not move to the next step which is command for servo3pos1().
this my attachment about the circuit and programming.