Difference between revisions of "Exercise - Adding Devices to a Program"

From Flowcode Help
Jump to navigationJump to search
 
(21 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<sidebar>Sidebar: Controlling Electronic Devices With Flowcode</sidebar>
+
<sidebar>Sidebar: Flowcode Exercises:Ex1</sidebar>
 
This exercise assumes that you have already built the Flowcode flowchart described in the exercise [[Exercise - Configuring Icons and Variables|Configuring Icons and Variables]].<br />
 
This exercise assumes that you have already built the Flowcode flowchart described in the exercise [[Exercise - Configuring Icons and Variables|Configuring Icons and Variables]].<br />
 
To complete the program, you need to add the two electronic components, the switch and the lamp.
 
To complete the program, you need to add the two electronic components, the switch and the lamp.
Line 16: Line 16:
 
==Add the Switch==
 
==Add the Switch==
 
[[File:Exercise Adding Devices to a Program Switch Properties.png|300px|right]]
 
[[File:Exercise Adding Devices to a Program Switch Properties.png|300px|right]]
* Click on the 'Inputs' toolbox, and locate the 'Push Round Panel' [[File:Component Icon 5c1da48f ce54 4622 bdd9 fc812e373696.png]] switch.
+
* Click on the 'Inputs' toolbox, and locate the [[Component: ID 5c1da48f ce54 4622 bdd9 fc812e373696|Push Round Panel]] [[File:Component Icon 5c1da48f ce54 4622 bdd9 fc812e373696.png]] switch.
 
* Hover over the image, and click on the down arrow that appears.
 
* Hover over the image, and click on the down arrow that appears.
 
* Select the 'Add to system panel' option.
 
* Select the 'Add to system panel' option.
Line 32: Line 32:
 
:: This setting is shown opposite.
 
:: This setting is shown opposite.
  
:* No other properties need changing, though '[[Object Scale|Scale]]' allows you to change the size (and shape) of the switch if you wish.
+
:* No other properties need changing, though the [[Object Scale|Scale]] section allows you to change the size (and shape) of the switch if you wish.
  
  
Line 41: Line 41:
 
==Add the Lamp==
 
==Add the Lamp==
 
[[File:Exercise Adding Devices to a Program LED Properties.png|300px|right]]
 
[[File:Exercise Adding Devices to a Program LED Properties.png|300px|right]]
* Click on the 'Outputs' toolbox, and locate the 'Single LED', which we will use as a lamp.
+
* Click on the 'Outputs' toolbox, and locate and add an [[Component: ID a7b05886 784c 48c8 a6f6 cc371c7728e1|LED]] such as the [[Component: ID 7fdaec78 394e 4ec9 a578 4f1a12a12076|LED 5mm Panel]] component, which we will use as a lamp.
 
* Hover over the image, and click on the down arrow that appears.
 
* Hover over the image, and click on the down arrow that appears.
 
* Select the 'Add to system panel' option.
 
* Select the 'Add to system panel' option.
Line 50: Line 50:
  
 
* With the LED selected, look at the Panel Properties.
 
* With the LED selected, look at the Panel Properties.
: Notice that the 'Handle' has changed to 'led'.
+
: Notice that the 'Handle' has changed to the name of the component handle.
 
: The 'Connection' property may not be connected to the correctly, as the flowchart expects it to be connected to Port B, bit 0.
 
: The 'Connection' property may not be connected to the correctly, as the flowchart expects it to be connected to Port B, bit 0.
 
:* Click on the box next to the 'Connection' property and, as before, a pinout of the chip appears.
 
:* Click on the box next to the 'Connection' property and, as before, a pinout of the chip appears.
Line 56: Line 56:
 
:: The Panel Properties now show that the LED is connected to Port B, bit 0.
 
:: The Panel Properties now show that the LED is connected to Port B, bit 0.
  
:* Once again, no other properties need changing, though 'Scale' and 'Color' settings can be altered to change the size and color of the LED.
+
:* Once again, no other properties need changing, though the 'Scale' section can alter the size of the component and the 'Color' property (also known as 'Bulb color' in other components) allows you to change the colour of the LED.
 
 
 
 
  
  
Line 68: Line 66:
  
  
==What Next?==
+
==Download the exercise==
Now that the flowchart is complete, we are ready to test it in simulation, as described in the next exercise [[Exercise - Simulating a Program|Simulating a Program]].
+
You can download the file created by this exercise and open it in Flowcode to identify errors in your program/file or you could also download the file to skip to the next exercise.
 +
 
 +
*To download the file, click on the link below and then either:
 +
:*Click on the file name.
 +
:*Right click the file name and select 'Save link as...' or 'Save target as...' (depending on your browser).
 +
 
 +
:::{{Fcfile|Exercise - Adding Devices to a Program.fcfx|Exercise - Adding Devices to a Program}}
  
  
==Link==
+
==What next?==
To download the Flowcode program for this exercise, click on the following link [[File:xxx|xxx]]
+
Now that the flowchart is complete, we are ready to test it in simulation, as described in the next exercise [[Exercise - Simulating a Program|Simulating a Program]].

Latest revision as of 14:28, 13 March 2014

<sidebar>Sidebar: Flowcode Exercises:Ex1</sidebar> This exercise assumes that you have already built the Flowcode flowchart described in the exercise Configuring Icons and Variables.
To complete the program, you need to add the two electronic components, the switch and the lamp.



Load the Flowcode Flowchart

(For help with this, see the article Opening an Existing Flowchart)
The System Panel and Panel Properties should be visible. If not, use the View menu to select them.


Add the Switch

Exercise Adding Devices to a Program Switch Properties.png
  • Click on the 'Inputs' toolbox, and locate the Push Round Panel Component Icon 5c1da48f ce54 4622 bdd9 fc812e373696.png switch.
  • Hover over the image, and click on the down arrow that appears.
  • Select the 'Add to system panel' option.


  • Click on the switch on the System Panel to select it. Its properties appear in the Panel Properties.
Notice that the name ('Handle') of the component selected appears at the top of the Panel Properties.
In this case, it shows the name of the switch as 'sw_push_rnd_pnl'!


  • Find the 'Connections' properties on the Panel Properties, the box to the right of it.
A pinout of the microcontroller appears.
  • Ensure that it is connected to Port A bit 0 by using the drop down menus or clicking on the rectangle representing the pin for Port A bit 0 (called RA0/AN0 on the graphic.)
This connects the switch to Port A bit 0 of the microcontroller, matching the settings you used when you created the flowchart.
This setting is shown opposite.
  • No other properties need changing, though the Scale section allows you to change the size (and shape) of the switch if you wish.




Add the Lamp

Exercise Adding Devices to a Program LED Properties.png
  • Click on the 'Outputs' toolbox, and locate and add an LED such as the LED 5mm Panel component, which we will use as a lamp.
  • Hover over the image, and click on the down arrow that appears.
  • Select the 'Add to system panel' option.
  • The LED appears in the middle of the System Panel, probably right on top of the switch.
It should already be selected, but if not click on it.
If so, drag it to a suitable position off to one side.


  • With the LED selected, look at the Panel Properties.
Notice that the 'Handle' has changed to the name of the component handle.
The 'Connection' property may not be connected to the correctly, as the flowchart expects it to be connected to Port B, bit 0.
  • Click on the box next to the 'Connection' property and, as before, a pinout of the chip appears.
  • Click on the rectangle representing the pin for bit 0 of Port B, shown as RB0/INT or use the drop down menus to connect the component.
The Panel Properties now show that the LED is connected to Port B, bit 0.
  • Once again, no other properties need changing, though the 'Scale' section can alter the size of the component and the 'Color' property (also known as 'Bulb color' in other components) allows you to change the colour of the LED.



Save the Flowchart

  • Save the flowchart using the same name. The simplest way to do this is to click on the 'Save' icon. Btn Save.png
For more information, see Saving a Flowchart.


Download the exercise

You can download the file created by this exercise and open it in Flowcode to identify errors in your program/file or you could also download the file to skip to the next exercise.

  • To download the file, click on the link below and then either:
  • Click on the file name.
  • Right click the file name and select 'Save link as...' or 'Save target as...' (depending on your browser).
FC6 Icon.png

Exercise - Adding Devices to a Program


What next?

Now that the flowchart is complete, we are ready to test it in simulation, as described in the next exercise Simulating a Program.