← All exercises

Voting Lamp

easy

Light a lamp when at least two of three push buttons are pressed.

What it teaches

Majority voting (2-of-3). The lamp turns on when any pair of buttons agrees — list the pairs that satisfy the vote and combine them with OR. Introduces n-of-m logic that recurs in safety and fault-tolerance patterns.

Inputs and outputs

TagTypeDefaultDescription
In_ButtonABOOLFirst push button
In_ButtonBBOOLSecond push button
In_ButtonCBOOLThird push button
Out_LampBOOLLamp drive signal

Required behavior

  • Out_Lamp is 1 when at least two of In_ButtonA, In_ButtonB, or In_ButtonC are 1.
  • Out_Lamp is 0 when one or zero buttons are pressed.