start FSVoltage fEQU 3.20 ;The actual FS voltage, as measured by multimeter (3.3V pin) launchtask ReadBat launchtask led1 ;starts task led1 launchtask led2 launchtask led3 launchtask led4 launchtask led5 launchtask led6 launchtask led7 launchtask led8 runtasksforever ReadBat fAnIn 0 ; read the analog input at input 0 fLoadQ FSVoltage ;load Q with the the value 3.20 fswap fmul ;calculate the actuall voltage and leave it in W Fstore 1 ; store the value in memory slot 1 yieldtask goto ReadBat led1 on 2 pause 10 off 2 ;flash led if les than 1V pause 30 frecallW 1 ;load the value stored in memory slot 1 into W floadq 0.8 ; load Q with the value Fgoifwgeq led1on ;go to led1on if W is equal to or greater than Q yieldtask goto led1 ;jump back to led1 led1on on 2 ;turn on led 1 frecallW 1 floadq 0.8 fgoifwltq led1 ;go to led1 if W is les than Q yieldtask goto led1on ;jump back to led1on led2 off 3 frecallW 1 floadq 0.9 Fgoifwgeq led2on yieldtask goto led2 led2on on 3 frecallW 1 floadq 0.9 fgoifwltq led2 yieldtask goto led2on led3 off 4 frecallW 1 floadq 1 Fgoifwgeq led3on yieldtask goto led3 led3on on 4 frecallW 1 floadq 1 fgoifwltq led3 yieldtask goto led3on led4 off 5 frecallW 1 floadq 1.1 Fgoifwgeq led4on yieldtask goto led4 led4on on 5 frecallW 1 floadq 1.1 fgoifwltq led4 yieldtask goto led4on led5 off 6 frecallW 1 floadq 1.2 Fgoifwgeq led5on yieldtask goto led5 led5on on 6 frecallW 1 floadq 1.2 fgoifwltq led5 yieldtask goto led5on led6 off 7 frecallW 1 floadq 1.3 Fgoifwgeq led6on yieldtask goto led6 led6on on 7 frecallW 1 floadq 1.3 fgoifwltq led6 yieldtask goto led6on led7 off 8 frecallW 1 floadq 1.4 Fgoifwgeq led7on yieldtask goto led7 led7on on 8 frecallW 1 floadq 1.4 fgoifwltq led7 yieldtask goto led7on led8 off 9 frecallW 1 floadq 1.5 Fgoifwgeq led8on yieldtask goto led8 led8on on 9 frecallW 1 floadq 1.5 fgoifwltq led8 yieldtask goto led8on