[code'****************************************************************
'* Name : UNTITLED.BAS *
'* Author : [select VIEW...EDITOR OPTIONS] *
'* Notice : Copyright (c) 2014 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 23/03/2014 *
'* Version : 1.0 *
'* Notes : *
'* : *
'****************************************************************
Device 16F877A
XTAL = 4
' LCD pin Configuracion
LCD_TYPE = 0
LCD_LINES = 4
LCD_DTPIN = PORTB.4
LCD_RSPIN = PORTB.2
LCD_ENPIN = PORTB.3
LCD_INTERFACE = 4
'***************************************************************************************
Cls ' Clear LCD
ALL_DIGITAL = True ' Set ports to digital mode
Clear
'******************************************************************************************
'********************* SIMBOLOS DEL PROGRAMA *********************************************
'******************************************************************************************
Symbol SDA = PORTC.5 ' Alias the SDA (Data) line
Symbol SCL = PORTC.4 ' Alias the SSL (Clock) line
Symbol Escribe = %01111000
Symbol Lee = %01111001
'*****************************************************************
Dim N As Byte
Dim A As Byte
Dim Ylcd As Byte
Dim Numero As DWord 'Byte
Dim OldNumero As DWord 'Byte
Dim Numeros As Byte
Dim Multi As Byte
Dim Direccion As Byte
'*****************************************************************
'****************INICIO*******************************************
'*****************************************************************
Inicio:
Ylcd = 17
Multi = 0
OldNumero = 0
Direccion = 0
EWrite Direccion,[OldNumero]
Numero = ERead 40
'****************************************************************
Print At 1,1,Dec Numero
DelayMS 2000
Cls
Numero = 0
Print At 2,1,"*-Borra #-Enter"
'01234568
A = %11110000
'**************************** TECLADO ****************************
Teclado:
A = %11110000
I2COUT SDA, SCL, Lee , [ A ]
I2Cin SDA, SCL, Escribe,[ N ]
'****************************************************************
If N=224 Then '<----------------------
A= %00000111 '
I2COUT SDA, SCL, Lee , [ A ] '
I2Cin SDA, SCL, Escribe,[ N ] '
'
If N=6 Then '
Numeros = 1 '
GoSub Numeraco '
EndIf '
'
If N=5 Then '
Numeros = 4 '
GoSub Numeraco '
EndIf '
'
If N=3 Then '
Numeros = 7 '
GoSub Numeraco '
EndIf '
'
If N=7 Then '(*)
GoSub Numeraco
EndIf '
'
EndIf '<------------------------------
'****************************************************************
If N=208 Then'<---------------------
A= %00001011 '
I2COUT SDA, SCL, Lee , [ A ] '
I2Cin SDA, SCL, Escribe,[ N ] '
'
If N=10 Then '
Numeros = 2 '
GoSub Numeraco '
EndIf '
'
If N=9 Then '
Numeros = 5 '
GoSub Numeraco '
EndIf '
'
If N=11 Then '
Numeros = 8 '
GoSub Numeraco '
EndIf '
'
If N=3 Then '
Numeros = 0 '
GoSub Numeraco '
EndIf '
'
EndIf '<----------------------------'
'****************************************************************
If N=176 Then'<----------------------
A= %00001101 '
I2COUT SDA, SCL, Lee , [ A ] '
I2Cin SDA, SCL, Escribe,[ N ] '
' '
If N=12 Then '
Numeros = 3 '
GoSub Numeraco '
EndIf '
' '
If N=13 Then '
Numeros = 6 '
GoSub Numeraco '
EndIf '
'
If N=9 Then '
Numeros = 9 '
GoSub Numeraco '
EndIf '
If N=5 Then '(#) '
Cls '
Print At 1,1,"Meto ",Dec Numero'
EWrite 40,[Numero]
DelayMS 1500 '
Cls '
GoTo Inicio '
EndIf '
'
EndIf '<-----------------------------
'****************************************************************
DelayMS 200
GoTo Teclado
'****************************************************************
'****************************************************************
'****************************************************************
Numeraco:
If N=7 Then
Dec Multi
If Multi = 255 Then
Multi = 0
Return
EndIf
Direccion = Direccion -4 ' dword 4bit,
OldNumero = ERead Direccion '
Numero = OldNumero
Inc Ylcd
Print At 1,8," "
Print At 1,Ylcd,Dec Numero
EWrite Direccion,[OldNumero]
Return
EndIf
Inc Multi
If Multi >= 10 Then
Multi = 10
GoTo Salgo ' return de numeraco
EndIf
Numero = OldNumero * 10
Numero= Numero + Numeros
OldNumero = Numero
Direccion = Direccion + 4 ' dword 4bit,
EWrite Direccion,[OldNumero]
Dec Ylcd
Print At 1,Ylcd,Dec Numero
Salgo:
Return
'*****************************************************************
End]