There's a mistake in my code.
The Setting variable can go from 0 to 5 (6 settings) but there's only five entries in the first LOOKUP statement, the one that sets the initial dutycycle.