'Timer with an 18X & 3 push buttons 'COUNT_DOWN_1.BAS 'C.Wylie 30/12/2007 SYMBOL sec_1 = b2 SYMBOL sec_10 = b1 SYMBOL up_button = pin1 'up button SYMBOL down_button = pin2 'down button SYMBOL Start_button = pin0 'run timer SYMBOL Time = b5 SYMBOL Flag = b4 'are we counting SYMBOL old_time = b7 SYMBOL lo_op = b10 SYMBOL del_ay = b6 'display loop time old_time = 0 flag = 0 read 1,Old_Time 'read in stored data Sec_1 = Old_Time / 10 Sec_10 = Old_Time % 10 Time = Old_Time if time = 0 then ' set up a time for first run time = 30 sec_1 = time / 10 sec_10 = time // 10 goto display endif goto main Main: if start_button = 1 then del_ay = 90 goto coun_t 'count down endif if up_button = 1 then U_p 'adjust time up if down_button =1 then D_wn 'adjust time down if start_button =0 and down_button = 0 and start_button = 0 then goto display goto Main U_p: if time => 99 then st_op old_time = time +1 sec_1 = old_time /10 sec_10 = old_time // 10 time = old_time del_ay = 30 'speed up display goto display end D_wn: if time =0 then st_op old_time = time - 1 sec_1 = old_time / 10 sec_10 = old_time // 10 time = old_time del_ay = 30 goto display end Display: for lo_op = 1 to del_ay ' loop to keep display + part of timing delay pins = sec_10 +64 'lsb plus bit 6 enable display pause 4 pins = sec_1 +128 'msb plus bit 7 enable display pause 4 next lo_op if Flag = 1 then coun_t 'back to count backwards goto Main end coun_t: 'Count backwards Flag = 1 if time = 0 then St_op time = time - 1 sec_1 = time / 10 +16 'msb of display + turn on relay sec_10 = time % 10 + 16 'lsb of display + turn on relay goto display end St_op: flag = 0 low 6 'turn off displays low 7 low 4 'turn off relay output high 5 pause 2000 sec_1 = Old_Time/10 'load old time sec_10 =Old_Time % 10 ' into Time = Old_Time 'counter for display and counting write 1,Time 'b7 write data to eeprom goto main end