TOC PREV NEXT INDEX



Set up initial variables.


Next you will set up some variables for the traffic light.

  1. Choose "Goto declaration code" from the Code menu of the Canvas Composer.
  2. Type the following lines into the text area. This text could be created using the Code Sourcerer, using "Declare a new variable..." and then adjusting the various settings.
static final int RED = 0;
static final int YELLOW = 1;
static final int GREEN = 2;
int state = 0;

These lines of code create a variable called 'state' which stores which color the traffic light should display, and define three possible states, RED, YELLOW, and GREEN.

  1. Choose "Initialize Class" from the Program menu. This will cause Simplicity to restart the working model, giving it access to the variables you just created.

Data Representations, Inc.
http://www.datarepresentations.com
support@datarepresentations.com
sales@datarepresentations.com
TOC PREV NEXT INDEX