#define a 5
#define b 6
#define c 7
int adcmux[8];
int digitalmux[8];
void sel(bool C, bool B, bool A) {
digitalWrite(a, A);
digitalWrite(b, B);
digitalWrite(c, C);
}
void baca_input() {
sel (0, 0, 0);
adcmux[0] = analogRead(A0);
digitalmux[0] = digitalRead(11);
sel (0, 0, 1);
adcmux[1] = analogRead(A0);
digitalmux[1] = digitalRead(11);
sel (0, 1, 0);
adcmux[2] = analogRead(A0);
digitalmux[2] = digitalRead(11);
sel (0, 1, 1);
adcmux[3] = analogRead(A0);
digitalmux[3] = digitalRead(11);
sel (1, 0, 0);
adcmux[4] = analogRead(A0);
digitalmux[4] = digitalRead(11);
sel (1, 0, 1);
adcmux[5] = analogRead(A0);
digitalmux[5] = digitalRead(11);
sel (1, 1, 0);
adcmux[6] = analogRead(A0);
digitalmux[6] = digitalRead(11);
sel (1, 1, 1);
adcmux[7] = analogRead(A0);
digitalmux[7] = digitalRead(11);
}
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode (a, OUTPUT);
pinMode (b, OUTPUT);
pinMode (c, OUTPUT);
pinMode (13, OUTPUT);
pinMode (11, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
baca_input();
Serial.println("---DIGITAL---");
for (int i = 0; i < 8; i++) {
Serial.print(digitalmux[i]);
}
Serial.println();
Serial.println("-----ADC----");
for (int i = 0; i < 8; i++) {
Serial.print(adcmux[i]);
Serial.print(" ");
}
Serial.println();
}