'This module contains BasicX code for toggle function. 'I don't care who uses it but I can't be liable. 'Ian Casey 'This function toggles the output level of a pin - the pin must already be set up as an output 'this only is set up for pins 5 thru 20, I guess it could be changed to include Pin 25,26?? '**I've only tested with a couple of pins, but working okay** Public Sub Toggle(ByVal Pin as Byte) If (Pin <= 12) And (Pin >= 5) then If Register.PortC AND POWB(2,12-Pin) = 0 then Call PutPin(Pin,bxOutputHigh) Else Call PutPin(Pin,bxOutputLow) End If ElseIf (Pin <= 20) And (Pin >= 13) then If Register.PortA AND POWB(2,20-Pin) = 0 then Call PutPin(Pin,bxOutputHigh) Else Call PutPin(Pin,bxOutputLow) End If End If End Sub 'this function similar as POW in BasicX but returns byte and I think is 700 bytes smaller. 'called by Toggle but may also be useful elsewhere. Public Function POWB(ByVal Root as Byte, ByVal Power as Byte) As Byte Dim Count as Byte Dim Result as Byte If Power = 0 then POWB = 0 ElseIf Power = 1 then POWB = Root Else Result = Root For Count = 1 to Power - 1 Result = Result * Root Next POWB = Result End If End Function