Another way
Code:
'************************************************* ****************
'* Name : Analogbargraph1(16F628A).BAS *
'* Author : M.David *
'* Notice : Copyright (c) 2008 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 28.02.2008 *
'* Version : 1.0 *
'* Notes : needs 12F675 for Lambdatesting device and LCD 1X16 *
'* : input 0.1 - 1.1 Volts in GPIO.0 *
'* : needs ADCserout(12F675).bas *
' 569 Lines
'************************************************* ****************
'
' DEFINITIONS
@ __config _XT_OSC & _WDT_ON & _MCLRE_ON & _LVP_OFF & _CP_OFF
Include "modedefs.bas"
'CMCON=%00000111
DEFINE OSC 4
NbPatterns var Byte
Uin var word
B0 VAR word ' Cnt is a word variable
inputData var word ' variable to receive data into
' START OF MAIN PROGRAM
'
CMCON = 7 ' RA0-RA3 are digital I/O
TRISA = 0 ' PORT A is output
TRISB = 1 ' RB0 is Input others output
main:
Serin PORTB.0,N2400,B0
B0 = 100 * B0
Uin = B0 / 207
bargraph:
IF Uin < 10 THEN LCDOUT $FE,1,"TOO LOW" : GOTO Show
IF Uin > 110 THEN LCDOUT $FE,1,"TOO HIGH" : GOTO Show
LOOKDOWN2 Uin , < [ 11,16,20,25,30,35,44,54,63], NbPatterns
LCDOUT $FE, 1, REP 255\ NbPatterns
IF Uin > 62 THEN
LOOKDOWN2 Uin , < [ 63,73,82,87,92,97,101,106,111], NbPatterns
LCDOUT $FE, 1, REP 255\ 8
LCDOUT $FE, $C0, REP 255\ NbPatterns
ENDIF
Show:
Pause 5
goto main
END ' End of program
569 Words ...
Alain
Bookmarks