static int middle_w = 0;
static int middle_h = 0;
void setup() {
chipName("74LS04");
logicFamily(TTL);
pin(1, "1A");
pin(2, "Y1", OUTPUT);
pin(3, "2A");
pin(4, "Y2", OUTPUT);
pin(5, "3A");
pin(6, "Y3", OUTPUT);
pin(7, "GND", GROUND);
pin(8, "Y4", OUTPUT);
pin(9, "4A");
pin(10, "Y5", OUTPUT);
pin(11, "5A");
pin(12, "Y6", OUTPUT);
pin(13, "6A");
pin(14, "VCC", POWER);
}
static bool a[6];
void loop() {
// Read the first input pin
a[0] = digitalRead(1);
// Write the negation of the first input pin to the first output pin
digitalWrite(2, !a[0]);
// Repeat the logic for the remaining pins
a[1] = digitalRead(3);
digitalWrite(4, !a[1]);
a[2] = digitalRead(5);
digitalWrite(6, !a[2]);
a[3] = digitalRead(9);
digitalWrite(8, !a[3]);
a[4] = digitalRead(11);
digitalWrite(10, !a[4]);
a[5] = digitalRead(13);
digitalWrite(12, !a[5]);
}
#define RED 255, 0, 0
#define GREEN 0, 255, 0
// Define the draw function
void draw(){
// Left
// Loop through each buffer symbol
for (int i = 0; i < 3; i++) {
int y_offset = 65 * i + 15; // Vertical position offset for each symbol
// Draw Post 1
drawLine(26, y_offset, 35, y_offset);
drawLine(35, y_offset, 35, y_offset + 7);
// Draw Post 2
drawLine(26, y_offset + 33, 35, y_offset + 33);
drawLine(35, y_offset + 33, 35, y_offset + 27);
// Draw Triangle
drawTriangle(28, y_offset + 6, 42, y_offset + 6, 35, y_offset + 20);
// Set color based on a values (a1, a2, a3)¿
if (!a[i])
setColor(GREEN);
else
setColor(RED);
// Draw Fill
fillTriangle(30, y_offset + 7, 40, y_offset + 7, 35, y_offset + 18);
// Reset the color
setDefaultColor();
// Draw Dot
drawCircle(35, y_offset + 23, 2);
}
// Right Side
// Loop through each buffer symbol
int offset = 0;
for (int i = 0; i < 3; i++) {
int y_offset = 64 * i + 48; // Vertical position offset for each symbol
// Draw Post 1
drawLine(68, y_offset, 59, y_offset); // x, y -> x, y for Post 1
drawLine(59, y_offset, 59, y_offset + 6); // Vertical line
// Draw Post 2
drawLine(68, y_offset + 33, 59, y_offset + 33); // x, y -> x, y for Post 2
drawLine(59, y_offset + 33, 59, y_offset + 27); // Vertical line
// Draw Triangle
drawTriangle(53, y_offset + 6, 65, y_offset + 6, 59, y_offset + 21); // Coordinates for the triangle
// Set color based on a_values[i]
// --> First iter: target index = 5, i = 0, constant = 5, offset = 0
// --> Second iter: target index = 4, i = 1, constant = 5, offset = 2
// --> Third iter: target index = 3, i = 2, constant = 5, offset = 4
if (!a[i + 5 - offset])
setColor(GREEN);
else
setColor(RED);
// Draw Fill
fillTriangle(54, y_offset + 7, 64, y_offset + 7, 59, y_offset + 19); // Filled triangle
// Reset the color
setDefaultColor();
// Draw Dot
drawCircle(59, y_offset + 23, 2); // Circle at the base of the symbol
// Update the offset
offset += 2;
}
}