/*
* Connect the four control pins to any Arduino pins.
* This example uses digital pins 4, 5, 6, and 7.
* You will get analog output at the Analog pin that you connect to Sig pin of CD74HC4067
* This examples loops through all channels and prints the analog input at all 16 channels
*/
#include <light_CD74HC4067.h>
const int s0Pin = 49; // S0 pin
const int s1Pin = 51; // S1 pin
const int s2Pin = 53; // S2 pin
const int s3Pin = 52; // S3 pin
// s0 s1 s2 s3: select pins
CD74HC4067 mux(s0Pin,s1Pin,s2Pin,s3Pin); // create a new CD74HC4067 object with its four select lines - 8,9,10,11
const int signal_pin = A0; // Pin A0 - Connected to Sig pin of CD74HC4067
void setup()
{
Serial.begin(9600);
pinMode(signal_pin, INPUT); // Set as input for reading through signal pin
}
void loop()
{
// loop through channels 0 - 15
for (byte i = 1; i < 6; i++) {
mux.channel(i);
int val = analogRead(signal_pin); // Read analog value
Serial.println("Channel "+String(i-1)+": "+String(val)); // Print value
delay(100);
}
Serial.println("");
delay(2000);
}
mega:SCL
mega:SDA
mega:AREF
mega:GND.1
mega:13
mega:12
mega:11
mega:10
mega:9
mega:8
mega:7
mega:6
mega:5
mega:4
mega:3
mega:2
mega:1
mega:0
mega:14
mega:15
mega:16
mega:17
mega:18
mega:19
mega:20
mega:21
mega:5V.1
mega:5V.2
mega:22
mega:23
mega:24
mega:25
mega:26
mega:27
mega:28
mega:29
mega:30
mega:31
mega:32
mega:33
mega:34
mega:35
mega:36
mega:37
mega:38
mega:39
mega:40
mega:41
mega:42
mega:43
mega:44
mega:45
mega:46
mega:47
mega:48
mega:49
mega:50
mega:51
mega:52
mega:53
mega:GND.4
mega:GND.5
mega:IOREF
mega:RESET
mega:3.3V
mega:5V
mega:GND.2
mega:GND.3
mega:VIN
mega:A0
mega:A1
mega:A2
mega:A3
mega:A4
mega:A5
mega:A6
mega:A7
mega:A8
mega:A9
mega:A10
mega:A11
mega:A12
mega:A13
mega:A14
mega:A15
mux1:I15
mux1:I14
mux1:I13
mux1:I12
mux1:I11
mux1:I10
mux1:I9
mux1:I8
mux1:I7
mux1:I6
mux1:I5
mux1:I4
mux1:I3
mux1:I2
mux1:I1
mux1:I0
mux1:COM
mux1:S3
mux1:S2
mux1:S1
mux1:S0
mux1:EN
mux1:VCC
mux1:GND
pot1:GND
pot1:SIG
pot1:VCC