Controlling the AD5254 Digital Potentiometer

This should answer most of your questions:

It's not very complicated, the library does most of it.