|
|
(55 intermediate revisions by 3 users not shown) |
Line 1: |
Line 1: |
− | Macros are sections of code that are repeated a number of times within a program.<br />
| + | For an excellent introduction guide, we recommend [https://www.flowcode.co.uk/education/ Introduction to microcontroller programming] |
− | It is more efficient to use a macro than to create the code repeatedly every time it is needed.<br />
| |
− | For more information about macros, see [[What Is a Macro?]]. | |
− | | |
− | This exercise shows how to use macros with a menu to create a simple LED flasher. The LED can be made to flash at different frequencies by pressing different switches.
| |
− | | |
− | | |
− | | |
− | The first section looks at using 'Component Macros' to create the core timing sequence. The second section looks at using it to turn on a lamp for ten seconds once a switch is pressed.
| |
− | | |
− | | |
− | __TOC__
| |
− | | |
− | ==The core timing sequence==
| |
− | At the core of the program is a section that sets up the LCD to display the time.<br />
| |
− | The flowchart sequence for displaying the elapsed time will be:
| |
− | ::::* Initialize the LCD using the 'Start' macro.
| |
− | ::::* Set the cursor position in the LCD, using the 'Cursor' macro.
| |
− | | |
− | | |
− | | |
− | | |
− | ===Set up the flowchart===
| |
− | * Open Flowcode, and set up the new flowchart as described in [[Exercise - Creating Your First Flowchart|Creating Your First Flowchart]].
| |
− | | |
− | | |
− | ===Create the core sequence===
| |
− | ===Add the LCD===
| |
− | * Locate the 'LCD' inside the 'Outputs' toolbox in the [[Tools and Views#1) Icons Toolbar|Icons toolbar]].
| |
− | :* Hover over the image to the left of the 'LCD' label, and click on the down-arrow that appears.
| |
Latest revision as of 13:24, 25 April 2023