GPIO Input port programming


1. Add GPIO Input port
  1. Use "InputPort" command to add new GPIO input port.

  2. Select "Application" tab.

  3. Add a new GPIO Input port as follows.

      
    clear
    
    InputPort    port5
    	/Pin:5
    	/GlitchFilter:false
    	/ResistorMode:PullDown
    
      
 

  1. Click "Send to MF Application" button or Press "F5" key.

  2. Executed result:




2. Read state of GPIO port by using "Read()" method
  1. Use "Read()" method to read current state.

  2. Type below script on the editor to read Pin 5's state.

      
    state = port5.Read()
    
    print "State of Pin5 is " + state
    
      


  3. Click "Send to MF Application" button or Press "F5" key.

  4. Executed result:




3. Change the port state through emulator
  1. You can't change the state of InputPort in the application itself because you can only read state from port.

  2. In order to change (or write to port), you have to use emulator script.

  3. Select Emulator tab as follow.



  4. Type below script on the emulator's editor in order to change the state of input port.

      
    port5.Write(true)
    
      


  5. Click "Execute Script on the Emulator" button or Press "F5" key.



  6. Executed result:



  7. You will see the log message that Port5's state was set with true.



4. Read changed state from aplication
  1. Select Application tab

  2. Execute below script again on the Application tab in order to read changed value.

      
    state = port5.Read()
    
    print "State of Pin5 is " + state
    
      


  3. Click "Send to MF Application" button or Press "F5" key.

  4. Executed result:



  5. You can see the state of input port was changed as true.