AND vs OR gates — which do I use first?
AND for doors that need two conditions; OR for traps that should fire when any sensor trips. Most raid rings start with OR.
Scrap Mechanic logic gates guide: AND/OR/XOR wiring, sensors, timers, controllers, pistons, and automation patterns for farms, doors, and raid traps on Steam.
kAN Gaming covers AND/OR/XOR gates and memory circuits — the foundation for farm automation and raid traps.
~9 min read
Scrap Mechanic logic gates turn Survival from manual button-mashing into programmable farms, raid traps, and factory lines. Axolot Games ships more than 400+ build parts on Steam (app 387990), and the Program Node family — gates, timers, sensors, controllers, and pistons — is what separates a hobby base from an automated planet.
This Scrap Mechanic logic guide explains AND/OR/XOR wiring, sensor detection, repeating timers, controller sequencing, and piston actuators with tables, callouts, and farm-ready examples. Pair it with the farming guide for raid defense, the building guide for stable contraptions, and the crafting guide for component recipes. Verified July 27, 2026 · Steam.

| Topic | What you will build |
|---|---|
| Logic gates | AND doors, OR alarms, XOR toggles |
| Sensors | Raid triggers, player-only airlocks |
| Timers | Repeating harvest cycles, blinkers |
| Controllers | Multi-step piston sequences |
| Pistons | Crushers, lift doors, sorters |
| Full automation | Raid traps, auto doors, sort lines |
Every Scrap Mechanic logic part speaks in binary: 1 (ON) or 0 (OFF). Buttons, switches, sensors, timers, and gates all push those states through connection ports. When a gate output is ON, its face glows — your visual debugger in the field.
Use the Connect Tool to link ports. Scrap Mechanic enforces direction: you cannot wire two gates as mutual input-and-output; the tool deletes the existing connection if you try. That limitation is why timers sit between flip-flop loops and why controllers exist for multi-step machines.
Logic gates update on ticks — roughly 0.025 seconds per tick with a 1-tick output delay on standard gates. Fast enough for doors and farm traps; slow enough that huge circuits may need planning. For brain-bending designs, the community Logic Gate Simulator (linked from the official wiki) lets you test before spending components in Survival.

Logic parts work in Creative immediately for testing and in Survival once you craft them at a Craft Bot. Creative is the sandbox for prototyping repeating timers or XOR latches without raid pressure. When a design is stable, blueprint the frame and rebuild it at your Mechanic Station base.
Challenge mode also uses logic for timed builds — clearing the first six challenges earns the True mechanic achievement; see the achievements page for the full Challenge route.
Most logic parts need a stable parent block on your lift structure. If bearings spin the whole assembly, wires can snap when the physics engine re-simulates. Anchor logic cores to the ground or a non-moving frame; mount pistons on the moving layer only.
The block exposes six modes: AND, OR, XOR, plus inverses NAND, NOR, and XNOR. Right-click to cycle modes; the face icon shows the active gate. Scrap Mechanic logic gates are the same parts used in community CPU builds — you only need three modes for most Survival automation.

| Gate | Output ON when… | Typical Survival use |
|---|---|---|
| AND | Every connected input is ON | Two-button secure doors, dual-sensor raid alarms |
| OR | Any input is ON | Merge multiple raid sensors into one siren line |
| XOR | Inputs disagree (one ON, one OFF) | Toggle latches, alternating piston phases |
| NAND | NOT all inputs ON | Reset lines for memory circuits |
| NOR | No inputs ON | Repeating timer loops with timers (wiki standard) |
| XNOR | Inputs match (both ON or both OFF) | Sync lines, repeating clock variants |
Wire and into an AND gate, then wire the AND output to a or on your gate. Both buttons must be held or latched ON before the door opens — classic airlock behavior for warehouse loot runs where you do not want Farmbots following you inside.
Connect three facing different raid paths into an OR gate, then into a piston crusher or mounted weapon controller. Any single bot crossing a beam triggers the output — ideal when raid spawn points rotate around your farming guide plots.
XOR outputs ON when inputs differ. Pair with a timer loop and you get alternating piston phases — one arm extends while another retracts. Sorting lines and flip-flop memory both start here; advanced builds chain XOR with NOR gates for stable clocks.
NAND and NOR are AND/OR with inverted output — handy when you want a line idle HIGH and pulsed LOW. The official wiki repeating-timer recipe uses AND + NOR + Timer in a triangle; XNOR repeating clocks appear in community tutorials as an alternative to XOR loops.
Matched by build plan, shared topics, and guide progression — not random related links.
Sensors cast a detection beam; Timers hold an ON pulse for a set duration then release. Together they are the sensory nervous system of Scrap Mechanic automation — raids detected, delays staged, harvesters clocked.

