NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Project Help and Ideas » indexing code with a button push help
October 18, 2012 by jfreethy |
Hello everyone, In my project I would like to index each line of code every time I press a button.i.e press the button execute the first output, press it again then more to the second output, and so on. Here is the section of code in question;
prusmably I think feel that I should be using some sorta switch function but I do not know how :), and have not seen an example that I could understand. please let me know if you need the full code or if you might have a soulution. thank you, Jason |
---|---|
October 18, 2012 by pcbolt |
Jason - Yes a switch would be the way to go. Here is an example:
You could use "if" statements but that can get messy. Or if you are really brave you could use function pointers. |
October 18, 2012 by jfreethy |
would I have to turn off the previous function or would the break function do that for me? p.s. thank you for your help! jason |
October 18, 2012 by pcbolt |
Jason - The "break" statement just takes you to the end of the code block. If you want to execute your code like in your first post each "case" statement would look like:
|
October 18, 2012 by jfreethy |
thank you again. I finaly got it wourking :) cheers |
Please log in to post a reply.
Did you know that NerdKits make a great gift? Learn more...
|