Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
CD74HC4067.h
00001 //CD74HC4067 Library based on bildr code: "http://bildr.org/2011/02/cd74hc4067-arduino/" 00002 //Ported to mbed by Scott M. O'Hair 00003 // 00004 //sample code: 00005 /* 00006 #include "mbed.h" 00007 #include "CD74HC4067.h" 00008 00009 Serial pc(PB_6, PA_10, 115200); //tx, rx 00010 00011 CD74HC4067 mux1(D8, D9, D12, D11, A0); //S0, S1, S2, S3, SIG 00012 00013 int main() 00014 { 00015 pc.printf("Running MUX test\n"); 00016 while(1) { 00017 //Loop through and read all 16 values 00018 for(int i = 0; i < 15; i++) { 00019 mux1.currentState = mux1.readMux(i); 00020 if (fabs(mux1.portState[i] - mux1.currentState) > BTN_NOISE_THRES) { 00021 pc.printf("Value at channel %i is %f\n", i, mux1.currentState); 00022 mux1.saveState(i, mux1.currentState); 00023 } 00024 } 00025 00026 } 00027 } 00028 */ 00029 00030 00031 00032 #ifndef MBED_CD74HC4067_H 00033 #define MBED_CD74HC4067_H 00034 00035 #include "mbed.h" 00036 00037 #define BTN_NOISE_THRES 0.018f //Define a threshold for the amount of analog change required 00038 00039 class CD74HC4067 { 00040 public: 00041 CD74HC4067(PinName S1, PinName S2, PinName S3, PinName S4, PinName SIG); 00042 void saveState(uint8_t port, float state); 00043 float readMux(uint8_t channel); 00044 float currentState ; 00045 float portState[16]; 00046 00047 private: 00048 DigitalOut _S0; 00049 DigitalOut _S1; 00050 DigitalOut _S2; 00051 DigitalOut _S3; 00052 AnalogIn _SIG; 00053 00054 }; 00055 00056 #endif
Generated on Thu Jul 14 2022 06:26:51 by
1.7.2