Design first, code later. Plan everything out using logic, flow diagrams, state diagrams, etc. Your problems are with the logic, not the coding. Jonk has done 8051, I have not. I have done 6502 and 6800 assembly, these are similar.
At first you might be tempted to have states based on physical position.
But, an elevator really only has 3 states, going up, ...
Using the following code we can obtain the path the poles go as you change k.
G = poly([-1],'z')/poly([0.3 1],'z');
y = ;
for k = logspace(-2,1,1000)
y = [y abs(roots((k*G/(1+k*G)).den))];
//pick here your optimal gain
L = 0.5*G;
L = L/(1+L);
t = 0:21;
I had the same issue. As you can see when you used the verbose mode it listed all the fuses you have : fuse0, fuse1, fuse2 ...
If you type avrdude.exe -c jtag2_updi -p attiny1616 -U fuse0:r:-:i -v it will show you the value written in fuse 0 which is the WDTCFG fuse.
So fuse0 to fuse9 correspond respectively to fuses with offset 0x00 to 0x09 (page 33 in ...