← Academy curriculum

Loops, timing and state machines

ලූප, කාලය සහ තත්ත්ව යන්ත්‍ර

Programming fundamentals · Self-study · Virtual first

AI-generated illustrative engineering concept; not an actual Zenvayra facility
AI-generated illustrative concept; use verified diagrams for connections.

Understand the conceptසංකල්පය තේරුම් ගන්න

Loops repeat operations. A state machine stores a current state and transitions when a condition occurs. Nonblocking timing lets a program check inputs while waiting. Compare elapsed time instead of assuming each loop takes a fixed time.

ලූපයකින් ක්‍රියා නැවත සිදු කරයි. තත්ත්ව යන්ත්‍රයක් වත්මන් තත්ත්වය ගබඩා කර කොන්දේසියක් අනුව වෙනස් වේ. අවහිර නොවන කාල පාලනයෙන් බලා සිටින අතරතුර ආදාන කියවිය හැකිය.

Worked exampleවිසඳූ උදාහරණය

A virtual traffic light cycles green 3 s, amber 1 s, red 3 s: total 7 s.

අතථ්‍ය සංඥා ආලෝකයක කොළ 3 s, කහ 1 s, රතු 3 s නම් චක්‍රය 7 s වේ.

Practice independentlyස්වාධීනව පුහුණු වන්න

Draw a state diagram for the traffic-light exercise. Predict state at 0, 3, 4 and 7 seconds; use the catalogue to locate the matching exercise by title.

සංඥා ආලෝක පරීක්ෂණයට තත්ත්ව සටහනක් ඇඳ 0, 3, 4 හා 7 තත්පරවල තත්ත්වය අනුමාන කරන්න.

Virtual lab / අතථ්‍ය පරීක්ෂණාගාරය ↗
Compare your reasoning (model answer)ඔබේ හේතු සමඟ සසඳන්න (උදාහරණ පිළිතුර)

Assuming transitions occur exactly at the stated boundaries: 0 s green, 3 s amber, 4 s red, 7 s green again.

සීමාවලදී තත්ත්ව වෙනස් නම් 0 s කොළ, 3 s කහ, 4 s රතු, 7 s නැවත කොළ.

Knowledge checkදැනුම පරීක්ෂාව

Why avoid a long blocking delay in a controller?පාලකයක දිගු අවහිරකාරී ප්‍රමාදයක් වැළැක්විය යුත්තේ ඇයි?

Choose an answer first.