Need help in code


Closed Thread
Results 1 to 23 of 23

Hybrid View

  1. #1
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by camolas View Post
    I got 2 problems 1 de led dont turn of afther the periode
    Fixed by post above?

    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.
    Ok, so how do you determine if the LED is off?
    How do you determine if 'switch 1' is on again?
    If you can answer those 2 questions, then you should be able to write your code.

  2. #2


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    Fixed by post above?


    Ok, so how do you determine if the LED is off?
    How do you determine if 'switch 1' is on again?
    If you can answer those 2 questions, then you should be able to write your code.
    Quote Originally Posted by skimask View Post
    Fixed by post above?


    Ok, so how do you determine if the LED is off?
    How do you determine if 'switch 1' is on again?
    If you can answer those 2 questions, then you should be able to write your code.

    Hi, not fixed.


    determine LED - i do not now if i anderstand you well (bad Inglish mine) but by having switch2 pressed led if off. (or if switch1 pressed is off to)

    'switch 1' - I only put this switch to try to stop the code there from looping and looping because i only want that led is high 1 time at the time (just when switch1 be pressesd again), then wait for switch2 to be not pressed.

    Thanks

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


    Did you find this post helpful? Yes | No

    Default

    One more thing...

    Turn the WDT OFF since your not clearing it.

    Ex:@ DEVICE pic16F877A, WDT_OFF ' Watchdog Timer off
    No, I'm not Superman, but I did stay at a Holiday Inn Express last night!

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    The compiler handle it for you
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by JD123 View Post
    Turn the WDT OFF since your not clearing it.
    PBP inserts WDT clearing instructions for you......unless you:
    DEFINE NO_CLRWDT 1
    in which case, it doesn't. And if you're not using the WDT and if you have it turned off, this can also save a LOAD of code space.

  6. #6
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Default

    Hi, Camolas

    1) some contradiction ...

    " text " tells :

    if input1 = 1 THEN


    WAIT for INPUT2 = 0 == WHILE INPUT2 = 1 : WEND ( loop if INPUT2 = 1 )

    WAIT 40s == PAUSE 40000 ... not 200 !
    LED ON for 3 s
    LED Off
    LOOP


    the program shows input levels inverted ... ( may be active low pushbuttons ??? did you think to the pullup ? )

    I think the first thing for you is to look at the different states ... and write succession of operations in order, more than write lines and try to make them work together.
    That's called an ORGANIGRAM ... ( joined an example )

    Now, I've almost written your program ... just translate it into PbP commands ( I gave you the "difficult part" command ... )

    Alain
    Attached Images Attached Images
    ************************************************** ***********************
    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 " !!!
    *****************************************

  7. #7


    Did you find this post helpful? Yes | No

    Default

    Thas i need to put WDT OFF or not?

    Yes im going to use low pullup pushbuttons rhas i have to do one more line code for it?

    Im very confuse

  8. #8
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by camolas View Post
    Thas i need to put WDT OFF or not?
    I wouldn't worry about it...

    Yes im going to use low pullup pushbuttons rhas i have to do one more line code for it?
    Sounds like you might need to back up a bit and work on the simple stuff first, i.e. make the blinky LED, make the LED follow a single button under SOFTWARE CONTROL, and so on and so on...build up to what you need.
    This 'jumping in with both feet' approach doesn't seem to be working out too well...

  9. #9
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Up in post#5 you are setting the fuses in code space. Have you commented out the lines in the *.inc file?
    http://www.picbasic.co.uk/forum/showthread.php?t=543
    Read post #1 and #5...

    And I do not see how the OSC is set or a
    Code:
    DEFINE OSC ??
    ?? being the speed.
    Dave
    Always wear safety glasses while programming.

  10. #10
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    When you're using PM, you shouldn't need to bother with it. Just to confirm it, i just uncommented the one in a .INC file and write over them... no compilation errors for PM, and the config fuses are set as expected when i look them in my PIC Programmer software.

    If no OSC is defined, PBP will consider 4 MHz.. no big deal. Default XT fuses for PM is XT. it seems to have some activity, seems something work, i worry more about the program flow. I'm still trying to understand what the OP need to do

    Camolas, can you ask your question in your own language (i feel spanish) so maybe someone else here could help you to translate it for us (maybe google translation but )
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

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