FritzeEngineering
Published

Part 1 - Arduino as a NAND gate

Digital technology with Arduino. Understanding digital technology with Arduino – explained in a practical way.

BeginnerWork in progress30 minutes54
Part 1 - Arduino as a NAND gate

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
Resistor 1,5k ohm
×1
LED, Low Current
LED, Low Current
×1
PTS 645 Series Switch
C&K Switches PTS 645 Series Switch
×2

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Breadboard, Plastic
Breadboard, Plastic

Story

Read more

Custom parts and enclosures

Arduino as a NAND gate

Schematics

Arduino as a NAND gate.

Code

Arduino as a NAND gate

Arduino
Arduino simulates a NAND gate.
// Arduino simulates a NAND gate
const int IN_PIN_A = 2;
const int IN_PIN_B = 3;
const int OUT_PIN_Q = 5;

void setup()
{
    //Inputs
    pinMode(IN_PIN_A, INPUT);
    pinMode(IN_PIN_B, INPUT);
    //Outputs
    pinMode(OUT_PIN_Q, OUTPUT);
}

void loop()
{
    bool a, b, q;

    a = digitalRead(IN_PIN_A) == LOW; 	//Read inputs 
    b = digitalRead(IN_PIN_B) == LOW; 
    q = !(a && b);				              //Link signals

    digitalWrite(OUT_PIN_Q,q ? HIGH : LOW);	
}

Credits

FritzeEngineering
4 projects • 0 followers
Hard- and software engineer specialised in embedded systems. Circuit design, PCB layouts and PLC programming.

Comments