Increment a Byte


Results 1 to 9 of 9

Threaded View

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


    Did you find this post helpful? Yes | No

    Default

    If pwr >= 255 always go to 0 and no to 255.Why happen this?
    Since a byte can count up to 255 max when you add 1 to 255 the byte overflow and start from zero again (it cannot be 256).

    If you want to keep your variable pwr at 255 then you can skip the add command, or you must use a word variable.

    Code:
    pwr var byte
    
    If up = 1 Then
           PAUSE 50
        If pwr = 255 Then Skip00
     pwr = pwr + 1                              
     Skip00:                       
    Endif

    Al.
    Last edited by aratti; - 20th November 2009 at 07:13.
    All progress began with an idea

Similar Threads

  1. LCD freeze
    By harryweb in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 5th October 2009, 08:01
  2. Memory use - how much do you use?
    By keymuu in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 10th June 2009, 22:39
  3. byte compression
    By Norbert in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 16th June 2007, 18:04
  4. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27
  5. 16F877 RAM Question
    By Art in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 6th August 2005, 11:47

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