Example Code

Solution for Sprinkler Machine using State Machine Approach

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.


  • LabVIEW

Code and Documents



This example demonstrates an implementation of a state machine design pattern in order to create the application logic for the Sprinkler Machine approach. 

  • It makes use of shift registers and low use of local variables to pass the data values.
  • There is a case and a Timer check for each zone in order to start the timer and check if the corresponding time has elapsed. 
  • There is an emergency stop to make sure that the application can be stopped at any moment. 
  • The check for the rain sensor and Low pressure has been implemented for the first zone. If desired, this can be duplicated in the following time checks for the remaining zones. 


Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.