'**************************************************************** '* Name : UNTITLED.BAS * '* Author : Harm de Vries * '* Notice : Copyright (c) 2010 Funny Faces Hard & Software * '* : All Rights Reserved * '* Date : 28-01-10 * '* Version : 1.0 * '* Notes : * '* : * '**************************************************************** Device 18F452 Xtal 20 All_Digital = true Config_Start OSC = HS ' Oscillator Selection HS OSCS = Off ' Osc. Switch Enable Disabled PWRT = On ' Power-up Timer Enabled BOR = Off ' Brown-out Reset Disabled BORV = 25 ' Brown-out Voltage 2.5V WDT = Off ' Watchdog Timer Disabled WDTPS = 128 ' Watchdog Postscaler 1:128 CCP2MUX = Off ' CCP2 MUX Enable (RC1) STVR = Off ' Stack Overflow Reset Disabled LVP = Off ' Low Voltage ICSP Disabled Debug = Off ' Background Debugger Enable Disabled CP0 = Off ' Code Protection Block 0 Disabled CP1 = Off ' Code Protection Block 1 Disabled CP2 = Off ' Code Protection Block 2 Disabled CP3 = Off ' Code Protection Block 3 Disabled CPB = Off ' Boot Block Code Protection Disabled CPD = Off ' Data EEPROM Code Protection Disabled WRT0 = Off ' Write Protection Block 0 Disabled WRT1 = Off ' Write Protection Block 1 Disabled WRT2 = Off ' Write Protection Block 2 Disabled WRT3 = Off ' Write Protection Block 3 Disabled WRTB = Off ' Boot Block Write Protection Disabled WRTC = Off ' Configuration Register Write Protection Disabled WRTD = Off ' Data EEPROM Write Protection Disabled EBTR0 = Off ' Table Read Protection Block 0 Disabled EBTR1 = Off ' Table Read Protection Block 1 Disabled EBTR2 = Off ' Table Read Protection Block 2 Disabled EBTR3 = Off ' Table Read Protection Block 3 Disabled Config_End TRISA = %00000001 TRISB = 0 TRISC = 0 TRISD = 0 TRISE = 0 Declare RC5In_Pin = PORTA.0 Declare LCD_Type = ALPHA Declare LCD_RSPin PORTB.4 Declare LCD_ENPin PORTB.5 Declare LCD_DTPin PORTB.0 Declare LCD_Lines = 2 Declare LCD_Interface = 4 All_Digital true Dim RC5_WORD As Word ' Create a WORD variable to receive the data Dim RC5_COMMAND As RC5_WORD.LowByte ' Alias the COMMAND byte to RC5_WORD low byte Dim RC5_SYSTEM As RC5_WORD.HighByte ' Alias the COMMAND byte to RC5_WORD high byte Dim MyRC5 As Byte Dim aTel As Byte Dim wtel As Word Cls ' Clear the LCD aTel = 0 PORTD = 0 While 1 = 1 ' Create an infinite loop Repeat RC5_WORD = RC5In ' Receive a signal from the infrared sensor Until RC5_COMMAND <> 255 ' Keep looking until a valid header found ; Print At 1,1,"SYS ",Dec2 RC5_SYSTEM," " ' Display the SYSTEM value ; Print At 2,1,"COM ",Dec2 RC5_COMMAND," " ' Display the COMMAND value GoSub DoeCommand Wend DoeCommand: Cls aTel = 0 MyRC5 = RC5_COMMAND Print At 1,1, Dec2 RC5_COMMAND, " " Select MyRC5 Case 1: GoSub com1 Case 2: GoSub com2 Case 3: GoSub com3 Case 4: GoSub com4 EndSelect Return WaitButton: wtel = 0 While wtel < 300 RC5_WORD = RC5In If RC5_COMMAND = 255 Then Inc wtel Else If RC5_COMMAND = MyRC5 Then wtel = 999 EndIf DelayMS 1 Wend Return com1: Print At 1,1, "Com1" PORTD.0 = 1 com1_00: Inc aTel Print At 2,1, Dec3 aTel GoSub WaitButton If RC5_COMMAND = MyRC5 Then GoTo com1_00 PORTD.0 = 0 Return com2: Print At 1,1, "Com2" PORTD.1 = 1 com2_00: Dec aTel Print At 2,1, Dec3 aTel GoSub WaitButton If RC5_COMMAND = MyRC5 Then GoTo com2_00 PORTD.1 = 0 Return com3: Print At 1,1, "Com3" PORTD.2 = 1 com3_00: GoSub WaitButton If RC5_COMMAND = MyRC5 Then GoTo com3_00 PORTD.2 = 0 Return com4: Print At 1,1, "Com4" PORTD.3 = 1 com4_00: GoSub WaitButton If RC5_COMMAND = MyRC5 Then GoTo com4_00 PORTD.3 = 0 Return End