To set up and program the flowchart you must configure the icons and variables to create an effective and functioning process.<br />
To set up and program the flowchart you must configure the icons and variables to create an effective and functioning process.<br />
This will prepare the program to interact with components connected to the specific ports.
This will prepare the program to interact with components connected to the specific ports.
__TOC__
Line 17:
Line 20:
It takes such a short time for the microcontroller to carry this out, that we don't need to worry whether the switch latches on or not.
It takes such a short time for the microcontroller to carry this out, that we don't need to worry whether the switch latches on or not.
==Program the input==
==Program the input==
Line 45:
Line 49:
: 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.
: 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.
: When the program looks at the input switch if it is pressed, the variable 'switch' contains logic 1. If unpressed, it contains logic 0.
==Check the Switch==
==Check the Switch==
Line 57:
Line 62:
: In this case, it depends on whether or not the variable 'switch' = 1.
: 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.
: If it is, the program follows the 'Yes' route. If not, it follows the 'No' route.
==Control the Lamp==
==Control the Lamp==
Revision as of 08:13, 18 July 2013
<sidebar>Sidebar: Controlling Electronic Devices With Flowcode</sidebar>
This exercise assumes that you have already built the Flowcode flowchart described in the exercise Creating a Flowchart.
To set up and program the flowchart you must configure the icons and variables to create an effective and functioning process.
This will prepare the program to interact with components connected to the specific ports.
Program the sequence
Now that the flowchart icons are correctly set up, we need to program them to carry out the following process:
Check if the switch is pressed.
If it isn't, go back to the beginning.
If it is:
Switch on the lamp;
Wait for 10 seconds;
Switch off the lamp;
Go back to the beginning.
It takes such a short time for the microcontroller to carry this out, that we don't need to worry whether the switch latches on or not.