Read switch 1 to 8 arbitrary

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
JanB
Posts: 34
Joined: Thu Feb 23, 2012 7:33 pm
Contact:

Read switch 1 to 8 arbitrary

Post by JanB »

I’m trying to make a simple program that has to change the LED flash pattern when a switch is pressed.

I have:
PIC16F690
8 switches (mandatory)
8 Macro LED flash patterns with loops (working)

The goal is when you push switch 2, the program has to start pattern 2 and stay there until for example switch 5 is pressed, then it has to go to pattern 5. And off course when you press switch x is has to go to pattern x. And so on.

I did take a look to: http://www.matrixmultimedia.com/mmforum ... ate#p15115

But I think this is too difficult for this simple program. Can someone help to make this work for two patterns? The rest I will try to do.

Thanks,

Jan

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: Read switch 1 to 8 arbitrary

Post by Enamul »

Hi

I think this is the program you are looking for..
Attachments
sw_LED.fcf
(9.5 KiB) Downloaded 622 times
Enamul
University of Nottingham
enamul4mm@gmail.com

JanB
Posts: 34
Joined: Thu Feb 23, 2012 7:33 pm
Contact:

Re: Read switch 1 to 8 arbitrary

Post by JanB »

Hi Enamul,

Thanks for helping me.

I'm trying to understand your program but I have (off course) some questions on how to modify it.

As you know, I have 8 macro's with flash patterns and 8 switches. In your program I can't see how you light the LED's when I push a switch. I think this has someting to do with this: LED_PAT1 = 0b10101010
LED_PAT2 = 0b11001100

This code is (now) too far for me :-)

Your program works fine, but I want to call a new flash_pattern macro when a switch is pressed, no matter in what state the running (loop) or macro is. It has to immidialty stop and go to the next switch input.

Something like this:
https://www.youtube.com/watch?v=WfPgZCCfOD0
You can see that when you press the A B or C switch it does the job, no waiting time (loop's, macro) at all. Just push the switch, and a "next new pattern" macro is activated.

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: Read switch 1 to 8 arbitrary

Post by Enamul »

Hi

You can try this version of the code with macro and earlier LED patterns. Now it is close to the youtube version. Need to press and hold the switch for 1 sec.
Attachments
sw_LED.fcf
(17 KiB) Downloaded 650 times
Enamul
University of Nottingham
enamul4mm@gmail.com

JanB
Posts: 34
Joined: Thu Feb 23, 2012 7:33 pm
Contact:

Re: Read switch 1 to 8 arbitrary

Post by JanB »

Hi Enamul,

This is a very nice one. Thank you !

There is one thing I don't understand. In the Calculation you set a Variable with some binary code. Please explain to me how why you do this? This is for me unclear.

Thanks and greetings,

Jan

EDIT: I can see it has something to do with driving the LEDs in the Macro's, but how this work, I cant see it :-)

EDIT 2: I understand it now. When I take a closer look to the binary format and the .fcf file I see that 0b10101010 is nothing else then a defenition on wich led goes on"1" and off "0"

JanB
Posts: 34
Joined: Thu Feb 23, 2012 7:33 pm
Contact:

Re: Read switch 1 to 8 arbitrary

Post by JanB »

Hi Enamul, (or others)

I want to ask you one more question, and that is more a technical question.

In all my flash patterns I make use of the Component Macro to flash a led (On / Off). I see that you do this on a other way. This way for flashing the LED’s is new to me, but I understand now how it works.

Please tell me, does it make any difference for the microprocessor what I use ? Your way of flashing the LED’s or the way that I do via the Component Macro.

This is just a technical question, for my learning. If I see something new than I want to know why is this.

Regards,

Jan

Post Reply