Short example:
Code:
'-------------------------------------------------------------------------------
'-------------------------------------------------------------------------------
@ DEVICE PIC12F683, MCLR_OFF
@ DEVICE PIC12F683, INTRC_OSC_NOCLKOUT
@ DEVICE PIC12F683, WDT_OFF
@ DEVICE PIC12F683, BOD_ON
@ DEVICE PIC12F683, PWRT_ON
'-------------------------------------------------------------------------------
OSCCON = %01110000 ' Internal 4MHz osc
ADCON0 = 0 ' A/D off
CMCON0 = 7 ' Comparators off
ANSEL = 0 ' Set all digital
WPU = 0 ' Internal pull-ups = off
OPTION_REG = %10000000 ' Pull-ups = off, GPIO.2 = I/O, prescaler to Timer1
GPIO = %00000000 ' All outputs = 0 on boot
TRISIO = %00001000 ' GPIO.3 input, GPIO.0,2,3,4,5 output
'-------------------------------------------------------------------------------
signal VAR GPIO.3
pulse VAR BYTE
'-------------------------------------------------------------------------------
main:
PulsIn signal, 1, pulse ' reads signal from receiver
IF (pulse >= 148) AND (pulse <= 152) Then
Low GPIO.0 ' turns LED off
Else
High GPIO.0 ' turns LED on
EndIF
GoTo main
'-------------------------------------------------------------------------------
End
'-------------------------------------------------------------------------------
'-------------------------------------------------------------------------------
Bookmarks