I can't understand why this code works when, for instance, w12 has value of 280 and w13 has value of 30 but doesn't work when w12=290 and w13=30.
Can someone please explain where I've gone wrong please?
Can someone please explain where I've gone wrong please?
Code:
#picaxe 08m2
setfreq m16
w12=280 ;w12 varies but is always >180 and<361 degrees
w13=30 ;w13 varies but is always <181 degrees
label1:
let b11=w12-w13 ;b11 is degrees right
if b11 >180 then gosub label2
goto label3
label2:
let b10=360-w12+w13 ;to give smallest angle between
let b11=0 ;w12 and w13 in a 360 degree circle
return ;b10 is degrees left
label3:
b9=b10+b11