I have the below code.
My problem is that the output RA2 and RA3 not change if (value - P2) >= 1 and (value1 - P3) >= 1.
What wrong i have made;
Code:'************************************************************************ @ DEVICE PIC16F88, MCLR_OFF ' Master Clear Options (Internal) '******************************** LCD *********************************** DEFINE LCD_DREG PORTB ' Selection of the port B DEFINE LCD_DBIT 4 DEFINE LCD_RSREG PORTB ' RS on port RB2 DEFINE LCD_RSBIT 2 DEFINE LCD_EREG PORTB ' E on port RB3 DEFINE LCD_EBIT 3 DEFINE LCD_BITS 4 ' Mode 4 bits DEFINE LCD_LINES 2 ' LCD 2 lines of 16 caracter '****************************Define ADCIN parameters ********************** DEFINE ADC_BITS 8 ' Set number of bits in result DEFINE ADC_CLOCK 3 ' Set clock source (3=rc) DEFINE ADC_SAMPLEUS 50 ' Set sampling time in uS '*********************************** VARIABLES ********************* TRISA = %00000011 CMCON = 7 ' PortA = digital I/O ANSEL = %00000011 ' Will set RA0-RA1 as analog and all others as digital ADCON0 = %11100001 ' Configure and turn on A/D Module ADCON1 = %00000010 ' Set PORTA analog and RIGHT justify result adval var Byte ' Create adval to store result value var Word adval1 var Byte ' Create adval1 to store result value1 var Word P VAR Byte P1 VAR Byte P2 var Word P3 var Word PAUSE 500 LCDOUT $FE,1," VOLTMETER " PAUSE 1000 P2 = P*50/255 P3 = P1*50/255 P2=28 P3=10 NORMAL: ADCIN 0, adval ' Read channel 0 to adval value = adval*50/255 ADCIN 1, adval1 ' Read channel 1 to adval1 value1 = adval1*50/255 LCDOUT $FE,1,"VOLT : ",DEC2 value LCDOUT $FE,$C0,"AMPER: ",DEC2 value1 if (value - P2) >= 1 then PORTA.2=1 else PORTA.2=0 endif if (value1 - P3) >= 1 then PORTA.3=1 else PORTA.3=0 endif PAUSE 500 GOTO NORMAL




Bookmarks