GPIO Input port programming
1. Add GPIO Input port
- Use "InputPort" command to add new GPIO input port.
- Select "Application" tab.
- Add a new GPIO Input port as follows.
| |
clear
InputPort port5
/Pin:5
/GlitchFilter:false
/ResistorMode:PullDown
| |
|
|
|
|
- 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 5's state.
| |
state = port5.Read()
print "State of Pin5 is " + state
| |
|
- Click "Send to MF Application" button or Press "F5" key.
- Executed result:
3. Change the port state through emulator
- You can't change the state of InputPort in the application itself because you can only read state from port.
- In order to change (or write to port), you have to use emulator script.
- Select Emulator tab as follow.
- Type below script on the emulator's editor in order to change the state of input port.
- Click "Execute Script on the Emulator" button or Press "F5" key.
- Executed result:
- You will see the log message that Port5's state was set with true.
4. Read changed state from aplication
- Select Application tab
- Execute below script again on the Application tab in order to read changed value.
| |
state = port5.Read()
print "State of Pin5 is " + state
| |
|
- Click "Send to MF Application" button or Press "F5" key.
- Executed result:
- You can see the state of input port was changed as true.
|