Don't ad-block us - support your favorite websites. We have safe, unobstrusive, robotics related ads that you actually want to see - see here for more.
0 Members and 1 Guest are viewing this topic.
#include "sys/atmega168.h"#include "a2d.h"#include "servos.h"#define pot ADC_NUMBER_TO_CHANNEL(5)//Define servoSERVO ser=MAKE_SERVO(FALSE,C4,1500,500);//CreatethelistSERVO_LIST servos[]={&ser};//CreateadriverforthelistofservosSERVO_DRIVER bank1=MAKE_SERVO_DRIVER(servos);void appInitHardware(void){//Initialise the servo controller using software PWMservosInit(&bank1,TIMER1);}//InitialisetheservosTICK_COUNT appInitSoftware(TICK_COUNT loopStart){act_setSpeed(&ser,1000);return 0;} TICK_COUNT appControl(LOOP_COUNT loopCount,TICK_COUNT loopStart){uint16_t val = a2dConvert10bit(pot); uint16_t s = interpolate(val, 0, 1023,1000,2000); act_setSpeed(&ser,s); return 10; }
uint16_t s = interpolate(val, 0, 1023,1000,2000);
DRIVE_SPEED s = interpolate(val, 0, 1023,DRIVE_SPEED_MIN,DRIVE_SPEED_MAX);