Skip to content

Commit c5b202e

Browse files
committed
Added readme & license
1 parent 2f7917d commit c5b202e

File tree

5 files changed

+109
-1
lines changed

5 files changed

+109
-1
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Library for the CMOS 40xx analog multiplexer series.
2+
3+
The MIT License (MIT)
4+
5+
Copyright (c) 2017 Julian Sanin
6+
7+
Permission is hereby granted, free of charge, to any person obtaining a copy
8+
of this software and associated documentation files (the "Software"), to deal
9+
in the Software without restriction, including without limitation the rights
10+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
copies of the Software, and to permit persons to whom the Software is
12+
furnished to do so, subject to the following conditions:
13+
14+
The above copyright notice and this permission notice shall be included in
15+
all copies or substantial portions of the Software.
16+
17+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
THE SOFTWARE.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# CMOS 40xx Analog Multiplexer Series Library
2+
A library to interface with analog multiplexers. Supports 4051, 4052, 4053, and
3+
4067 series multiplexers.
4+
5+
## How to use
6+
```
7+
#include <AnalogMultiplexer.h>
8+
9+
enum {
10+
PIN_EN = 2, // The enable pin of the multiplexer.
11+
PIN_S0 = 3, // Channel selector pin 0.
12+
PIN_S1 = 4, // Channel selector pin 1.
13+
PIN_S2 = 5, // Channel selector pin 2.
14+
PIN_IO = A0 // Use here a pin that can work in analog & digital modes.
15+
};
16+
17+
AMxx4051 mux{ PIN_EN, PIN_S0, PIN_S1, PIN_S2 }; // 8:1 Multiplexer.
18+
19+
void setup() {
20+
Serial.begin(9600);
21+
while (!Serial);
22+
}
23+
24+
void loop() {
25+
mux.pinMode(PIN_IO, INPUT); // PIN_IO will be used to read from the mux.
26+
mux.enable(); // Enable multiplexer.
27+
for (int channel = 0; channel < 8; channel++) {
28+
int value = mux.analogRead(channel); // Do analog read.
29+
Serial.println(value);
30+
}
31+
Serial.println();
32+
}
33+
```

avr/libraries/AnalogMultiplexer/examples/AnalogMultiplexerExample/AnalogMultiplexerExample.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ void setup() {
4242
Serial.println(value);
4343
}
4444
Serial.println();
45-
mux.disable(); // Switch of multiplexer.
45+
mux.disable(); // Switch off multiplexer.
4646
}
4747

4848
void loop() { }

avr/libraries/AnalogMultiplexer/src/AnalogMultiplexer.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,29 @@
1+
/*
2+
* Library for the CMOS 40xx analog multiplexer series.
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2017 Julian Sanin
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
127
#include "AnalogMultiplexer.h"
228

329
AnalogMultiplexer::AnalogMultiplexer(uint8_t pinEnable) {

avr/libraries/AnalogMultiplexer/src/AnalogMultiplexer.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,29 @@
1+
/*
2+
* Library for the CMOS 40xx analog multiplexer series.
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2017 Julian Sanin
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
127
#ifndef ANALOG_MULTIPLEXER_H
228
#define ANALOG_MULTIPLEXER_H
329

0 commit comments

Comments
 (0)