====== portBlockIn ======
''u8 portBlockIn (u8 portBlockNumber)''
|portBlockNumber : The port block to read (0 through 5) |
|returns a bit array containing the input state of each port in portBlockNumber|
Reads the input state of all ports in the given port block, portBlockNumber, returning a 8-bit array containing
the input state of each of the 8 ports in the port block. If portBlockNumber is 1, bit 0 of the return value
would correspond to port 10, and bit 7 would correspond to port 17. If portBlockIn(1) returned a value
of 7 (b0000 0111), this would mean ports 10~12 would be on, and ports 13-17 would be off.
u8 i = portBlockIn(2); // Reads the input state of ports 20 ~ 27
The following program will copy all the outputs read from an input module in slot 0 (DIO +0) to the output module in slot 1 (DIO + 10).
#include "moacon500.h"
void cmain()
{
portInit(0, 1); // Input module in slot 0
portInit(1, 0); // Output module in slot 1
while(1)
{
u8 state = portBlockIn(0); // Read all 8 inputs
portBlockOut(1, state); // Copy input state to outputs
}
}
[[MOACON:index#System_Library:|MOACON home]]