The Code to Emulate the AND logic gate in 8 pin DIP form [edit, fixed, only outputs High when BOTH are HIGH
/* Instructions
1. Upload the ISP sketch to an Arduino board.
2. Program the attiny accordingly.
3. Upload this sketch via Aruduino as ISP
*/
//Arduino Emulating a Logic AND gate
//I Plan on doing a library of these, either to temp replace
//a faulty IC, or to improve on one..
//for example, No need to tie these pins down with pull up/down resistors
//add extra functionality of logic
void setup()
{
// put your setup code here, to run once:
pinMode(4,INPUT); // pin 3
pinMode(3,INPUT); //pin 2
pinMode(0,OUTPUT); //pin 5 (this is your Logic HIGH/LOW)
}
void loop()
{
boolean Status1 = digitalRead(3);
boolean Status2 = digitalRead(4);
if ((Status1==HIGH) && (Status2==HIGH))
{
digitalWrite(0,HIGH); //Your Logic Result on Pin 5
//add a delay for example
//delay(400);
}
else
digitalWrite(0,LOW);
}