Need help in code


Closed Thread
Results 1 to 23 of 23

Hybrid View

  1. #1

    Red face Need help in code

    Hi,

    Im traing to macke a code in PBP for a 18f877a (to add more things in futer) and im very new at this sow i can not macke one that works well one month traing .

    I need 2 condictions to light the led (2 push buttons comands or input)
    first only goto to secund if on (input=1)
    secund waits intill is of (input=0)
    then after 40s light the led for 3s
    then off the led and goto to first condiction.


    Thanks in advance and sory for my bad Inglish.

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,651


    Did you find this post helpful? Yes | No

    Wink

    Hi, Camolas

    Welcome here ... and do not be sorry for your English.

    YOU made this effort ... some don't dare.

    Back to our subject, Her you won't find "already cooked" code ... except if you do a search over the forums ... for existing applications.


    The habit is : YOU try to make something run ( by the way learn how the processor works , and which PicBasic commands you have to use ....) - and then , we help you.


    The first thing you'll have to do is CONFIGURE your processor:

    - Which will be the Inputs and Outputs ?

    - How to disable Unwanted features like comparators and ADC ... that could interfere with PORTs

    for that ... the '877 is not the simplest ! ... would you own an old 16F84 ??? ( not compulsory - do not buy one ... but would help you a lot ! )


    And, once that done, begin to translate your " text" program into successive elementary PbP ( PicbasicPro ...) commands.

    So, you'll need :

    1) the 16F877a Datasheet ( from Microchip site )
    2) the PicbasicPro Manual corresponding to your release ( which one ? 2.50 ? )
    3) some paper sheets to note the 877 registers and data for the config.
    4) a good pencil and rubber
    5) a HUGE coffee cup (hot is better ...)
    6) LOTs of patience

    ...

    Welcome aboard and read you soon.

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  3. #3
    Join Date
    Mar 2008
    Location
    Texas, USA
    Posts
    114


    Did you find this post helpful? Yes | No

    Default

    Alain, you forgot one...

    7) A swear jar

    You too can retire rich!

    Camolas, in a month's time you should have some code. Post it so we can take a look at it.
    No, I'm not Superman, but I did stay at a Holiday Inn Express last night!

  4. #4


    Did you find this post helpful? Yes | No

    Default

    Hi,

    Thanks for the starting hellp

    PicbasicPro 2.50





    My code

    @ DEVICE pic16F877A, WDT_ON ' Watchdog Timer
    @ DEVICE pic16F877A, PWRT_ON ' Power-On Timer
    @ DEVICE pic16F877A, BOD_ON ' Brown-Out Detect
    @ DEVICE pic16F877A, LVP_OFF ' Low-Voltage Programming
    @ DEVICE pic16F877A, CPD_OFF ' Data Memory Code Protect
    @ DEVICE pic16F877A, PROTECT_OFF ' Program Code Protection
    @ DEVICE pic16F877A, WRT_OFF ' Flash Memory Word Enable

    TRISB.0=1
    TRISB.1=1
    TRISC.7=0
    LED var PORTC.7

    inicio:

    if PORTB.0 = 0 then
    GOSUB liga
    else
    low LED
    endif
    goto inicio

    liga:
    if PORTB.1=1 then
    high LED
    PAUSE 200
    low LED
    else
    low LED
    endif
    goto inicio


    end

  5. #5
    Join Date
    Mar 2008
    Location
    Texas, USA
    Posts
    114


    Did you find this post helpful? Yes | No

    Default

    At first glance, replace the "goto inicio" at the end of the program with "return" (it was called under a "gosub").
    No, I'm not Superman, but I did stay at a Holiday Inn Express last night!

  6. #6


    Did you find this post helpful? Yes | No

    Default

    I got 2 problems 1 de led dont turn of afther the periode and 2 i need the code to do like a cicle and stops when led off and only start again when "switch" 1 is on again.

Similar Threads

  1. Reading in Manchester code
    By brid0030 in forum Code Examples
    Replies: 0
    Last Post: - 10th March 2009, 21:55
  2. How much code space do PBP statements use.
    By Darrel Taylor in forum Code Examples
    Replies: 5
    Last Post: - 13th February 2009, 21:31
  3. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 8th December 2008, 23:40
  4. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26
  5. Re-Writing IF-THEN-AND-ENDIF code?
    By jessey in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 18th August 2006, 17:23

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