Library to support the 16:1 Multiplexer Chip, CD74HC4067from TI
Read_MUX.cpp
- Committer:
- melmon
- Date:
- 2015-08-05
- Revision:
- 0:bd14983a5156
File content as of revision 0:bd14983a5156:
#include "Read_MUX.h" #include "mbed.h" Read_MUX::Read_MUX(PinName pin) : _pin(pin) { _pin == 0; } int Read_MUX::readMux(int channel){ DigitalOut s0(p21); DigitalOut s1(p20); DigitalOut s2(p23); DigitalOut s3(p24); DigitalOut led1(LED1); DigitalOut led2(LED2); DigitalOut led3(LED3); DigitalOut led4(LED4); int muxChannel[16][4]={ {0,0,0,0}, //channel 0 {1,0,0,0}, //channel 1 {0,1,0,0}, //channel 2 {1,1,0,0}, //channel 3 {0,0,1,0}, //channel 4 {1,0,1,0}, //channel 5 {0,1,1,0}, //channel 6 {1,1,1,0}, //channel 7 {0,0,0,1}, //channel 8 {1,0,0,1}, //channel 9 {0,1,0,1}, //channel 10 {1,1,0,1}, //channel 11 {0,0,1,1}, //channel 12 {1,0,1,1}, //channel 13 {0,1,1,1}, //channel 14 {1,1,1,1} //channel 15 }; //loop through the 4 sig /* for(int i = 0; i < 4; i ++){ controlPin[i] = muxChannel[channel][i]; } */ s0 = muxChannel[channel][0]; s1 = muxChannel[channel][1]; s2 = muxChannel[channel][2]; s3 = muxChannel[channel][3]; led1= muxChannel[channel][0]; led2= muxChannel[channel][1]; led3= muxChannel[channel][2]; led4= muxChannel[channel][3]; //read the value at the SIG pin int val = _pin.read_u16(); //return the value return val; }