'Microcontroller: PIC18F4620
'Clock Frequency: 8MHz
main:
ADCON0 = 7
ADCON1 = 7 ' All pins digital.
CMCON = 7 ' All comparator Off.
TRISB = %00011111
TRISC = %00000000
TRISD = %00000000
TRISE = %1000
PORTB = 0
PORTC = 0
PORTD = 0
PORTE.0 = 0
PORTE.1 = 0
PORTE.2 = 0
PORTE.3 = 1
Lcd8_Config(PORTE, PORTC, 2,1,0, 7,6,5,4,3,2,1,0) [COLOR="#FF0000"]//8-bit LCD Routines and Configuration[/COLOR]
Lcd8_Cmd(LCD_TURN_ON)
Lcd8_Cmd(LCD_CURSOR_OFF)
Lcd8_Cmd(LCD_CLEAR)
Lcd8_Out(1,1, "PIC18F4620 Based")
Lcd8_Out(2,1, "XXXXXXXXXXXXXXXXXXXX")
Lcd8_Out(3,1, "XXXXXXXXXXXXXXXXXXXX")
Lcd8_Out(4,1, "XXXXXXXXXXXXXXXXXXXX")
while(1)
select case PORTB
case %00000001
delay_ms(10)
if (PORTB = %00000001) and (PORTD = %00000000) then
delay_ms(10)
if (PORTB = %00000000) and (PORTD = %00000000) then
PORTD = %00000001
[COLOR="#FF0000"]Lcd_Cmd[/COLOR](LCD_CLEAR) [COLOR="#FF0000"]//4-bit LCD Routines[/COLOR]
[COLOR="#FF0000"]Lcd_Out[/COLOR](1,1, "RELAY ON")
[COLOR="#FF0000"]Lcd_Out[/COLOR](2,1, "RELAY ON")
[COLOR="#FF0000"]Lcd_Out[/COLOR](3,1, "RELAY ON")
[COLOR="#FF0000"]Lcd_Out[/COLOR](4,1, "RELAY ON")
end if
end if
case %00000010
delay_ms(10)
if (PORTB = %00000010) and (PORTD = %00000001) then
delay_ms(10)
if (PORTB = %00000000) and (PORTD = %00000001) then
PORTD = %00000000
[COLOR="#FF0000"]Lcd_Cmd[/COLOR](LCD_CLEAR) [COLOR="#FF0000"]//4-bit LCD Routines[/COLOR]
[COLOR="#FF0000"]Lcd_Out[/COLOR](1,1, "RELAY OFF")
[COLOR="#FF0000"]Lcd_Out[/COLOR](2,1, "RELAY OFF")
[COLOR="#FF0000"]Lcd_Out[/COLOR](3,1, "RELAY OFF")
[COLOR="#FF0000"]Lcd_Out[/COLOR](4,1, "RELAY OFF")
end if
end if
end select
wend
end.