Toggle bit

General discussion on mikroBasic for AVR.
Post Reply
Author
Message
zuran
Posts: 29
Joined: 19 Oct 2007 08:15
Location: Belgium

Toggle bit

#1 Post by zuran » 26 Oct 2007 12:32

is there an easier way to toggle a bit then this one

Code: Select all

    if Button(PORTD, 5, 10, 1) then
    if (resettrue = 0) then
       if (portc.1) then
       portC.1 = 0
       else
       portC.1 = 1
       end if
       resettrue = 1
      end if
    end if

    
    if Button(PORTD, 5, 10, 0) then
       resettrue = 0
    end if
portC.1 = not(portC.1) does not work

thx

zuran
Posts: 29
Joined: 19 Oct 2007 08:15
Location: Belgium

#2 Post by zuran » 26 Oct 2007 12:59

ok found something

Code: Select all

portC.1 = portC.1 xor 1
instead of

Code: Select all

       if (portc.1) then
       portC.1 = 0
       else
       portC.1 = 1
       end if
does the trick

Post Reply

Return to “mikroBasic for AVR General”