Your code doesn't run top to bottom just once. It runs again and again, on a fixed clock: read the inputs, run the logic, write the outputs, repeat. Once this loop makes sense, the rest of the course gets much easier to follow.
An NJ/NX controller runs your Primary Periodic Task on a fixed period (say 1 ms). Every period it does the same three things. Step through one cycle, or let it run.
Input image sensors
Output image actuators
The logic here is out[i] := in[i]: each lamp mirrors its sensor, but only using the values captured at phase 1.
📸 Inputs are frozen for the whole scan. If a sensor flips during Execute, your code won't see it until the next cycle's refresh. That is deliberate: your logic reads one consistent snapshot and never sees a value halfway through a change.
🐶 The watchdog guards the clock. If your program ever takes longer than the task period to execute, the controller logs a Task Period Exceeded error, which NJ/NX treats as a minor fault. Task execution time must always fit inside the period, and that period is the time budget you design to.
🔋 And after power-off? Normal variables reset to their initial values. Only variables you mark Retain keep their last value across a power cycle. Retention is the first topic in the variable scope deep dive.
A sensor turns on during the Execute phase. When does your logic first react to it?