Today 03:53
Forum: USB
Starter: towlerg
Views: 12
Replies: 0
Today 03:19
Forum: USB Module
Starter: MTH
Views: 93
Replies: 10
Yesterday 14:32
Forum: Wish List / Product Feedback
Starter: Latex
Views: 20
Replies: 0
+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Junior Member kishorbodake's Avatar
    Join Date
    Aug 2016
    Posts
    4
    Thumbs Up
    Received: 0
    Given: 0
    Total Downloaded
    31.56 MB

    0 Not allowed!

    Default multi action led running light using pic16f628A

    delay variable switch PORTA.5 not working .
    please help me







    '************************************************* ***************
    Device = 16F628A
    Reminders = FALSE
    Config XT_OSC ,_ ' External Oscillator
    WDT_OFF,_ 'Disable watch dog timer
    PWRTE_ON,_ ' Enable power up timer
    MCLRE_OFF,_ ' Disable MCLR pin
    BODEN_ON,_ ' Enable brown out detect
    LVP_OFF,_ ' Disable Low voltage programming mode
    DATA_CP_OFF,_ ' Disable data code protect
    CP_OFF ' Disable code protect
    Reminders = TRUE
    Watchdog = OFF

    Declare Xtal = 4

    '**************** CONFIGURATION *************************************

    CMCON = 7 ' PortA = digital I/O
    Declare All_Digital = TRUE
    VRCON = 0 ' comparators off

    'Symbol key = PORTA.2
    'Symbol key1 = PORTA.5

    Dim x As Word
    'Dim y As Word
    Dim a As Word

    Dim i As Byte
    Dim i1 As Byte
    Dim i2 As Byte
    Dim i3 As Byte
    Dim i4 As Byte


    TRISA = 0b00100100
    TRISB = 0b00000000

    'OPTION_REG.7 = 0

    x = 0
    y = 200



    loop:
    If PORTA.5 = 0 Then
    x = x +50
    DelayMS 10
    EndIf


    If PORTA.2 = 0 Then
    Next i
    EndIf



    For i = 0 To 10
    DelayMS x
    PORTA = %00001001
    PORTB = %01010101
    DelayMS x
    PORTA = %00010010
    PORTB = %10101010
    Next i
    For i = 0 To 10
    DelayMS x
    PORTA = %00011000
    PORTB = %00001111
    DelayMS x
    PORTA = %00000011
    PORTB = %11110000
    Next i
    For i = 0 To 5
    DelayMS x
    PORTA = %00011000
    PORTB = %00001111
    DelayMS x
    PORTA = %00010000
    PORTB = %00011111
    DelayMS x
    PORTA = %00000000
    PORTB = %00111111
    DelayMS x
    PORTB = %01111110
    DelayMS x
    PORTB = %11111100
    DelayMS x
    PORTB = %11111000
    PORTA = %00000001
    DelayMS x
    PORTB = %11110000
    PORTA = %00000011

    DelayMS x
    PORTA = %00000001
    PORTB = %11111000
    DelayMS x
    PORTA = %00000000
    PORTB = %11111100
    DelayMS x
    PORTB = %01111110
    DelayMS x
    PORTB = %00111111
    DelayMS x
    PORTB = %00011111
    PORTA = %00010000
    Next i
    For i = 0 To 5
    DelayMS x
    PORTA = %00000010
    DelayMS x
    PORTB = %00000000
    PORTA = %00000011
    DelayMS x
    PORTB = %10000000
    DelayMS x
    PORTB = %11000000
    DelayMS x
    PORTB = %11100000
    DelayMS x
    PORTB = %11110000
    DelayMS x
    PORTB = %11111000
    DelayMS x
    PORTB = %11111100
    DelayMS x
    PORTB = %11111110
    DelayMS x
    PORTB = %11111111
    DelayMS x
    PORTA = %00010011
    DelayMS x
    PORTA = %00011011
    '''''''''''''''''
    '''''''''''''''''
    DelayMS x
    PORTA = %00011001
    DelayMS x
    PORTA = %00011000
    DelayMS x
    PORTB = %01111111
    DelayMS x
    PORTB = %00111111
    DelayMS x
    PORTB = %00011111
    DelayMS x
    PORTB = %00001111
    DelayMS x
    PORTB = %00000111
    DelayMS x
    PORTB = %00000011
    DelayMS x
    PORTB = %00000001
    DelayMS x
    PORTB = %00000000
    DelayMS x
    PORTA = %00001000
    DelayMS x
    PORTA = %00000000
    Next i


    GoTo loop

  2. #2
    Prolific Poster normnet's Avatar
    Join Date
    Jul 2004
    Posts
    2,109
    Thumbs Up
    Received: 82
    Given: 24
    Total Downloaded
    765.90 MB

    0 Not allowed!

    Default Re: multi action led running light using pic16f628A

    Quote Originally Posted by kishorbodake View Post
    delay variable switch PORTA.5 not working .
    please help me

    As per data sheet PORTA.5 when MCLRE_OFF is a digital input only not a bidirectional I/O pin:
    Code:
    MCLRE: RA5/MCLR/VPP Pin Function Select bit
    1 = RA5/MCLR/VPP pin function is MCLR
    0 = RA5/MCLR/VPP pin function is digital Input, MCLR internally tied to VDD

  3. #3
    Prolific Poster normnet's Avatar
    Join Date
    Jul 2004
    Posts
    2,109
    Thumbs Up
    Received: 82
    Given: 24
    Total Downloaded
    765.90 MB

    1 Not allowed!

    Default Re: multi action led running light using pic16f628A

    If you wish to use PORTA.5 as an input you might try setting it as such in the loop pre use as setting PORTA = %xxxxxxxx may be automatically changing the port to an output although technically A.5 isn't capable of output.

    Also I use TRISA = %00100100 in place of TRISA = 0b00100100 however this forum sometimes displays a percentage sign as other character.
    Last edited by normnet; 2nd September 2016 at 04:53.

  4. #4
    Prolific Poster normnet's Avatar
    Join Date
    Jul 2004
    Posts
    2,109
    Thumbs Up
    Received: 82
    Given: 24
    Total Downloaded
    765.90 MB

    0 Not allowed!

    Default Re: multi action led running light using pic16f628A

    Quote Originally Posted by normnet View Post
    If you wish to use PORTA.5 as an input you might try setting it as such in the loop pre use as setting PORTA = %xxxxxxxx may be automatically changing the port to an output although technically A.5 isn't capable of output.

    Also I use TRISA = %00100100 in place of TRISA = 0b00100100 however this forum sometimes displays a percentage sign as other character.
    kishorbodake
    Thanks for the thumbs up!
    Was the fix setting PORA.5 as an input in the loop or use of a percentage sign in place of 0b?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. multi action led running light using pic16f628A
    By kishorbodake in forum Projects discussion
    Replies: 4
    Last Post: 1st September 2016, 21:33
  2. Blinking Led while main program is running
    By Engineer in forum Projects discussion
    Replies: 5
    Last Post: 30th April 2013, 11:04
  3. Running led sign
    By Roshan in forum Proton Plus Compiler v3
    Replies: 8
    Last Post: 31st January 2011, 21:54
  4. LED Light
    By fanie in forum The Lounge
    Replies: 1
    Last Post: 20th July 2009, 11:56
  5. Led as a light sensor
    By Tim in forum The Lounge
    Replies: 14
    Last Post: 23rd June 2008, 08:22

Tags for this Thread

Posting Permissions

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