/*
See https://blog.jochumzen.com/ entry 12
Demonstration of a tri-state buffer (also called a three-state switch).
Input: D (data), E (enable)
Output: W (write)
When E = 1, W is equal to D
When E = 0, W = Z (high impedance, "floating", "disconnected")
D E W
0 0 Z
1 0 Z
0 1 0
1 1 1
Set D high or low (press 1). Set E high or low (press 2). Observe the output W.
*/
//Library with basic gates
#include <ACELBG.h>
//Create an Arduino board
auto* ard = new ArduinoBoard();
//Define chips
auto* TriStateBuffer = new ThreeStateSwitch();
//Add all chips to be emulated here
Chip* chips[] = {
TriStateBuffer
};
//Add all connections here
ConnectionBase* connections[] = {
new Connection(ard, 2, TriStateBuffer->D),
new Connection(ard, 3, TriStateBuffer->E),
};
//Setting up the emulation. No need to change
Emulation emulation = Emulation(ard, chips, sizeof(chips)/2,
connections, sizeof(connections)/2);
void setup() {
Serial.begin(9600); Serial.println(); Serial.println("START");
Serial.println();
emulation.makePrintPin(13, 1);
emulation.printOnArdEvent(1);
}
void loop() {
emulation.emulate();
}
Print
D
E