hola alguien me puede ayudar con mi codigo esta en bascom no se me apaga al iniciar el turnero la flecha ya que las flechas funcionan cuando el displays comienza a contar los tunos y junto a esto parparea un led de timbre aca les dejo la programacion:
esta simulado en proteus
aqui esta el circuitoVer el archivo adjunto cc.bmp
Código:
$regfile = "m8def.dat"
$crystal = 8000000
'$baud = 9600
'******************* DipSwitch ***********************************************
Ddrc.0 = 0
Portc.0 = 1
Ddrc.1 = 0
Portc.1 = 1
Ddrc.2 = 0
Portc.2 = 1
Ddrc.3 = 0
Portc.3 = 1
Dipswitch Alias Pinc.0
'******************* Flecha Derecha ******************************************
Ddrc.4 = 1
Portc.4 = 0
Flechaderecha Alias Portc.4
'******************* Flecha Derecha ******************************************
Ddrc.5 = 1
Portc.5 = 0
Flechaizquierda Alias Portc.5
'******************* Speaker *************************************************
Ddrd.0 = 1
Portd.0 = 0
Speaker Alias Portd.0
'******************* Habilitar Display ***************************************
Ddrc.4 = 1
Portc.4 = 0
Habilita Alias Portc.4
'******************* Botones *************************************************
Ddrb.0 = 0
Portb.0 = 1
Boton1 Alias Pinb.0
Ddrb.1 = 0
Portb.1 = 1
Boton2 Alias Pinb.1
Ddrb.2 = 0
Portb.2 = 1
Boton3 Alias Pinb.2
Ddrb.3 = 0
Portb.3 = 1
Boton4 Alias Pinb.3
Ddrb.4 = 0
Portb.4 = 1
Boton5 Alias Pinb.4
Ddrb.5 = 0
Portb.5 = 1
Boton6 Alias Pinb.5
Ddrb.6 = 0
Portb.6 = 1
Boton7 Alias Pinb.6
Ddrb.7 = 0
Portb.7 = 1
Boton8 Alias Pinb.7
'******************* Display *************************************************
Ddrd.1 = 1
Portd.1 = 0
Ddrd.2 = 1
Portd.2 = 0
Ddrd.3 = 1
Portd.3 = 0
Ddrd.4 = 1
Portd.4 = 0
Ddrd.5 = 1
Portd.5 = 0
Ddrd.6 = 1
Portd.6 = 0
Ddrd.7 = 1
Portd.7 = 0
Ddrd.6 = 1
Portd.6 = 0
Const Delay1 = 80 'Delay 1
Const Delay10 = 10 'Delay 10
Const Delay500 = 500 'Delay 500
Dim Ram(4) As Byte
Dim A As Byte
Dim B As Word
Dim C As Word
Dim D As Byte
Dim F As Byte
Dim H As Word
Dim I As Byte
Dim W As Word
Dim X As Byte
Dim Y As Byte
Dim Z As Byte
Dim Unidades1 As Byte
Dim Pulsa1 As Bit
Dim Pulsa2 As Bit
Dim Pulsa3 As Bit
Dim Pulsa4 As Bit
Dim Pulsa5 As Bit
Dim Pulsa6 As Bit
Dim Pulsa7 As Bit
Dim Pulsa8 As Bit
Dim Pulsa9 As Bit
Dim Pulsa10 As Bit
Dim Pulsa11 As Bit
Dim Pulsa12 As Bit
Dim Pulses As Word , Periods As Word
'Pulses = 10 : Periods = 1 'set variables
Pulses = 1000 : Periods = 100
Unidades1 = 0
Habilita = 1
Gosub Display1
Do
If Boton1 = 0 Then
Waitms Delay1
While Boton1 = 0
Wend
Waitms Delay1
Unidades1 = 1
Gosub Dips
Gosub Display1
Gosub Sonido
End If
If Boton2 = 0 Then
Waitms Delay1
While Boton2 = 0
Wend
Waitms Delay1
Unidades1 = 2
Gosub Dips
Gosub Display1
Gosub Sonido
End If
If Boton3 = 0 Then
Waitms Delay1
While Boton3 = 0
Wend
Waitms Delay1
Unidades1 = 3
Gosub Dips
Gosub Display1
Gosub Sonido
End If
If Boton4 = 0 Then
Waitms Delay1
While Boton4 = 0
Wend
Waitms Delay1
Unidades1 = 4
Gosub Dips
Gosub Display1
Gosub Sonido
End If
If Boton5 = 0 Then
Waitms Delay1
While Boton5 = 0
Wend
Waitms Delay1
Unidades1 = 5
Gosub Dips
Gosub Display1
Gosub Sonido
End If
If Boton6 = 0 Then
Waitms Delay1
While Boton6 = 0
Wend
Waitms Delay1
Unidades1 = 6
Gosub Dips
Gosub Display1
Gosub Sonido
End If
If Boton7 = 0 Then
Waitms Delay1
While Boton7 = 0
Wend
Waitms Delay1
Unidades1 = 7
Gosub Dips
Gosub Display1
Gosub Sonido
End If
If Boton8 = 0 Then
Waitms Delay1
While Boton8 = 0
Wend
Waitms Delay1
Unidades1 = 8
Gosub Dips
Gosub Display1
Gosub Sonido
End If
Loop
Display1:
Ram(1) = Lookup(unidades1 , Numeros)
Portd.1 = Ram(1).1
Portd.2 = Ram(1).2
Portd.3 = Ram(1).3
Portd.4 = Ram(1).4
Portd.5 = Ram(1).5
Portd.6 = Ram(1).6
Portd.7 = Ram(1).0
Return
'******************************************************************************
Sonido:
Sound Speaker , 65 , 1000 'C2(1/16)
For I = 0 To 12
Gosub Display1
Next I 'P(1/16)
Sound Speaker , 87 , 954 'F2(1/16)
For I = 0 To 12
Gosub Display1
Next I 'P(1/16)
Sound Speaker , 98 , 850 'G2(1/16)
For I = 0 To 12
Gosub Display1
Next I
Return
'******************************************************************************
Dips:
C = Pinc
C = C And &B11110000
If C < Unidades1 Then
Flechaderecha = 0
Flechaizquierda = 1
Else
Flechaderecha = 1
Flechaizquierda = 0
End If
Return
Numeros:
Data 191 , 134 , 219 , 207 , 230 , 237 , 253,135,255,239
esta simulado en proteus
aqui esta el circuitoVer el archivo adjunto cc.bmp
Última edición por un moderador: