#define BIT_0 2
#define BIT_1 3
#define BIT_2 4
#define BIT_3 5
/////////////Don't build the circuit without resitors guys/////////////
void binSwitch() {
for (uint8_t Byte = 0; Byte < 16; ++Byte) {
digitalWrite(BIT_0, bitRead(Byte, 0));
digitalWrite(BIT_1, bitRead(Byte, 1));
digitalWrite(BIT_2, bitRead(Byte, 2));
digitalWrite(BIT_3, bitRead(Byte, 3));
Serial.print("Byte = ");
Serial.print(Byte);
Serial.print(" = 0b");
for (int8_t bit = 3; bit > -1; bit--) {
Serial.print(bitRead(Byte, bit));
}
Serial.println();
delay(500);
}
}
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println();
pinMode(BIT_0, OUTPUT);
pinMode(BIT_1, OUTPUT);
pinMode(BIT_2, OUTPUT);
pinMode(BIT_3, OUTPUT);
}
void loop() {
binSwitch();
delay(2000);
}