Just a few things to start off with:
There's probably more but that's what I see for now.Code:@ __CONFIG _INTOSCIO & _FCMEN_OFF & _IESO_OFF & _BOD_OFF & _BOD_OFF & _CP_OFF & _MCLRE_ON & _MCLRE_OFF & _PWRTE_ON & _WDT_OFF Choose one DEFINE OSC 8 ' Internal 8MHz 'DEFINE ADC_BITS 8 ' 8-bit resolution 'DEFINE ADC_CLOCK 2 ' Set clock source to Frc/32 'DEFINE ADC_SAMPLEUS 50 ' Sample time in uS before A/D conversion is started CMCON0 = 7 'Comparators off ADCON0 = %00000000 ANSEL = %00000000 INTCON = 0 'INTERRUPTS off OSCCON = %01110000 '8 Mhz TRISIO = %000100 GPIO = %00000100 OPTION_REG = %00101000 A VAR byte TMR0= 0 ' clear count low GPIO.4 low GPIO.5 input GPIO.2 A=0 main: 'You'll probably want to "see" what's happening on GPIO.2 once you get this part done I reckon while TMR0 <= 5 wend TMR0= 0 ' clear count A= A+1 pulsout GPIO.5, 100 '500 uS short pulses pin 2 if A = 4 then GOSUB largepulse ' lets the four pulses go first then jumps to "large pulse" GOTO main ' GOTO here instead largepulse: pulsout GPIO.4, 100 '500 uS big pulse pin 3 A=0 return




Bookmarks