'--------Title-------- ' File......array2.pbp ' Started....4/23/08 ' Microcontroller used: Microchip Technology 16F88 ' microchip.com ' PBPro Code, micro-Engineering Labs, Inc. ' melabs.com '--------Program Desciption-------- ' This program compares the elements of a 7 element array, x[c0]. ' The first LCD row displays the values of x[c0] and the second ' LCD row displays the maximum value of x[c0], x_max. '------------Variables------------- c0 VAR BYTE 'Byte for counter, c0 x var byte[7] 'BYTE for each of 7 elements 'of array x[] x_max var byte 'BYTE for maximum value of x_max '----------Initialization---------- ANSEL = 0 'Configure all pins to digital 'operation since not using ADC '(Analog to Digital Converter) OSCCON = $60 'Sets the internal oscillator in the '16F88 to 4 MHz '-------------Main Code------------ pause 1000 '1 second PAUSE to allow LCD to setup x[0] = 2 'Set element values of array x[] x[1] = 145 x[2] = 56 x[3] = 244 x[4] = 24 x[5] = 248 x[6] = 247 x_max = 0 'Set initial value for x_max for c0 = 0 to 6 'FOR..NEXT loop to compare values of x[c0] if x[c0] > x_max then x_max = x[c0] 'Makes comparison to determine maximum 'value of x[c0] lcdout $FE,1, #x[c0] 'Display current value of x[c0] lcdout $FE,$C0, #x_max 'On the second row of the LCD screen, 'display maximum value of x[c0], x_max. pause 1500 next c0 'Proceed to NEXT value of c0 until c0 = 6. end