/*
Demonstration of a clock signal hooked up to a T flip-flop (or a JK flip-flop with J = K = T)
Check out Entry 25 at https://blog.jochumzen.com/p/entries.html
The left LED indicates the clock signal
The clock signal is hooked up to the the Clock pin of the T flip-flop through an inverter (Note: ACEL inverts input signals - see entry 6)
The T pin is set to 1 (Arduino pin 2, which connects to the T pin, is grounded - ACEL inverts the input)
The output of the T flip-flop is connected to the second LED
Observe that the frequency of the second LED is half the frequency of the first.
You can set the frequency of the clock signal in "diagram.json"
*/
//Library with basic gates
#include <ACELBG.h>
//Create an Arduino board
auto* ard = new ArduinoBoard();
auto* inv = new Inverter();
//Define chips
auto* flipFlop = new TFlipFlop();
//Add all chips to be emulated here
Chip* chips[] = {
flipFlop, inv
};
//Add all connections here
ConnectionBase* connections[] = {
new Connection(ard, 2, flipFlop->T), //
new Connection(ard, 3, inv->X),
new Connection(inv->Y, flipFlop->Clock),
new Connection(flipFlop->Q, ard, 4),
};
//Section 6: 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);
}
void loop() {
emulation.emulate();
}
Q
Print