Autor Tema: problema contador de puntos  (Leído 1272 veces)

0 Usuarios y 1 Visitante están viendo este tema.

Desconectado aenema

  • PIC10
  • *
  • Mensajes: 2
problema contador de puntos
« en: 22 de Febrero de 2012, 10:05:27 »
en el programa siguiente, muestra una sumatoria mostrada en lcd siempre y cuanto portb > %11. en este caso la sumatoria se hace correctamente y se muesta en la lcd... el problema opcurre cuando se realiza la captacion de PORTA no hace nadaaaaaaaaa no la suma y no muestra en la lcd  "donde dice regi_rojo= porta.0 + etc"" esa parte no logro q me de  de antemano gracias por mirar

program contador
  ' Declarations section
  DIM LCD_RS AS SBIT AT RD4_BIT                   'CONFIGURACION PARA LA
      LCD_EN AS SBIT AT RD5_BIT                   'PANTALLA LCD POR EL PUERTO D
      LCD_D4 AS SBIT AT RD0_BIT
      LCD_D5 AS SBIT AT RD1_BIT
      LCD_D6 AS SBIT AT RD2_BIT
      LCD_D7 AS SBIT AT RD3_BIT

      LCD_RS_DIRECTION AS SBIT AT TRISD4_BIT
      LCD_EN_DIRECTION AS SBIT AT TRISD5_BIT
      LCD_D4_DIRECTION AS SBIT AT TRISD0_BIT
      LCD_D5_DIRECTION AS SBIT AT TRISD1_BIT
      LCD_D6_DIRECTION AS SBIT AT TRISD2_BIT
      LCD_D7_DIRECTION AS SBIT AT TRISD3_BIT
      dim contan, contar as word
      dim regi_negro as word
      dim regi_rojo  as word
      dim text       as char[3]
      dim ch, adc_rd as word
      dim cont       as byte [20]
      dim txt1       as char[16]
          txt2       as char[9]
          txt3       as char[9]
          u          as byte
          i          AS BYTE
          a          as  byte
          o          as  byte
      ANSEL          AS BYTE
      ANSELH         AS WORD
     
CONF:
    ANSEL = 0                 ' Todos los pines de E/S se configuran como digitales
    ANSELH = 0
    TRISB  = %00001111         'PUERTO b COMO entranda de registro negro
    PORTB  = %00001111
    TRISA  = %00001111         'PUERTO a COMO entranda de registro rojo
    PORTA  = %00001111
    TRISD  = 0                 'PUERTO D COMO SALIDA
    PORTD  = 0
    PORTC  = %00000111              'PUERTO C COMO COMO ENTRANDAS
    TRISC  = %00000111
    txt1 = "NEGRO"
    txt2 = "ROJO"
    txt3 = "0"


    MAIN:
                      ' Inicializamos el módulo UART a 2400 bps.

    LCD_INIT()                                  'INICIALIZAR LCD
    LCD_CMD(_LCD_CLEAR)                         'BORRAR DISPLAY
    LCD_CMD(_LCD_CURSOR_OFF)
     LCD_OUT(1,5,"PRECIONE")                                        'MENSAJE INICIAL
    LCD_OUT(2,6,"INICIO")
                                                                               ' Bucle infinito
                                                                   'APAGAR CURSOR
while 1                                          'SISTEMA DE

   if PORTC.0 = 1 then                                              ' Si se presiona el pulsador 1
   delay_ms(50)
    PORTB.0 = 1
    LCD_CMD(_LCD_CURSOR_OFF)
    LCD_CMD(_LCD_CLEAR)
    Lcd_Out(1,1,txt1)
    Lcd_Out(2,1,txt2)
    Lcd_Out(1,9,"PTS:")
    Lcd_Out(2,9,"PTS:")
    Lcd_Out(1,13,txt3)
    Lcd_Out(2,13,txt3)
    DELAY_MS(1500)
     End if

     contar=0
     contan=0
     

    regi_negro = portb.0 + portb.1+ portb.2 + portb.3
    if regi_negro > %10 then
    i= i+1
    if  i<10 then
    Lcd_Chr(1,14,48+i)
    DELAY_MS(600)
    end if
    if i=10 then
    lcd_Out(1,14,txt3)
    u=u+1
    Lcd_Chr(1,13,48+u)
    DELAY_MS(600)
    contan= contan +1
    end if
    end if

    regi_rojo = porta.0 + porta.1+ porta.2 + porta.3
    if regi_rojo > %10 then
    o= o+1
    if o<10 then
    Lcd_Chr(2,14,48+o)
    DELAY_MS(600)
    end if
    if o=10 then
    lcd_Out(2,14,txt3)
    a=a+1
    Lcd_Chr(2,13,48+a)
    DELAY_MS(600)
    end if
    end if
     contar= contar +1


    if portc.2 = 1 then
    if   contar > contan then
    porta.4 =1
    end if
    if  contan > contar then
    porta.5 =1
    end if
    end if
    if portc.1 = 1 then
    delay_ms(100)
    porta.4=0
    porta.5=0
    contar   =0
    contan =0
    i=0
    u=0
    o=0
    a=0
    goto main
    end if
   wend



  END.