Skip to content

Instantly share code, notes, and snippets.

@jadudm
Created January 23, 2014 15:39
Show Gist options
  • Save jadudm/8580714 to your computer and use it in GitHub Desktop.
Save jadudm/8580714 to your computer and use it in GitHub Desktop.
Testing Transistor Gates
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