input b.7 ;Current input
input b.6 ;Fan input
input b.5 ;Stirrer input
main: readadc b.7,b0
readadc b.6,b1
readadc b.5,b2
if b0 > 2 then goto reda ; move to reda to turn red light on when the current stops
if b1 < 2 then goto redb ; move to redb to turn red light on when the extraction tube stops
if b2 > 2 then goto redc ; move to redc to turn red light on when the magnetic stirrer stops
low b.3 ; blue light off
low b.2 ; red light off
high b.1 ; green light on
serout b.0,N2400, (254,1)
pause 30
serout b.0,N2400, (254,129,"All systems OK") ; display "all systems OK" on OLED screen
pause 500 ; pause for 1 second
goto main ; start again
reda: low b.1 ; green light off
high b.2 ; red light on
serout b.0,N2400, (254,1)
pause 30
serout b.0,N2400, (254,133,"Current") ; display "current off" on OLED screen
pause 500; pause for 1 second
readadc b.7,b0
readadc b.6,b1
readadc b.5,b2
if b1 < 2 then goto reda1 ; move to reda1 to keep red light on if extraction tube also stops
if b2 > 2 then goto reda2 ; move to reda2 to keep red light on if magnetic stirrer also stops
if b0 < 2 then goto main ; start program again if the current returns
goto reda ; start again
reda1:serout b.0,N2400, (254,1)
pause 30
serout b.0,N2400, (254,129,"Current and fan") ; display "current off and extraction fan not working" on OLED screen
pause 500 ; pause for 1 second
readadc b.7,b0
readadc b.6,b1
readadc b.5,b2
if b2 < 2 then goto blue ; move to blue to turn blue light on if the magnetic stirrer also stops
if b0 < 2 then goto main ; start program again if the current returns
if b1 > 2 then goto main ; start program again if the extraction fan starts working again
goto reda1 ; start again
reda2:serout b.0,N2400, (254,1)
pause 30
serout b.0,N2400, (254,130,"Current and") ; display "current off and magnetic stirrer not working" on OLED screen
serout b.0,N2400, (254,196,"stirrer")
pause 500 ; pause for 1 second
readadc b.7,b0
readadc b.6,b1
readadc b.5,b2
if b1 < 2 then goto blue ; move to blue to turn blue light on if the extraction fan also stops
if b0 < 2 then goto main ; start program again if the current returns
if b2 < 2 then goto main ; start program again if the magnetic stirrer starts working again
goto reda2 ; start again
redb: low b.1 ; green light off
high b.2 ; red light on
serout b.0,N2400, (254,1)
pause 30
serout b.0,N2400, (254,134,"Fan") ; display "extraction fan not working" on OLED screen
pause 500 ; pause for 1 second
readadc b.7,b0
readadc b.6,b1
readadc b.5,b2
if b0 > 2 then goto redb1 ; move to redb1 to keep red light on if current also stops
if b2 > 2 then goto redb2 ; move to redb2 to keep red light on if magnetic stirrer also stops
if b1 > 2 then goto main ; start program again if the extraction fan starts working again
goto redb ; start again
redb1:serout b.0,N2400, (254,1)
pause 30
serout b.0,N2400, (254,129,"Current and fan") ; display "current off and extraction fan not working" on OLED screen
pause 500 ; pause for 1 second
readadc b.7,b0
readadc b.6,b1
readadc b.5,b2
if b2 > 2 then goto blue ; move to blue to turn blue light on if the magnetic stirrer also stops
if b0 < 2 then goto main ; start program again if the current returns
if b1 > 2 then goto main ; start program again if the extraction fan starts working again
goto redb1 ; start again
redb2:serout b.0,N2400, (254,1)
pause 30
serout b.0,N2400, (254,129,"Fan and stirrer") ; display "extraction fan and magnetic stirrer not working" on OLED screen
pause 500 ; pause for 1 second
readadc b.7,b0
readadc b.6,b1
readadc b.5,b2
if b0 > 2 then goto blue ; move to blue to turn blue light on if the current also stops
if b1 > 2 then goto main ; start program again if the extraction fan starts working again
if b2 < 2 then goto main ; start program again if the magnetic stirrer starts working again
goto redb2 ; start again
redc: low b.1 ; green light off
high b.2 ; red light on
serout b.0,N2400, (254,1)
pause 30
serout b.0,N2400, (254,132,"Stirrer") ; display "magnetic stirrer not working" on OLED screen
pause 500 ; pause for 1 second
readadc b.7,b0
readadc b.6,b1
readadc b.5,b2
if b0 > 2 then goto redc1 ; move to redc1 to keep red light on if current also stops
if b1 < 2 then goto redc2 ; move to redc2 to keep red light on if extraction fan also stops
if b2 < 2 then goto main ; start program again if the magnetic stirrer starts working again
goto redc ; start again
redc1:serout b.0,N2400, (254,1)
pause 30
serout b.0,N2400, (254,130,"Current and") ; display "current off and magnetic stirrer not working" on OLED screen
serout b.0,N2400, (254,196,"stirrer")
pause 500 ; pause for 1 second
readadc b.7,b0
readadc b.6,b1
readadc b.5,b2
if b2 > 2 then goto blue ; move to blue to turn blue light on if the extraction fan also stops
if b0 < 2 then goto main ; start program again if the current returns
if b1 > 2 then goto main ; start program again if the magnetic stirrer starts working again
goto redc1 ; start again
redc2:serout b.0,N2400, (254,1)
pause 30
serout b.0,N2400, (254,129,"Fan and stirrer") ; display "extraction fan and magnetic stirrer not working" on OLED screen
pause 500 ; pause for 1 second
readadc b.7,b0
readadc b.6,b1
readadc b.5,b2
if b0 > 2 then goto blue ; move to blue to turn blue light on if the current also stops
if b1 > 2 then goto main ; start program again if the extraction fan starts working again
if b2 < 2 then goto main ; start program again if the magnetic stirrer starts working again
goto redc2 ; start again
blue: low b.2 ; red light off
high b.3 ; blue light on
serout b.0,N2400, (254,1)
pause 30
serout b.0,N2400, (254,132,"Finished") ; display "finished" on OLED screen
pause 800 ; pause for 3ms
readadc b.7,b0
readadc b.6,b1
readadc b.5,b2
if b0 < 2 and b1 > 2 and b2 < 2 then goto main ; if all three components start working again start program from beginning
goto blue ; start again