Buy an Axon, Axon II, or Axon Mote and build a great robot, while helping to support SoR.
0 Members and 1 Guest are viewing this topic.
// defined in hardware.c#define servo(position) servo(PORTH,2,position);
// initialized in control.cint servo_loc = 0;
/* control.c */// center servo during axon initcenter_servo();// turn far leftturn servo(200);// turn far rightturn_servo(1200);// somewhere in betweenturn_servo(470);// center the HS-422void center_servo(void){ for(unsigned short int i=0; i<10; i++) { servo(700); delay_ms(20); } // set current location servo_loc = 700;}// move the HS-422 to desired location between 200(left) & 1200(right)void turn_servo(int new_location){ // turning right if (new_location > servo_loc) { for(unsigned short int i=servo_loc; i<new_location; i=i+10) { // move servo servo(i); // set current servo location servo_loc = i; delay_ms(20); } } else { for(unsigned short int i=servo_loc; i>new_location; i=i-10) { // move servo servo(i); // set current servo location servo_loc = i; } }}
My problem is not getting pointers in the general sense of c.
#define LEFT_WHEEL 1#define RIGHT_WHEEL 2
void turn_servo(int servoNumber, unsigned int position){ switch(servoNumber){ case LEFT_WHEEL: servo(PORTH,2,position); break; case RIGHT_WHEEL: servo(PORTE,1,position); break; }}
Thanks, you beat me to it. I thought I was pushing my luck, but the preview looked OK. What was my mistake?