CampusSpark
ORIGINAL CAMPUSSPARK GUIDE

Count events rather than held signals

BeginnerExplanation · worked example · practice

A rising-edge counter reacts to false-to-true transitions, not every scan with a true signal.

  1. Reset the example counter.
  2. Pulse the sensor high, then return it low.
  3. 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.

  1. Starting at zero, false produces count 0. The first false→true transition produces count 1.
  2. Another true sample keeps count 1 because there is no new rising edge. Returning false still leaves count 1.
  3. 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.

Check your reasoning

A reset CTU sees false,true,true,false,true. What is its final count?

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.

Siemens programming documentation

Product documentation; AutoLab uses its own documented educational model.

Lesson and answer rationale reviewed 27 October 2026. A practice answer is not an official exam score.
Try the counting projects

Learning support, not an official certificate, professional assessment or automatic grade. Use original provider requirements for your examination or application.

Private AI