# AND Gate (`and`)

> Outputs 1 only when every input read is above 0.5.

![and](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/and.svg)

[Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/and/)

**Group:** Control · **Kind:** `{"block":"and","kind":"control"}`

## When to use it

Use it to combine enable and fault signals, for example to pass a gate command only while no fault is active. Use OR Gate when one input is enough.

## Pins

| Pin | Domain | Meaning |
|---|---|---|
| `in1` | signal | First input; true above 0.5 |
| `in2` | signal | Second input; true above 0.5 |
| `in3` | signal | Third input, read if n is 3 or 4 |
| `in4` | signal | Fourth input, read if n is 4 |
| `out` | signal | Output, always 0 or 1 |

## Common parameters

- `n`: How many inputs the gate has (Default: 2)

## Parameters

| Key | Unit | Default | Typical range | Description |
|---|---|---|---|---|
| `n` | — | 2 |  | How many inputs the gate has |

_Parameter descriptions are in English in both languages._

## Model

The first n inputs are read (n = 2 by default, up to 4). An input is true when it is above 0.5. The output is 1 when all n inputs are true and 0 otherwise. The gate is combinational: it has direct feedthrough and follows its inputs at every solver step.

## Common mistakes

- With the default n of 2, the pins in3 and in4 are ignored even when wired, so set n to the number of inputs you use. An input that is not wired reads 0, which keeps the output at 0.
- The threshold is 0.5, so an analog value such as a 0.4 duty counts as false. A loop made only of gates is refused; use SR Latch or D Flip-Flop to store a state.

Problems rules: `compile.error`

## Datasheet and sources

There is no datasheet. n is the number of signals you combine. The logic levels come from your protection or enable scheme, such as a fault comparator or a gate-enable signal from the controller.

## Example

Open the example with the command `file.openExample` and the name `demo:and`.

---
Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand.
