Need Help To Understand This Program


Closed Thread
Results 1 to 3 of 3
  1. #1
    Danish's Avatar
    Danish Guest

    Thumbs down Need Help To Understand This Program

    HELLO CAN ANYONE HELP ME UNDERSTAND THIS PROGRAM I MEAN I UNDERSTAND BUT ONE THING I DONT GET AND WHY DOESN'T IT DO IT I PUT A TOGGLE COMMAND IN THIS PROGRAM WITH THE BUTTON COMMAND AND THE PROGRAM WORKS PERFECTLY AND BUT WHEN EVERYBODY KNOWS WHEN THE BUTTON IS PRESSED IT GOES TO THE LABEL IT IS ASSIGNED TO IF THE ACTION IS TRUE AND WHEN IT SCANS THE BUTTON COMMAND AND IT IS NOT PRESSED IT GOES TO THE TOGGLE COMMAND AND THEN IT TURNS OFF THE LED BUT WHEN IT RESTARTS THE LOOP AND SCANS THE BUTTON COMMAND AGAIN AND IT IS NOT PRESSED THEN GOES TO THE TOGGLE COMMAND THEN THE TOGGLE SHOULD TURN OFF THE LED BECAUSE THATS WHAT THE TOGGLE COMMAND DOES WHEN THE LED IS HIGH IT TURNS IT LOW AND WHEN IT IS LOW IT TURNS IT HIGH HERE IS THE PROGRAM TO GIVE YOU AND IDEA ABOUT WHAT I AM TALKING ABOUT :

    loop: B0=0
    BUTTON 1,1,254,0,B0,1,loop
    TOGGLE 0
    PAUSE 500
    GOTO LOOP

    CAN ANYONE REPLY BACK TO ME I WOULD REALLY APPRECIATE A REPLY

  2. #2
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    762


    Did you find this post helpful? Yes | No

    Default

    Ok,
    here is the first reply:

    some periods, and full stops.
    In addition to some "CRLF"
    would have made your Posting "readable"

    YOUDONTREALLYWANTUSGUESSINGWHATYOUAREACTUALLYTRYIN GTOTELLUSDOYOU
    regards

    Ralph

    _______________________________________________
    There are only 10 types of people:
    Those who understand binary, and those who don't ...
    _______________________________________________



  3. #3
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Hi Danish,

    Just wondering if you're covered with Cream Cheese. Mmmmmmm.

    The BUTTON command will never time out because B0 is getting reset to 0 on every loop. It will never reach a full count. Try putting the B0 = 0 outside the loop, something like this.
    Code:
    B0=0 
    loop:
        BUTTON 1,1,254,0,B0,1,ButttonPressed
        TOGGLE 0
        PAUSE 500
    GOTO LOOP
    
    ButttonPressed:
    ' ... code here ...
    goto loop
    ADDED: I should probably mention that the PAUSE 500 with a BUTTON delay of 254 will mean you'll have to hold the button down for 128 seconds before it will jump to the Button pressed routine. So a smaller delay or pause will be needed.<br>
    Last edited by Darrel Taylor; - 9th August 2005 at 22:28.
    DT

Similar Threads

  1. Presetting Configuration Fuses (PIC Defines) into your Program
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 82
    Last Post: - 15th December 2013, 09:54
  2. Replies: 1
    Last Post: - 23rd May 2009, 09:22
  3. Compile and Program help using PICKit2
    By ozarkshermit in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 10th March 2009, 14:51
  4. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26
  5. PIC16F684 Program question
    By Nicholas in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 28th December 2006, 14:30

Members who have read this thread : 1

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