GPIO Output port programming


1. Add GPIO Output port
  1. Use "OutputPort" command to add new GPIO output port.

  2. Select "Application" tab.

  3. Add a new GPIO Output port as follows.

      
    OutputPort    port6
    	/Pin:6
    	/InitialState:false
    
      
 

  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 6's state.

      
    state = port6.Read()
    
    print "State of Pin6 is " + state
    
      


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

  4. Executed result:




3. Change the port state by using "Write()" method
  1. Use "Write(bool)" method to change current state.

  2. 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
    
      


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

  4. Executed result:




4. Repeated change of state
  1. 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
    }
    
      


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

  3. Executed result:



  4. Above result shows state of OutputPort is being changed repeatedly.