Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.1 kB
3
Indexable
Never
   /*
	 * 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>


	                             // s0 s1 s2 s3: select pins
	CD74HC4067 mux(3, 5, 7, 9);  // create a new CD74HC4067 object with its four select lines - 8,9,10,11


	const int signal_pin = 2; // Pin 2 - 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 = 0; i < 16; i++) {
	        mux.channel(i);
	        int val = digitalRead(signal_pin);                       // Read digital value
	        Serial.println("Channel "+String(i)+": "+String(val));  // Print value
	        delay(500);
	    }
	  delay(2000);
	}