Device = 18F1320
Clock = 8
Config OSC = INTIO2
Config MCLRE = OFF
Include "INTOSC8.bas" // Sets up the internal oscillator for 8Mhz straight away
Include "Utils.bas"
Dim sink As PORTA.6 // Names PORTA.6 to sink for led2
Dim led As PORTA.0 //Names PORTA.0 to led
Dim IR As PORTB.0 //Names PORTB.0 to IR
Output (sink) //Sets sink to output
Output (led) //Sets led to output
Input (IR) //Sets IR to input
Low (led) //Sets led low
SetAllDigital //sets all ports digital
TRISB =%00000001 // just to make sure IR is set to input
PORTB =%00000000 // Sets all PORTB low
While true // while loop
If IR =0 Then //checks to see if IR change states
Low (led) //If IR is low led is on
Else
High (led) //else if IR is high led is off
EndIf // end of statement
Wend //end of loop