/** *****************RECURSIVEDOG PROJECT_ARDUINO CODE******************* * * Reads a 74LS151 32 inputs digital mux * * Builded on Arduino 0007 Alpha * * copyleft 2007 by Enrique Tomas aka quique.at.recursivedog.org * *****************RECURSIVEDOG PROJECT_ARDUINO CODE******************* * ********************************************************************* ***********************www.recursivedog.org************************** * */ //mux variables int input = 8; // digital input to arduino from mux int strobe=7; //digital outputs to control mux inhibidor int e=6; int d=5; int c=4; int b=3; int a=2; // to store the values from mux int val[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; // digital values to control 32 inputs int e_bin[]={LOW,LOW,LOW,LOW,LOW,LOW,LOW,LOW,LOW,LOW,LOW,LOW,LOW,LOW,LOW,LOW,HIGH,HIGH,HIGH,HIGH,HIGH,HIGH,HIGH,HIGH,HIGH,HIGH,HIGH,HIGH,HIGH,HIGH,HIGH,HIGH}; int d_bin[]={LOW,LOW,LOW,LOW,LOW,LOW,LOW,LOW,HIGH,HIGH,HIGH,HIGH,HIGH,HIGH,HIGH,HIGH,LOW,LOW,LOW,LOW,LOW,LOW,LOW,LOW,HIGH,HIGH,HIGH,HIGH,HIGH,HIGH,HIGH,HIGH}; int c_bin[]={LOW,LOW,LOW,LOW,HIGH,HIGH,HIGH,HIGH,LOW,LOW,LOW,LOW,HIGH,HIGH,HIGH,HIGH,LOW,LOW,LOW,LOW,HIGH,HIGH,HIGH,HIGH,LOW,LOW,LOW,LOW,HIGH,HIGH,HIGH,HIGH}; int b_bin[]={LOW,LOW,HIGH,HIGH,LOW,LOW,HIGH,HIGH,LOW,LOW,HIGH,HIGH,LOW,LOW,HIGH,HIGH,LOW,LOW,HIGH,HIGH,LOW,LOW,HIGH,HIGH,LOW,LOW,HIGH,HIGH,LOW,LOW,HIGH,HIGH}; int a_bin[]={LOW,HIGH,LOW,HIGH,LOW,HIGH,LOW,HIGH,LOW,HIGH,LOW,HIGH,LOW,HIGH,LOW,HIGH,LOW,HIGH,LOW,HIGH,LOW,HIGH,LOW,HIGH,LOW,HIGH,LOW,HIGH,LOW,HIGH,LOW,HIGH}; //aux int contador=0; int entrada=0; int a_val=0; int b_val=0; int c_val=0; int d_val=0; int e_val=0; void setup() { beginSerial(9600); pinMode(input, INPUT); pinMode(strobe, OUTPUT); pinMode(e, OUTPUT); pinMode(d, OUTPUT); pinMode(c, OUTPUT); pinMode(b, OUTPUT); pinMode(a, OUTPUT); } void loop() { for(entrada=0;entrada<=31;entrada++) { //select mux input a_val=a_bin[entrada]; b_val=b_bin[entrada]; c_val=c_bin[entrada]; d_val=d_bin[entrada]; e_val=e_bin[entrada]; digitalWrite(a,a_val); digitalWrite(b,b_val); digitalWrite(c,c_val); digitalWrite(d,d_val); digitalWrite(e,e_val); //strobe LOW to read digitalWrite(strobe,LOW); //read value val[entrada] = digitalRead(input); // read input value //strobe HIGH to avoid jitters digitalWrite(strobe,HIGH); } //serial printing //serialWrite('A'); //delay(100); for(contador=0;contador<=31;contador++) { printInteger(val[contador]); delay(10); } printNewline(); }