| Part | Role | Knob settings |
|---|---|---|
| Detects objects/players in a beam | Filter by type where supported; aim across choke points | |
| Delays and pulses signals | Duration in ticks/time — shorter = faster cycle | |
| Manual ON/OFF kill switch | Hard-disable repeating loops or trap arms | |
| Momentary pulse | Manual door open, single-shot piston fire |
Mount sensors at ankle height across field entrances — Haybots and Totebots trip beams reliably at ground level. Point beams across chokepoints rather than wide open fields; fewer false positives from your own vehicles. Feed sensor outputs into OR gates when covering multiple lanes, then into piston crushers or mounted weapons.
For player-only doors, combine a sensor with an AND gate tied to an Enter button inside the base so Farmbots cannot follow even if they touch the outer switch.
A repeating timer needs at least two logic gates + one timer + optional switch (see wiki *Building: Repeating Timer*). Wire OR → XNOR → AND → Timer → back to OR, or the AND/NOR/Triangle variant. Adjust timer duration for crop harvest intervals or trap re-arm delays.
Always add a switch on the kill line so you can silence the loop during building — otherwise pistons hammer while you align bearings.
Controllers sequence multiple outputs from one input — perfect for garage doors, multi-stage traps, or synchronized piston walls. convert logic ON signals into linear motion: push crops into collectors, smash bots, or lift airlock doors.
Mount pistons on sturdy frames. Axolot Games's physics engine transfers force through lift blocks — a piston on a wobble bearing can yeet the whole trap sideways during a level-5 raid.

Connect a gate output to a , then wire each controller channel to a piston, bearing brake, or mounted tool. Controllers fire steps in order — use them when a single pulse must extend three walls before arming a weapon.
For garage doors, pair a controller with timed piston pairs: one row extends to lift, a second row slides the gate. Test in Creative with no bots so you can rewind mis-timed channels without losing crops.
Raid traps often use overhead pistons on OR-gated sensors — bot enters, piston slams, timer rearms after two seconds. Bot splat and junkyard achievements count creation kills; piston crushers rack up Totebot and Haybot totals passively during farmbot raids.
Horizontal pistons make fine sorters: extend to push items off a conveyor bearing, retract to let the next stack pass. Combine with XOR-timed arms for alternating lanes.
These four patterns cover most Scrap Mechanic automation needs from early Survival through Chapter 2 mining hubs. Copy one block at a time; do not merge raid traps with harvest loops until each sub-circuit works alone.

| Build | Core parts | Goal |
|---|---|---|
| Dual-button AND door | 2× , , | Stop Farmbots entering base |
| OR-gated raid trap | 3× , , , | Passive kills during raids |
| Repeating timer farm clock | 2× , , , | Cycle harvesters or sprinklers |
| Warehouse airlock | , , 2× , | Loot runs without bot tail |
Place Button A outside and Button B inside, both wired to an AND gate driving a horizontal piston door. You must press inside first to arm, then outside to enter — bots cannot random-walk both buttons. Upgrade to sensors once you craft them.
Surround the field with three sensors aimed at raid spawn lanes. OR gate → timer (0.5s) → piston crusher. Timer rearms after each smash so one bot does not drain the line ON forever. Pair with the farming guide raid calendar so you power traps before warnings.

Build the OR–XNOR–AND–Timer loop from the sensor section; hang a Light or Controller on the XNOR output. Flip the master switch OFF while aligning, then ON for overnight crop lighting or timed harvester bearings.
After a warehouse guide run, drop loot on a bearing conveyor. Sensor detects item stack → piston pushes left if ON, timer clears → next sensor sorts another tier. XOR alternates lanes when two pistons would collide.
AND for doors that need two conditions; OR for traps that should fire when any sensor trips. Most raid rings start with OR.
Yes — craft Program Node parts at Craft Bots after unlocking tiers at the Mechanic Station. Creative is only for risk-free testing.
Gate states restore asynchronously on chunk load. Add a switch default-OFF or a short delay timer before explosives arm.
Community builds include calculators and displays using XOR latches and binary adders — start with the wiki flip-flop, then scale up in Creative.
Both work. Gates for simple ON/OFF; controllers when one button must run multiple pistons in sequence.
OR-gated sensors into piston crushers along spawn paths, plus walls from the building guide. Automate before expanding to level-5 raid farm size.
Matched by build plan, shared topics, and guide progression — not random related links.