Using the basic functionality of the Logic Gates Simulator only requires a USB mouse, but the functionality and ease of use is expanded if you also have a USB keyboard connected.
Add Parts
To add a new part to the workspace first click the 'add' button in the top left corner. Once the toolbox grid is shown click the part to add. Finally, click on the workspace in the location where the part should get put.
The available parts are:
- And Gate - Outputs logic signal 1 when both inputs are logic signal 1, otherwise outputs 0.
- Nand Gate - Outputs logic signal 1 when at least one input signal is 0, otherwise outputs 0.
- Or Gate - Outputs logic signal 1 when at least one input signal is 1, otherwise outputs 0.
- Nor Gate - Outputs logic signal 1 when both input signals are 0, otherwise outputs 0.
- Not Gate - Outputs logic signal 1 when the input signal is 0 and outputs logic signal 0 when input signal is 1.
- Xor Gate - Outputs logic signal 1 when one input signal is 1 and the other input signal is 0, otherwise outputs 0.
- Xnor Gate - Outputs logic signal 1 when both input signals are 1 or both input signals are 0, otherwise outputs 0.
- Virtual Push Button - A circle push button that can be clicked with the mouse to toggle the logic signal that it outputs between 1 and 0.
- Output Panel - A basic rectangle visual output that shows a 1 or 0 based on the logic signal that is input to it.
- NeoPixel Output - Accepts 3 logic signal inputs that correspond to red, green, and blue. The NeoPixels on the Fruit Jam are updated to reflect the color matching the value of logic signals being input.
- Physical Button - A circle button that is hooked up to one of the hardware buttons on the Fruit Jam. Pressing the matching physical button will set the logic signal output to 1 and releasing the button will return the signal to 0.
- Wire - A straight or 90 degree turn line that connects two entities together. Logic signal flows through the wire getting passed from outputs of one entity to inputs of another.
- Signal Transmitter - Accepts a logic signal in and transmits the signal to all paired receivers. It's possible to make up to 5 transmitters at once. Transmitters are assigned a letter A-E.
- Signal Receiver - Receives signal value from the paired transmitter. Multiple receivers can be paired to the same transmitter. It will be paired to the transmitter matching it's letter.
Move Parts
To move a part that is already on the workspace, right click on it to pick it up attaching it to the mouse cursor. Then move the mouse to the desired location and left click to put the part down at the location of the cursor.
Delete Parts
Deleting parts is similar to moving them. Start by right clicking on a part that is on the workspace to pick it up. Then move the mouse up to the add button in the top left and left click on it. When a part is attached to the cursor clicking the add button will remove the part from the cursor thus deleting it from existence.
Toggle Part States
Wires, logic gates, SignalTransmitter, SignalReceiver, and the NeoPixelOutput can be left clicked to toggle or cycle through possible states. For logic gates and the NeoPixelOutput left clicking them will toggle between the inputs being to the left of the gate or being above and below the gate.
For Wires, they'll cycle between the possible straight and 90 degree connections that are supported by the simulator.
For signal transmitter and receivers clicking cycles between the available pairing letters A-E.
With a USB mouse and the above actions you can do all of the basics with the simulator: laying out logic gates, buttons, output panels, and NeoPixelOutputs. Hooking up buttons to the logic gate inputs will allow you to experiment with the different logical rules that govern each gate. Use the NeoPixelOutput if you want to see that glowing rainbow goodness instead of cold logical ones and zeros.
Advanced Usage
Connecting a USB keyboard to the Fruit Jam it will unlock some more advanced capabilities of the simulator. The two biggest features unlocked are the ability to scroll the workspace and saving/opening the workspace into any of 10 available storage slots. All features supported by the keyboard allow the definition of custom Hotkeys.
Custom Hotkeys
There is a dictionary mapping for hotkeys that makes it easy to customize the hotkeys instead of sticking with the defaults. The default hotkeys dictionary is shown below. The dictionary maps byte-strings of keyboard keypress data to strings that represent the possible actions.
HOTKEYS = {
b"\x1b[A": "scroll_up", # up arrow
b"\x1b[B": "scroll_down", # down arrow
b"\x1b[C": "scroll_right", # right arrow
b"\x1b[D": "scroll_left", # left arrow
b"q": "eyedropper",
b"s": "save",
b"o": "open",
b"a": "add",
b"i": "import",
b"\x08": "remove", # backspace
b"\x1b[3~": "remove", # delete
}
To customize the hotkeys, copy this dictionary into code.py, replace the byte-string keys with whatever keyboard press events you want to use for each action then add it as the value for keyword argument hotkeys to the Workspace constructor.
workspace = Workspace(neopixels, (btn_1, btn_2, btn_3), hotkeys=HOTKEYS)
Scrolling
Scrolling uses the arrow keys by default, and is very straight forward. Press the arrow key matching the direction you want to scroll and the workspace will get shifted revealing more space in the specified direction.
Save, Import and Open Workspace
The save and open feature makes use of the CPSAVES partition of flash storage to save JSON files that represent the state of the workspace and all entities on it.
To save the current workspace, press the 's' key on the keyboard. A prompt will appear asking for a slot number save to. Enter any number 0-9. The current workspace will get serialized to JSON and saved in a file associated with the selected slot number.
To open from a saved slot, press the 'o' key on the keyboard. A prompt will appear asking for a slot number to open from. Enter any number 0-9. It will attempt to load the the file for the given slot number and populate the workspace based on the data contained within it. If there was no save file in that slot it will output a message indicating so.
It's possible to copy the save files out of CPSAVES and send them to your friends. To import a save file save it in CIRCUITPY with the exact filename logic_gates_import.json. Press the 'i' on the keyboard. A prompt will appear asking for a slot number to import the file into. Enter any number 0-9. It will copy the contents of logic_gates_import.json into the specified save slot.
Convenience Actions
The remaining hotkeys don't do anything functionally new, instead they make existing actions a little more quick and convenient.
- Add - Pressing the 'a' key will open the toolbox grid, the same as if the add button in the top left corner were clicked.
- Remove - Pressing 'del' or 'backspace' when there is an entity attached to the mouse will remove that entity from the mouse thus deleting it from the existence.
- Eyedropper/Pipette - Pressing the 'q' key will activate the eyedropper or pipette action. This is similar to the tool by the same name in photo editing applications. It allows you to quickly duplicate existing parts that are on the workspace. To use it, move your mouse to the part that you want to duplicate and press 'q', a copy of the entity will appear and be attached to the mouse ready for you to move it and place it on the workspace. If there is already an entity attached to the mouse then pressing 'q' will remove the attached entity, the same as if 'del' or 'backspace' were pressed. This action and it's default key 'q' are an homage to the video game Factorio which has the same action on this hotkey by default, and was part of the inspiration for this simulator.
Page last edited October 31, 2025
Text editor powered by tinymce.