05-06-2009 09:38 AM
Hi,
I am trying to create a sequence where the LED lights up sequentially for 200ms each. If the switch corresponding to the lighted LED is flipped within then 200ms, the LED turns off and the next LED turns on. However I can't seem to be getting what I want. Can somebody pls help me with this or tell me what errors I'm making? I've attached my file. Thanks
05-06-2009 09:54 AM
I hate to be the one to tell you this, and forgive me for being blunt, but your code is an absolute mess. This seems to be a whack-a-mole game implementation. What is the purpose of all those Boolean switches? Are those intended to be use to "whack the mole"? In what sequence are the LEDs supposed to light up? In a specific order? Randomly?
I would suggest reading up a bit on programming architectures, like the state machine. If this is supposed to be a "whack-a-mole" game then I would suggest using an event structure and handling the user clicking on the LED (by handling the MouseDown event on the LED), rather than having the user flip a switch.
You may also want to take a look at the XOR truth table.
05-06-2009 10:32 AM
I agree that you probably should start out with some simple tutorials.
Here's a very simple draft to get you started. See if you understand it. 😉
05-06-2009 07:21 PM
05-11-2009 11:12 AM
05-11-2009 11:27 AM
If you have e.g. four LEDs, you could generate a random number at regsular intervals and, depeding on the value, light LED1 if the number is 0..0.1, LED2 (0.1..0.2), etc. and have them all off if the random number is 0.4..1.
Simply generate a random number using the "dice" from the numeric palette.
05-11-2009 09:28 PM
05-11-2009 11:12 PM
Well, now you are dealing with 2D arrays, so you should run the index up to the product of the two dimensions. Use Q&R to recover the two indices.
Here's a quick example. Makes sense?