RELOJ PARLANTE
PIC 16F871
Y como no, para poder descargar el HEX al PIC utilizo nada mas y nada
menos que mi GTP USB + con el winpic800 del maestro SISCO, un
programador muy rápido y soporta gran cantidad de dispositivos, haciendo que
GTP USB +
ISD25120
LCD 16x2
Este es un dispositivo muy útil que en nuestro caso nos servirá para visualizar
la hora y la fecha como se muestra en la imagen
RTC DS1307
Estos a mi parecer son los dispositivos mas importantes, ya que los otros
como el micrófono, parlante y teclado son muy conocidos.
Y con esta breve introducción creo que estamos listos para empezar a
hablar de lo que nos interesa que es el Reloj Parlante.
1 2 3
FIG 1.
4
FIG 2.
21 "SON"
22 "LAS"
23 "AM"
24 "PM"
25 "MINUTOS"
Una ves que se han grabado esos mensajes, el reloj esta listo para
funcionar.
CODIGO
'PIC a utilizar
DEVICE 16F871
'Frecuencia
XTAL 4
'declaracion del LCD
DECLARE LCD_TYPE 0
DECLARE LCD_DTPIN PORTC.4
DECLARE LCD_ENPIN PORTC.2
DECLARE LCD_RSPIN PORTC.3
DECLARE LCD_INTERFACE 4
DECLARE LCD_LINES 2
'teclado matricial
DECLARE KEYPAD_PORT PORTD
SYMBOL PR = PORTE.2
SYMBOL EOM = PORTC.0
TRISA = 0
DELAYMS 500
cont=0
cont1=0
CLS
PORTA = 0
HIGH CE
GOSUB grabar_RTC
'Programa principal
inicio:
GOSUB leer_RTC
tecla = INKEY
PRINT AT 1,12,DEC2 cont,"-"
PRINT AT 1,15,DEC2 cont1,
SELECT CASE tecla
CASE 0: 'para grabar
GOSUB antirebote 'antirebote de tecla
GOSUB grabar
CASE 1: 'para reproducir el msg seleccionado
GOSUB antirebote 'antirebote de tecla
GOSUB reproducir
CASE 2
cont1=cont1+1
GOSUB antirebote 'antirebote de tecla
CASE 3
cont1=cont1-1
IF cont1<0 THEN
cont1=0
ENDIF
GOSUB antirebote 'antirebote de tecla
CASE 5
GOSUB reproducir_HORA
CASE 6
cont=cont+1
GOSUB antirebote
CASE 7
cont=cont-1
IF cont<0 THEN
cont=0
ENDIF
GOSUB antirebote
CASE 8
GOSUB antirebote
GOSUB reproducir_HORA
ENDSELECT
GOTO inicio
'Subrutinas
grabar:
PORTA=cont
HIGH PD: DELAYMS 10
LOW PR:LOW PD:HIGH CE
' --------------------------------------------------------
reproducir:
PORTA=cont1
PRINT AT 2,1, "REPRODUCIR"
HIGH PR: LOW PD: LOW CE
WHILE EOM <> 0 'buble para esperar el bajo en EOM para saber
WEND 'cuando ha finalizado el mensaje
HIGH CE
PRINT AT 2,1, " "
RETURN
' --------------------------------------------------------
antirebote:
WHILE tecla<>16 'antirebote
tecla=INKEY
WEND
RETURN
' --------------------------------------------------------
grabar_RTC:
'---------------------------------------------------------
leer_RTC:
BUSIN %11010000,0,[segu]
BUSIN %11010000,1,[minu]
BUSIN %11010000,2,[hora]
BUSIN %11010000,3,[diaS]
BUSIN %11010000,4,[diaF]
BUSIN %11010000,5,[mes]
BUSIN %11010000,6,[anio]
reproducir_HORA:
GOSUB leer_RTC
'--------------- son
cont1=21
GOSUB reproducir
DELAYMS 100
'--------------- las
cont1=22
GOSUB reproducir
DELAYMS 100
'--------------- HORAS
IF hora>12 THEN
hora=hora-12
horario=1
ELSE
horario=0
ENDIF
cont1=hora
GOSUB reproducir
DELAYMS 100
'--------------- AM/PM
IF horario=1 THEN
cont1=24
ELSE
cont1=23
ENDIF
GOSUB reproducir
DELAYMS 100
'--------------- Y
cont1=20
GOSUB reproducir
DELAYMS 100
'--------------- MINUTOS
'-------------------
minu1=DIG minu, 0
cont1=minu1
GOSUB reproducir
ENDIF
ENDSELECT
DELAYMS 100
cont1=25
GOSUB reproducir
RETURN
END