- CODE: SELECT_ALL_CODE
void main() {
TRISB = 0X0F;
UART1_Init(9600);
// for activating servo channel
UART1_Write(192); //select all servo
UART1_Write(1); //activate all servo
UART1_Write(129); //select all servo
UART1_Write(62); //activate all servo
UART1_Write(32); //select all servo
while (UART1_Read() !=0x04){
}
//for position and speed command
while(1){
if (PORTB.F0 == 0){
Delay_ms(40);
// for activating servo channel
UART1_Write(225); //position & speed command servo 1
UART1_Write(62); //higher byte position
UART1_Write(32); //lower byte position
UART1_Write(0); //servo speed
}
//for position and speed command
if (PORTB.F1 == 0){
Delay_ms(40);
// for activating servo channel
UART1_Write(225); //position & speed command servo 1
UART1_Write(31); //higher byte position
UART1_Write(16); //lower byte position
UART1_Write(0); //servo speed
}
//for position and speed command
if(PORTB.F2 == 0){
Delay_ms(40);
// for activating servo channel
UART1_Write(225); //position & speed command servo 1
UART1_Write(93); //higher byte position
UART1_Write(48); //lower byte position
UART1_Write(0); //servo speed
}
}
}