Overview
This is a p5.js sketch of Logic Gates.
Modeled concepts:
- The 6-main Logic Gates
- Simple Input and Button
- Fixed inputs with signals of 0 or 1.
- Button which when pressed, toggles its original value.
- Clock Signal
- Modes a square wave, includes configuration for wave length and duty-cycle (% of time that the signal is sent).
- Push Switch
- Acts a link a spring loaded button, which returns to its default state when not pressed.
- Switches (See Switches - Contact Terminology for details)
- Single Pole, Single Throw
- Single Pole - meaning there is a single input.
- Single Throw - meaning there is a single output.
- Single Pole, Double Throw
- (Flipped) Single Pole, Double Throw
- Single Pole, Single Throw
Controls
Limited controls in this sketch.
Keys:
1
-6
in Examples #1 and #4 cycle the ‘main gate’ through the 6-basic gatesp
will save the current canvas as a PNG.
Mouse:
CLICK
on the yellow-highlighted components toggles their states.
References / Inspiration:
- Wikipedia - Logic Gate
- Texas Instruments - IEEE Standard 91-1984
- Spemco - Electronics 101
- allaboutcircuits.com
- electronics-tutorials.ws
- logic.ly (Interactive circuit design)
- academo.org - Logic Gate Simulator
Links:
Screenshot:
Screen Captures
Example #1 - Demo of basic gates, Pressing 1-6
will cycle through the logic gate types.
Example #2 - Demo of Push Switches
Example #3 - Demo of Pole-Throw Switches
Example #4 - Demo of Clock Signals; includes 4 clocks, from top down:
- Has a wave-length of 180 frames (~3 seconds), and a duty-cyle of 50%.
- Has a wave-length of 90 frames (~1.5 seconds), and a duty-cyle of 50%. (so twice as fast as 1st clock).
- Has a wave-length of 100 frames (~1.5 seconds), and a duty-cyle of 20%.
- Has a wave-length of 100 frames (~1.5 seconds), and a duty-cyle of 80%, and offset of 80 frames (meaning it turns on at the 20th frame, just when the 3rd clock turns off).