-- -- name : e0002.jal -- author : Wouter van Ooijen -- date : 05-May-1998 -- purpose : jal example -- -- This program shows a night-rider style LED on port B -- -- target configuration: 16f84 with 10 Mhz Xtal include 16f84_10 -- standard library include jlib -- jal has no enumerate, so use constants const byte to_right = 1 const byte to_left = 0 -- determine a new direction d when x has hit a boundary, -- shift x one step in the good direction procedure night( byte in out x, byte in out direction ) is -- hit left border? if ( x & 0b_1000_0000 ) != 0 then direction = to_right end if -- hit right border? if ( x & 0b_0000_0001 ) != 0 then direction = to_left end if -- shift in current direction if direction == to_right then x = x >> 1 else x = x << 1 end if end procedure -- port b all pins output port_b_direction = all_output var byte x = 0b_0000_0001 var byte d = to_left -- main loop forever loop -- set port b -- for active-low LEDs remove the -- port_b = x -- ^ 0xFF -- delay 200mS delay_100ms( 2 ) -- shift x one step in the current direction night( x, d ) end loop