/*

  ## Display
  Uses the HSPI

  |Pin|Use|Note|
  |---|---|----|
  |IO2|TFT_RS|AKA: TFT_DC|
  |IO12|TFT_SDO|AKA: TFT_MISO|
  |IO13|TFT_SDI|AKA: TFT_MOSI|
  |IO14|TFT_SCK||
  |IO15|TFT_CS||
  |IO21|TFT_BL|Also on P3 connector, for some reason|
*/


/******************************************************************************
  Mux_Analog_Input
  SparkFun Multiplexer Analog Input Example
  Jim Lindblom @ SparkFun Electronics
  August 15, 2016
  https://github.com/sparkfun/74HC4051_8-Channel_Mux_Breakout

  This sketch demonstrates how to use the SparkFun Multiplexer
  Breakout - 8 Channel (74HC4051) to read eight, separate
  analog inputs, using just a single ADC channel.

  Hardware Hookup:
  Mux Breakout ----------- Arduino
     S0 ------------------- 2
     S1 ------------------- 3
     S2 ------------------- 4
     Z -------------------- A0
    VCC ------------------- 5V
    GND ------------------- GND
    (VEE should be connected to GND)

  The multiplexers independent I/O (Y0-Y7) can each be wired
  up to a potentiometer or any other analog signal-producing
  component.

  Development environment specifics:
  Arduino 1.6.9
  SparkFun Multiplexer Breakout - 8-Channel(74HC4051) v10
  (https://www.sparkfun.com/products/13906)
******************************************************************************/
/////////////////////
// Pin Definitions //
/////////////////////
const int selectPins[2] = {5, 18}; // S0~5, S1~18
//const int zOutput = 5;
const int zInput = 35; // Connect common (Z) to A0 (analog input)

int wait = 10;

void setup()
{
  Serial.begin(9600); // Initialize the serial port
  // Set up the select pins as outputs:
  for (int i = 0; i < 2; i++)
  {
    pinMode(selectPins[i], OUTPUT);
    digitalWrite(selectPins[i], HIGH);
  }
  pinMode(zInput, INPUT); // Set up Z as an input

  // Print the header:
  Serial.println("Y0\tY1\tY2\tY3");
  Serial.println("---\t---\t---\t---");
}

void loop()
{
  int value[4] = {0, 1, 2, 3};
  
  // Loop through four pins.
  for (byte pin = 0; pin <= 3; pin++)
  {
    selectMuxPin(pin); // Select one at a time
    delay(wait);
    int inputValue = analogRead(zInput); // and read Z
    Serial.print(pin);
    Serial.print(": ");
    //  Serial.print(String(inputValue) + "\t");
    Serial.print(inputValue);
    Serial.print("\t");
  }
  Serial.println();
  delay(1000);
}

// The selectMuxPin function sets the S0, S1, and S2 pins
// accordingly, given a pin from 0-7.
void selectMuxPin(byte pin)
{
  for (int i = 0; i < 3; i++)
  {
    if (pin & (1 << i))
      digitalWrite(selectPins[i], HIGH);
    else
      digitalWrite(selectPins[i], LOW);
  }
}
Loading
esp32-devkit-c-v4
Loading
cd74hc4067