Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
PCBX
Published

OD Gate and XOR Gate Test Verification

Streamline your digital design verification with OD Gate and XOR Gate testing.

BeginnerProtip44

Things used in this project

Story

Read more

Schematics

od_gate_Zl031530bE.png

Code

Untitled file

Arduino
#include <LiquidCrystal.h>

// Initialize the LCD library, setting the Arduino pins connected to the LCD
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

// Define the pin connections for the buttons
const int sw1 = 8; // The first button is connected to D2
const int sw2 = 9; // The second button is connected to D3

// Define the pin connection for the LED
const int ledPin = 0; // The LED is connected to D13

// Define the pin connection for the AND gate/open-drain output
const int andODOutputPin = 7; // Assuming the AND gate/open-drain output is connected to D7

void setup() {
  pinMode(sw1, INPUT_PULLUP);
  pinMode(sw2, INPUT_PULLUP);
  pinMode(ledPin, OUTPUT);
  pinMode(andODOutputPin, INPUT); // Set as input mode
  lcd.begin(16, 2); // Initialize the LCD for 16 columns and 2 rows
  lcd.clear(); // Clear the screen
}

void loop() {
  int input1 = digitalRead(sw1);
  int input2 = digitalRead(sw2);
  int andODResult = digitalRead(andODOutputPin); // Read the output of the AND gate/open-drain
  int xorResult = input1 ^ input2; // Calculate the XOR result
  digitalWrite(ledPin, xorResult); // Control the LED

  // Display the results
  lcd.clear(); // Clear the screen at the start of each loop
  lcd.print("SW1: ");
  lcd.print(input1);
  lcd.print(" SW2: ");
  lcd.print(input2);
  lcd.setCursor(0, 1); // Set the cursor position to the second line
  lcd.print("OD: ");
  lcd.print(andODResult);
  lcd.print(" XOR: ");
  lcd.print(xorResult);

  delay(500); // Wait for 500ms before measuring again
}

Credits

PCBX
33 projects • 9 followers
Customer Success: Your one-stop solution for PCB and PCBA services, plus component sourcing. Enjoy FREE online simulation and EDA.
Contact

Comments

Please log in or sign up to comment.