Tutorial: Your First Circuit
Build a simple interactive circuit using the script editor
This tutorial will guide you through creating a simple interactive circuit using the script editor. We will build a basic Logic Tester that lights up an LED when two buttons are pressed.
Prerequisites
Make sure you have Logicarium installed. See the Installation guide if needed.
Building an AND Gate Circuit
Open the Script Editor
Launch Logicarium. If the script editor on the right is collapsed, click the < button at the top-right corner to expand it.
You can also press Tab to toggle the script editor.
Add Components
In the script editor, we'll define our components. We need:
- Two switches (Inputs)
- One AND gate
- One LED (Output)
Clear any existing script and paste:
In switch1 @ 100, 100
In switch2 @ 100, 250
AND logic @ 300, 175
Out led @ 500, 175Click Apply (or the refresh icon). Four nodes should appear on the canvas.
Connect the Wires
Now we tell the signals where to flow. Add these lines to connect:
switch1andswitch2to thelogicgate inputs- The
logicoutput to theled
switch1.out -> logic.in0
switch2.out -> logic.in1
logic.out -> led.inClick Apply. Wires now connect your nodes!
Test Your Circuit!
- Click the button inside switch1 — it toggles to ON
- The LED is still OFF (AND requires both inputs HIGH)
- Click switch2 to toggle it ON
- The LED lights up! Both inputs are HIGH.
Congratulations! You've built a working AND gate circuit.
Complete Script
Here's the full script for reference:
In switch1 @ 100, 100
In switch2 @ 100, 250
AND logic @ 300, 175
Out led @ 500, 175
switch1.out -> logic.in0
switch2.out -> logic.in1
logic.out -> led.inVariations
Simple Inverter
A NOT gate inverts the input signal:
In switch @ 100, 100
NOT inverter @ 250, 100
Out led @ 400, 100
switch -> inverter -> ledWhen the switch is OFF, the LED is ON (and vice versa).
Building an OR Gate
Since only AND and NOT are built-in, let's build OR using De Morgan's Law:
// Define OR: NOT(NOT(a) AND NOT(b))
define OR(a, b) -> (out):
na = NOT a
nb = NOT b
t = na AND nb
out = NOT t
end
// Use it
In switch1 @ 100, 100
In switch2 @ 100, 250
OR logic @ 300, 175
Out led @ 500, 175
switch1 -> logic.in0
switch2 -> logic.in1
logic -> ledThe LED lights up when either switch is ON.
Understanding the Syntax
| Code | Meaning |
|---|---|
In name @ x, y | Create an input switch at position (x, y) |
Out name @ x, y | Create an output LED at position (x, y) |
AND name @ x, y | Create an AND gate at position (x, y) |
NOT name @ x, y | Create a NOT gate at position (x, y) |
a.out -> b.in | Connect a's output to b's input |
momentary | Makes input a push-button instead of toggle |