programming with AD5171

hai guyz... am new to arduino. i have to makea task to control a motor with AD5171 and also those control will come under single sensor. while the sensor sense a ostacle means the motor has to run at different speed. any one help me with a algorithm. block diagram is shown below