PinGet (GetPin)
Syntax
Variable = PinGet Pin Number
Overview
Read a pin of a port.
Parameters
Variable is a user defined variable. Pin Number is a constant, variable, or expression that points to the pin of a port that requires reading. A value of 0 will read PORTA.0, a value of 1 will read PORTA.1, a value of 8 will read PORTB.0 etc… The pin will be made an input before reading commences.
Example
' Examine and display each pin of PORTB
Device = 16F1829 ' Select the device to compile for
Declare Xtal = 16 ' Tell the compiler the device will be operating at 16MHz
Dim PinNumber as Byte
Dim MyByte as Byte
Do
For PinNumber = 8 to 15 ' Create a loop for 8 pins
MyByte = PinGet PinNumber ' Examine each pin of PORTB
Print Dec1 MyByte ' Display the binary result
DelayMs 100 ' Slow things down to see what's happening
Next ' Close the loop
Loop ' Do it forever
Note.
Each pin number has a designated name. These are Pin_A0…Pin_A7, Pin_B0…Pin_B7, Pin_C0…Pin_C7, Pin_D0…Pin_D7 to Pin_L7 etc… Each of the names has a relevant constant value, for example, Pin_A0 has the value 0, Pin_B0 has the value 8, up to Pin_L7, which has the value 87. For 8-pin devices, the pins can be referenced as Pin_IO0...Pin_IO5. The pin names can be found within the device’s .def file, within the compiler’s directory.
See also : Output, Input, PinClear, PinSet, PinPullup, High, Low.
