inp( pinname )

Get Input Pin Value

Syntax: inp( pinname )
Description: Reads the digital input pin value and returns the value.
Note: the pin should be configured as an input using the pindir( ) command
Parameters: pinname Name of a pinname, This should be in the form Px_y. Where x is the port number, which can be 1 or 2, and y is the bit number which is between 0 and 7. (e.g. P2_3)
Returns: 0 or 1 The digital value at the input pin
Related:  out( ), pindir( )


Example:


pindir(P1_0, OUT)              # Set port P1_0 as an output (Launchpad red led)
pindir(P1_3, INPU)             # Set port P1_3 as an input with pulldown resistor
while 1:                       # do forever
   switch_input = inp(P1_3)    # read the input from pin P1_3 (switch SW2)
   out(P1_0, switch_input)     # set the output pin P1_0 (red led) to the switch value