On Sat, 25 Apr 2015 00:44:18 -0700 (PDT), you wrote: >Hello, > >I am currently working on a project that involves using switches (handled >the same was as a button) and node.js. I am stuck on a part that involves >making sure the switches are pressed in the correct order. There is an Up >switch and a Down switch. > >The things I need to do: > >- The Up switch needs to be the first switched pressed, if the Down switch >is pressed first I need to print an error (console.log will do) >- The Up switch cannot be pressed two or more times in a row without having >a Down switch press in between, if there are two or more Up switch presses >in a row it will result in printing an error. >- The Down switch cannot be pressed two or more times in a row without >having an Up switch press in between, if there are two or more Down switch >presses in a row it will result in printing an error. > >Any help I can get would be greatly appreciated! I have been stuck on this >for quite a while and I know it shouldn't be hard its just not coming to me >very easily. Everything I have tried so far as been unsuccessful.
Flow chart this. You will need a routine that sets a boolean variable when a key has been pressed, or a method of checking when the key has been pressed. A flow chart will give you the program flow, Example as a start, using words... Initialize all switches to not pressed. is switch pressed? if not, loop on this question is switch UP switch, if yes, go to next statement, if no print error // up has to be first is switch DOWN switch, if yes, go to DOWN, if not, go to next statement is up switch already pressed? if so, print error. if not, go to next statement .... code here to handle up switch press and then reset up switch pressed and go back to looking for switch pressed DOWN: is down switch already pressed? if so, print error, if not, go to next statement ..... etc Harvey > >Thanks. -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups "BeagleBoard" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
