- #1
DrDanger
- 44
- 0
// first write the basic functionality for motion
void left_forward() {
PORTC.F0 =1;
PORTC.F1 =0;
}
void left_reverse() {
PORTC.F0 =0;
PORTC.F1 =1;
}
void left_stop() {
PORTC.F0 =0;
PORTC.F1 =0;
}
void right_forward() {
PORTC.F5 =1;
PORTC.F6 =0;
}
void right_reverse() {
PORTC.F5 =0;
PORTC.F6 =1;
}
void right_stop() {
PORTC.F5 =0;
PORTC.F6 =0;
}
void setup_P16F690() {
// This is all the stuff that's needed for the chip
ANSEL=ANSELH=0;
PORTC=0;
TRISC=0;
}
main() {
setup_P16F690();
while(1) { // Do this forever
left_forward();
delay_ms(1000); // Wait 1000 ms = 1sec
left_reverse();
delay_ms(1000); // Wait 1000 ms = 1sec
left_stop();
delay_ms(2000); // Wait 1000 ms = 1sec
}
while(1) { // Do this forever
right_forward();
delay_ms(1000); // Wait 1000 ms = 1sec
right_reverse();
delay_ms(1000); // Wait 1000 ms = 1sec
right_stop();
delay_ms(2000); // Wait 1000 ms = 1sec
}
}
I am new to programming just started learning it a few days ago. I wrote this for a robot I am working on and can't get the right wheel to move. The left one works fine. thanks for any help
void left_forward() {
PORTC.F0 =1;
PORTC.F1 =0;
}
void left_reverse() {
PORTC.F0 =0;
PORTC.F1 =1;
}
void left_stop() {
PORTC.F0 =0;
PORTC.F1 =0;
}
void right_forward() {
PORTC.F5 =1;
PORTC.F6 =0;
}
void right_reverse() {
PORTC.F5 =0;
PORTC.F6 =1;
}
void right_stop() {
PORTC.F5 =0;
PORTC.F6 =0;
}
void setup_P16F690() {
// This is all the stuff that's needed for the chip
ANSEL=ANSELH=0;
PORTC=0;
TRISC=0;
}
main() {
setup_P16F690();
while(1) { // Do this forever
left_forward();
delay_ms(1000); // Wait 1000 ms = 1sec
left_reverse();
delay_ms(1000); // Wait 1000 ms = 1sec
left_stop();
delay_ms(2000); // Wait 1000 ms = 1sec
}
while(1) { // Do this forever
right_forward();
delay_ms(1000); // Wait 1000 ms = 1sec
right_reverse();
delay_ms(1000); // Wait 1000 ms = 1sec
right_stop();
delay_ms(2000); // Wait 1000 ms = 1sec
}
}
I am new to programming just started learning it a few days ago. I wrote this for a robot I am working on and can't get the right wheel to move. The left one works fine. thanks for any help