Created
January 23, 2014 15:39
-
-
Save jadudm/8580714 to your computer and use it in GitHub Desktop.
Testing Transistor Gates
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int pinA = 8; | |
int pinB = 9; | |
int lvlA; | |
int lvlB; | |
int delayTime = 3000; | |
void setup () { | |
Serial.begin(9600); | |
pinMode (pinA, OUTPUT); | |
pinMode (pinB, OUTPUT); | |
} | |
void printMsg (int A, int B) { | |
Serial.print("A: "); | |
if (A == 0) { | |
Serial.print("LOW"); | |
} | |
else { | |
Serial.print("HIGH"); | |
} | |
Serial.print(" B: "); | |
if (B == 0) { | |
Serial.print("LOW"); | |
} | |
else { | |
Serial.print("HIGH"); | |
} | |
Serial.print("\n"); | |
} | |
void loop () { | |
// A = 0, B = 0 | |
lvlA = LOW; | |
lvlB = LOW; | |
printMsg(lvlA, lvlB); | |
digitalWrite (pinA, lvlA); | |
digitalWrite (pinB, lvlB); | |
delay (delayTime); | |
// A = 0, B = 1 | |
lvlA = LOW; | |
lvlB = HIGH; | |
printMsg(lvlA, lvlB); | |
digitalWrite (pinA, lvlA); | |
digitalWrite (pinB, lvlB); | |
delay (delayTime); | |
// A = 1, B = 0 | |
lvlA = HIGH; | |
lvlB = LOW; | |
printMsg(lvlA, lvlB); | |
digitalWrite (pinA, lvlA); | |
digitalWrite (pinB, lvlB); | |
delay (delayTime); | |
// A = 1, B = 1 | |
lvlA = HIGH; | |
lvlB = HIGH; | |
printMsg(lvlA, lvlB); | |
digitalWrite (pinA, lvlA); | |
digitalWrite (pinB, lvlB); | |
delay (delayTime); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment