Count events rather than held signals
A rising-edge counter reacts to false-to-true transitions, not every scan with a true signal.
- Reset the example counter.
- Pulse the sensor high, then return it low.
- Repeat and compare the current count with the expected number of edges.
false → true → true → false → true gives two rising edges.
See the reasoning, step by step.
- Starting at zero, false produces count 0. The first false→true transition produces count 1.
- Another true sample keeps count 1 because there is no new rising edge. Returning false still leaves count 1.
- The next false→true transition produces count 2. Sequence false,true,true,false,true therefore finishes at 2.
A mistake worth catching
The trap: Counting the number of scans in which the sensor is true.
A better approach: For this counter, count distinct rising transitions; insert a false sample between events.
Your turn: use the idea.
From reset, trace false,true,true,true,false,false,true,true.
Try it yourself first. This is a self-review task, not automatic marking.
Compare with a model answer
The count ends at 2. There are two positive transitions, regardless of how many high samples follow each transition.
Check your own work
Go deeper with the right source.
Supporting references and further reading. The worked examples above are original CampusSpark teaching material.
Product documentation; AutoLab uses its own documented educational model.