How to replace a mechanical Potentiometer with arduino controlled digital Pot?

As I understand this code, it put CS to LOW for digit pot can send a signal on wiper exit accordingly with value.