Below is the code but it produces only a string output. I'm not sure how to work with it but then again I can't figure out how to generate a byte or integer.
int Zin = 12; // input from multiplexer
int Z = 0;
String poll;
int r0 = 0;
int r1 = 0;
int r2 = 0;
int count = 0;
void setup(){
Serial.begin(9600);
pinMode(Zin, INPUT); // data from multiplexer
pinMode(2, OUTPUT); // s0
pinMode(3, OUTPUT); // s1
pinMode(4, OUTPUT); // s2
}
void loop () {
for (count=0; count<=7; count++) {
// select the bit
r0 = bitRead(count,0);
r1 = bitRead(count,1);
r2 = bitRead(count,2);
digitalWrite(2, r0);
digitalWrite(3, r1);
digitalWrite(4, r2);
// read the input pin:
int Z = digitalRead(Zin);
poll = poll + Z;
}
print1();
poll = 0;
}
void print1 () {
Serial.println(poll);
delay(500);
}