GPIO Output port programming
1. Add GPIO Output port
- Use "OutputPort" command to add new GPIO output port.
- Select "Application" tab.
- Add a new GPIO Output port as follows.
| |
OutputPort port6
/Pin:6
/InitialState:false
| |
|
|
|
|
- Click "Send to MF Application" button or Press "F5" key.
- Executed result:
2. Read state of GPIO port by using "Read()" method
- Use "Read()" method to read current state.
- Type below script on the editor to read Pin 6's state.
| |
state = port6.Read()
print "State of Pin6 is " + state
| |
|
- Click "Send to MF Application" button or Press "F5" key.
- Executed result:
3. Change the port state by using "Write()" method
- Use "Write(bool)" method to change current state.
- Type below script on the editor in order to change the state of port.
| |
port6.Write(true)
state = port6.Read()
print "State of Pin6 is " + state
| |
|
- Click "Send to MF Application" button or Press "F5" key.
- Executed result:
4. Repeated change of state
- Type below script on the editor in order to toggle state per 1 sec.
| |
while(true)
{
state = port6.Read()
print "State of Pin6 is " + state
//Change state
state = !state
port6.Write(state)
wait 1000
}
| |
|
- Click "Send to MF Application" button or Press "F5" key.
- Executed result:
- Above result shows state of OutputPort is being changed repeatedly.
|