← All exercises

Xor Gate

easy

Turn on a lamp when exactly one of two push buttons is pressed and off otherwise.

What it teaches

Exclusive OR — output is high when exactly one input is high. Use the XOR operator directly, or decompose as (A OR B) AND NOT (A AND B). Reinforces compound boolean expressions.

Inputs and outputs

TagTypeDefaultDescription
In_Button1BOOLFirst push button
In_Button2BOOLSecond push button
Out_LampBOOLLamp drive signal

Required behavior

  • Out_Lamp is 1 when exactly one of In_Button1 or In_Button2 is 1.
  • Out_Lamp is 0 when both In_Button1 and In_Button2 have the same value.