16F877 and 4094 please help


Results 1 to 19 of 19

Threaded View

  1. #8
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    But does not function the circuit,When I have in 3 inputs 0, (ΡΒ0=0,ΡΒ1=0,ΡΒ2=0)
    Do not turn on 3 led but always only 1
    To have also two or three leds on at the same time you have to add more code (in red):


    Code:
    INCLUDE "modedefs.bas"
    DEFINE SHIFT_PAUSEUS 100
    
    
            
            TRISB = %00000111 
            
            alarm var BYTE
            Flag   var BYTE
    '****************************************************************
            symbol clock=portc.4
            symbol data_pin=portc.2
            symbol strb=PORTc.3
    '****************************************************************
            alarm=0
            Flag = 0
    
    start:
    Pause 10
    
    IF PORTB.0=0 THEN
    alarm=%10000000
    Flag=1   
    ENDIF
    
    IF PORTB.1=0 THEN
    alarm=%01000000
    Flag = 1   
    ENDIF
    	   
    IF PORTB.2=0 THEN
    alarm=%00100000
    Flag = 1   
    ENDIF
     
    IF PORTB.0=0  and PORTB.1 =0 THEN
    alarm=%11000000
    Flag=1   
    ENDIF
    
    IF PORTB.1=0  and PORTB.2 =0 THEN
    alarm=%01100000
    Flag=1   
    ENDIF
    
    IF PORTB.0=0  and PORTB.2 =0 THEN
    alarm=%10100000
    Flag=1   
    ENDIF
    
    
    IF PORTB.0=0  and PORTB.1 =0 AND PORTB.2 = 0 THEN
    alarm=%11100000
    Flag=1   
    ENDIF
    
    If Flag = 1 Then  gosub print
           goto start      
    
    print:
            
            ShiftOut data_pin,clock,0,[alarm]                              
            strb = 1  : PAUSEUS 100 :  STRB = 0
            Flag = 0
    return
    
    end
    Very likely you will need also a reset, in this case add the following code:
    Code:
    IF PORTB.0=1  and PORTB.1 =1 AND PORTB.2 = 1 and alarm>0 THEN
    alarm=%00000000
    Flag=1   
    ENDIF

    You can also try the following code which is a lot shorter and should work as well.
    Code:
    INCLUDE "modedefs.bas"
    DEFINE SHIFT_PAUSEUS 100
    
    
            
            TRISB = %00000111 
            
            Alarm   var BYTE
            Flag    var BYTE
            B0      var Byte
    '****************************************************************
            symbol clock=portc.4
            symbol data_pin=portc.2
            symbol strb=PORTc.3
    '****************************************************************
    alarm = 0
    Flag = 0
    B0 = 0
    
    start:
    
    Pause 10
    
    B0 = PortB & %00000111
    Alarm = (7 - B0) * 32
    If Alarm <> Flag then gosub Print
    goto start      
    
    Print:
    
    ShiftOut data_pin,clock,0,[alarm]                              
    strb = 1  : PAUSEUS 100 :  STRB = 0
    Flag = Alarm
    return
    
    end
    Al.
    Last edited by aratti; - 19th October 2009 at 09:30.
    All progress began with an idea

Similar Threads

  1. 4094 Please Help
    By dovegroup in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 10th September 2009, 13:11

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts