Page 1 of 1

Help please

Posted: Tue Sep 22, 2009 5:02 pm
by stevel
Having problems with my project having to reset micro for the switches to work first time. i want it to do when switch 1 is pressed to do the leds on and when switch 2 is pressed do led pattern i am sending my flow chart can you look at this please and alter it if needed. i am not sure wat to do as i am very new to flowcode

Re: Help please

Posted: Tue Sep 22, 2009 6:52 pm
by Spanish_dude
Hi stevel,

I downloaded your program, and I saw a few things that aren't correct.

First one:
To read the switches (input on PORT A) is ok, but you can use the macro instead of the input icon to read the state of a switch. You'll need to use the ReadState() function. If you use this macro, you need to "tell" the macro witch switch you want the read. Ex.: for the first switch then you need to write '0', for the seconde one you need to write '1', etc. You also need to write a variable, so that the microcontroller can "save" the state of the switch. Ex.: for switch 0 use a variable named switch_0.

If you want to use the input PORT A icon and use 2 switches, you can erase the if-then-else switch = 3 and switch = 4.

Second one:
Your if-then-else aren't correct. If you use the macro and use a variable ex. switch_0 then your if-then will look like this: If (switch_0 = 1) then "all leds on" (= output PORT B high) else "nothing happens". For the second switch use the same if-then-else but now you'll change the variable name switch_0 by ex. switch_1.

You only need 2 if-then-else because you only use 2 switches.

Third one:
You use 'while (1)' when you want to 'activate' your LED's. A while (1) is a loop that will never stop. So you need to change that.
If you want to turn your LED's on, you don't need the loop, the icon PORT B = 255 will activate the LED's.
For your "led pattern" try to turn on and off the LED 5 times with a 'loop count'.

I uploaded two examples for you. One with the macro and another one with the input PORT A icon.
I hope you understand what I wrote above.

Re: Help please

Posted: Tue Sep 22, 2009 7:04 pm
by kersing
stevel wrote:Having problems with my project having to reset micro for the switches to work first time. i want it to do when switch 1 is pressed to do the leds on and when switch 2 is pressed do led pattern i am sending my flow chart can you look at this please and alter it if needed. i am not sure wat to do as i am very new to flowcode
There is no need to post the same question multiple times. Anyway, see my comment at your other posting.