Method for adapting stiffness in a variable stiffness actuator