direction Property

Top  Previous  Next

Gets or sets the direction (input or output) of each port pin.

Syntax

Cell.PortA.direction

Cell.PortB.direction

Property Value

A bit mask identifying the port pins that are outputs.

Remarks

Setting a bit of the direction property to 1 makes the corresponding port pin an output. Setting the bit to zero makes the pin an input.

 

Each port pin has a corresponding bit value, as shown in the table:

 

Port Pin

Bit Value

A0/B0

0x01

A1/B1

0x02

A2/B2

0x04

A3/B3

0x08

A4/B4

0x10

A5/B5

0x20

A6/B6

0x40

A7/B7

0x80

 

To set pins as outputs, OR together their corresponding bit values and assign the result to direction.

 

When a pin is set as an input, a pull-up resistor can be enabled. This is set with the pullup property.

Examples

Cell.PortA.direction = 0xFF;// All outputs
Cell.PortB.direction = 0;// All inputs
Cell.PortA.direction = 0xE0;// A5, A6, A7 are outputs
Cell.PortA.direction &= ~0x20;// A5 back to input
Cell.PortA.direction |= 0x20;// A5 back to output

See Also

pins Property, pullup Property