All,<br><br>I am working on a project that involves switching LED pattern based on pressing a button. I would like to have multiple "modes" that could be cycled through by pushing a button multiple times. Im unsure of how to count the number of pushes that occur. This is what I have so far.<br>
<br>#INCLUDE "plumbing.module"<br>PROC number.pushes (CHAN SIGNAL push?, CHAN INT num.pushes!)<br> CHAN INT pushes:<br> WHILE TRUE<br><span style="color:rgb(255,102,102)"> IF push ? SIGNAL</span><br> SEQ<br>
num.push := num.push +1<br> pushes ! num.push<br> IF num.push > 4<br> num.push := 0<br> <br>:<br><br>PROC main()<br> CHAN SIGNAL s:<br> INT num.pushes:<br> CHAN INT pushes:<br>
SEQ<br> serial.setup(TX0,9800)<br> PAR<br> button.press(2,s!)<br> number.pushes(s?, pushes!)<br> SEQ<br> pushes ? pushes<br> <a href="http://serial.write.int">serial.write.int</a>(TX0,pushes)<br>
:<br><br>I am unsure of how to implement what I have highlighted as red text. Am I at least on the right track? <br><br>Looking forward to any thoughts anyone might have.<br><br>Thanks,<br>Ian Armstrong<br>