> > Simulate the whole day every minute like I was talking about. It sounds > like a horribly inefficient thing to do, but what else is the PIC going > to be doing? Also it should lead to small code, which is vital for you. > I think you mean something like this: for x = 1 to 20 ; max. N^ of setpoint (in random order) If set_point_time(x) = present_time then buffer = third_byte_eeprom(x) ; it said what to do end if next x PIC_out_pin = buffer and repeat this at least every minute . I can't understand how to get a correct refresh of the buffer every minute with the whole day min. by min. comparison. > Although your way based on compare if greater isn't too bad either. As > someone else suggested, rather than do a full sort, just keep the table > in order from the beginning. Find the proper place to store enter a new > set-point and move the other entries in the table up to accomodate it. > Keeping the table in order should make it easier to use as well. > Yes. It's a good idea . I'll try it. > Yes, that's another way to do it. You'll need a way to subtract times, I written my idea in that way : buffer = 0 ;stay off until there is a match prev_dist = 1440 ; 1 + hh*60 + mm (23*60+59 ) for x = 1 to 20 ;max. N^ of setpoint (in random order) If present_time > = set_poin_time(x) then dist = present_time - set_point_time if prev_dist > dist then prev_dist = dist buffer = third_byte_eeprom(x) end if end if next x PIC_out_pin = buffer and repeat this at least every minute. In qbasic seems it work ; now i 'll try to translate in asm.