Led's in array

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Led's in array

Post by stefan.erni »

hi Ben
I have a board with 23 Led's. I use the LED(SMD,PCB). The simulation is working nice. Also in the hardware. But how can I control the Led like a array with index? Or can I use for the "handle" an array?
regards

Stefan

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Led's in array

Post by Benj »

Hi Stefan,

The easiest way is to create a macro with two parameters, LED and state.
CreateMacro.jpg
CreateMacro.jpg (34.16 KiB) Viewed 4049 times
In the macro add decisions for each LED, .LED = 0 for example.

Inside the yes branch of the .LED = 0 decision add another decision .State.

In the yes branch of the .State decision switch LED0 on, and in the no branch switch LED0 off.

Copy and paste the .LED = 0 decision in the macro, one for each LED.
CreateMacro2.jpg
CreateMacro2.jpg (37.95 KiB) Viewed 4049 times
You can then use your new macro to easily control all the individual LEDs.

You could even export this as a component if you want to be able to re-use the code again and again in different projects.

Let us know how you're getting on.

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: Led's in array

Post by stefan.erni »

Hi Ben
Thank you for the help.
I will do somthing like this.
But how can I build a component from the Macro?

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Led's in array

Post by Benj »

But how can I build a component from the Macro?
File -> Component Configuration

Setup Tab
Specify a Name, Cosmetic Name, Category, Description.

Interface Tab
Set macros you want to be available to Downloadable.

Click OK

File -> Export Component

Export the component file to either one of the following.

v7) C:\Program Files (x86)\Flowcode 7\components - maybe export to your desktop and then manually copy the file to avoid write protection issues.

v8) C:\ProgramData\MatrixTSL\FlowcodeV8\Components

Custom Location) Export to any location on your HDD, then use the View -> Global Options -> Locations Tab to add a folder in the "Look For Components In" text field.

Hope this helps.

More info here if you need it.
https://www.matrixtsl.com/wiki/index.ph ... l_Managers

This is more advanced tutorial but should also cover the basics.
https://www.matrixtsl.com/wiki/index.ph ... eled_robot

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: Led's in array

Post by stefan.erni »

Hi Ben

I did my first component...It's working nice. But if I understand it right, I can nod modify the component. I have to save it as a project?

regards

Stefan

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Led's in array

Post by Benj »

Hi Stefan,

If you need to modify the component then you have to go back to your source project, make the changes there and then re-export.

If you need to be able to change things in your component then you can create your own properties (or expose sub properties) to allow you to configure things on the fly without re-exporting.

Post Reply