Wiring and using CD74HC4067 with CircuitPython?

I have a student in my Physical Computing class who is trying to use the CD74HC4067 breakout from Sparkfun. I’ve been helping them out but we’ve hit a wall and could use some help!

Sadly, the product page doesn’t show a wiring diagram. Can you confirm this is correct?

  • - GND to ground (obv!)
  • - VCC to 3.3 or 5V
  • - EN to ground (otherwise the whole thing is off)
  • - S0–S3 to digital pins, set with binary values in the datasheet
  • - SIG to digital pin to read/write
  • - C0–C15 to buttons etc (if unused needs to be tied to ground
  • Can y’all also let me know if this code looks approximately right? I don’t recall seeing any CircuitPython support on Sparkfun so apologies if this isn’t something you all do! Even just a gut-level “that looks about right” would be really helpful.

    import board, digitalio
    
    s0 = digitalio.DigitalInOut(board.D5)
    s1 = digitalio.DigitalInOut(board.D6)
    s2 = digitalio.DigitalInOut(board.D9)
    s3 = digitalio.DigitalInOut(board.D10)
    
    s0.direction = digitalio.Direction.OUTPUT
    s1.direction = digitalio.Direction.OUTPUT
    s2.direction = digitalio.Direction.OUTPUT
    s3.direction = digitalio.Direction.OUTPUT
    
    sig = digitalio.DigitalInOut(board.D13)
    sig.pull = digitalio.Pull.UP
    
    while True:
      # 0 in binary (to read C0)
      s0.value = False
      s1.value = False
      s2.value = False
      s3.value = False
    
      c0 = sig.value
      print('c0', c0)
    
      # C1
      s0.value = True
      s1.value = False
      s2.value = False
      s3.value = False
    
      c1 = sig.value
      print('c1', c1)
    

    Thanks so much!

    We don’t deal with circuitpython too much (other than our XRP https://www.sparkfun.com/products/22230), but it does look about right…likely needs to tested live to be certain. ChatGPT likes it:

    "The wiring connections you’ve described seem correct for using the CD74HC4067 breakout from Sparkfun. Here’s a quick rundown:

    GND to ground.

    VCC to either 3.3V or 5V, depending on your microcontroller’s voltage level.

    EN to ground to enable the breakout.

    S0-S3 to digital pins for setting the channel to read from.

    SIG to a digital pin for reading/writing.

    C0-C15 are the channels to connect your buttons or other sensors. If unused, they should be tied to ground.

    Regarding the code, it appears to be structured correctly for controlling the CD74HC4067 breakout. You’re setting the digital pins for S0-S3 as outputs, which is necessary for controlling the multiplexer channels. The loop structure is also appropriate for continuous reading from the breakout.

    Your code snippet seems to correctly cycle through the channels and read the value from SIG. However, one thing to note is that the pull direction of SIG is set to UP, which means it’s pulled high when not actively driven. This should work fine if your external circuit is designed to pull the signal low when active.

    In summary, your wiring and code setup looks good based on the information provided. You might want to test it with your specific hardware setup to ensure everything works as expected."