Difference between revisions of "Exercise - Configuring Icons and Variables"

From Flowcode Help
Jump to navigationJump to search
Line 23: Line 23:
  
  
:* Double click on it to open the configuration dialogue box, and then: [[File:gen_exerciseFirstFlowchartadddev_deciconprops_01.png|250px|right]]
+
:* Double click on the [[Decision Icon Properties|Decision icon]] to open the configuration dialogue box, and then: [[File:gen_exerciseFirstFlowchartadddev_deciconprops_01.png|250px|right]]
 
::* Rename it "Switch pressed?".
 
::* Rename it "Switch pressed?".
 
::* In the 'If:' box, type "switch=1".
 
::* In the 'If:' box, type "switch=1".

Revision as of 11:30, 17 July 2013

This opens the 'Properties: Input' dialogue box, allowing you to configure the way the program treats information from the switch.
This information will be contained in a variable called 'switch'.
  • Click on the down arrow at the right-hand end of the 'Variable:' box to open the variables dialogue box.
  • Hover to the left of the 'Variables' label and click on the down arrow that appears.
  • Click on the 'Add new' option to open the 'Create a New Variable' dialogue box.
  • Create a new variable named "switch" with initial value "0" and description "Copies the state of the switch"
  • Leave the 'Variable type:' as 'Byte'.
(For more information about variables, see Creating Variables and Variable Types.
(The resulting dialogue box is shown opposite.)
  • Finish configuring the input properties as follows:
  • Change the 'Display name:' to "Read the switch".
  • In the 'Variable:' box, type the name of the variable you created "switch".
  • Leave the 'Port:' as PORT A.
  • Select to 'Input from:' 'Single Bit' and choose bit 0.
(The resulting dialogue box is shown opposite.)


Set up like this, the program monitors the state of the switch, which will be connected to bit 0 of Port A of the microcontroller.
When the program looks at the input switch if it is pressed, the variable 'switch' contains logic 1. If unpressed, it contains logic 0.


  • Rename it "Switch pressed?".
  • In the 'If:' box, type "switch=1".
  • Leave the 'Swap Yes and No' box unchecked.
  • Click on 'OK'.
This icon will be used to make the program perform what is known as a conditional branch.
The subsequent course of the program depends on the outcome of the condition specified in the 'Decision' icon.
In this case, it depends on whether or not the variable 'switch' = 1.
If it is, the program follows the 'Yes' route. If not, it follows the 'No' route.