/*
* 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);
}
Loading
cd74hc4067
cd74hc4067