/*-
* This example demonstrates how to read digital signals.
*
* It assumes there are push buttons with pullup resistors connected to the 16
* channels of the 74HC4067 mux.
*
* ------------------------------------------------------------
* Project: arduino-ad-mux-lib
* Source: https://github.com/stechio/arduino-ad-mux-lib.git
*
* Author: Nick Lamprianidis (adaptation by Stefano Chizzolini)
*/
#include <Arduino.h>
#include "Mux.h"
using namespace admux;
/*
* Creates a Mux instance.
*
* 1st argument is the SIG (signal) pin (Arduino digital input pin 3).
* 2nd argument is the S0-S3 (channel control) pins (Arduino pins 8, 9, 10, 11).
*/
Mux mux(Pin(2, INPUT_PULLUP, PinType::Digital), Pinset(8, 9, 10, 11));
Mux muxAnalog(Pin(A0, INPUT, PinType::Digital), Pinset(8, 9, 10, 11));
void setup() {
// Serial port initialization.
// pinMode(2, INPUT_PULLUP);
// digitalWrite(2, HIGH);
Serial.begin(115200); while (!Serial) /* Waits for serial port to connect (needed for Leonardo only) */;
}
/**
* Reads the 16 channels and reports on the serial monitor if the corresponding
* push button is pressed.
*/
void loop() {
int data;
for (int i = 0; i < 5; i++) {
data = muxAnalog.read(i) /* Reads from channel i (returns HIGH or LOW) */;
Serial.print("Pin ");
Serial.print(i);
Serial.print(" = ");
Serial.println(data);
// if(data == LOW) {
// Serial.print("Throttle ");
// Serial.println(i);
// }
}
Serial.println("=========");
Serial.println();
delay(2000);
}
Loading
cd74hc4067
cd74hc4067
Loading
cd74hc4067
cd74hc4067