Recent Changes - Search:

Introduction to Microcontroller Programming

About PICmicro Chips

Clocking Your PICmicro Devices

E-Blocks

Flowcode Step By Step

PICmicro Projects

Labs

More Efficient Macros

<^< Create New Macros | Course Index | Other macro features >^>

  1. If you run the program you will find out that it has much the same effect as before. However now we have created two macros that we could use at other places in our program. However it is possible to use another technique so that we can cut the number of macros down to just one that would also be even more flexible.
  2. Create a new macro called "FLASH". Hover over 'Parameters' a button will appear, click on it then 'Add new'. Add a variable called 'whichone', keep it as a 'Byte' and select OK. You should have a Macro dialogue window that looks like this:
  1. First, create an Output icon in your newly created 'FLASH' macro, double-click this Output icon to access the properties. First we need to change the output to Port B, next we need to add our newly created local variable, Flowcode knows that the new macro 'FLASH' takes one parameter that is passed to it, you can see this demonstrated when you click on the button and then click on the 'Locals' button. Double-click the 'whichone' parameter to insert it.
  1. Next insert a 200ms Delay, an Output icon which sends 0 to Port B, and another 200ms Delay. You should end up with this:
  1. On the main flowchart double-click on the Macro icon that calls the 'LEFT' macro. In the 'Macro:' dialogue box select FLASH. below the 'Macro:' dialogue box you will see that Flowcode has recognised that this needs a parameter and the 'parameters:' dialogue box is enabled to allow you to enter the parameter. Enter the number '1':
  1. Similarly for the 'RIGHT' Macro icon call the 'FLASH' macro with a parameter of '2'. Your whole flowchart should now look like the one below. You now have the same functionality as the previous program but you have only used one macro. That's not too important in a small program like this, but in later programs you will appreciate the efficiency of this method of writing programs.

<^< Create New Macros | Course index | Other macro features >^>

Print - Search - Login

Page last modified on May 14, 2013, at 01:10 PM