Skip to content
TheChatArchiveThe Chat Archive
Claudeclaude-3-5-haiku-20241022· AnthropicHugging Face LMArena Human Preference 140K

I have a problem. For a project i'm working on i have 4 buttons to be read with only one…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with grok-3-preview-02-24’s answer.
  1. User

    I have a problem.

    For a project i'm working on i have 4 buttons to be read with only one analog in pin in an ESP32C3. for which i'm thinking on doing the usual voltage divider setup. BUT i would like it to have SOME semblance of multi touch by detecting when i click any two buttons at the same time and i know this is possible by some testing and theoretically.

    for example, the usual multi-button voltage divider input works as such: you have a series of resistors and switches conecting each node between these resistors to the analog input. when you press a button the input will read the tension at that node as given by: V * (Req_bottom / (Req_top + Req_bottom), where Req_top and Req_bottom are the Equivalent resistance of the "top" and "bottom" resistors. BUT this also works if you press two switches for current will flow up to switch A the go through their shared connection at the input pin to switch b then on. in this case Req_top is from the first resistor on the VDD to the first switch and Req_bottom is from the second switch to ground

    The problem is: if all values are the same, you can't differentiate the switch at the halfway point to the first and last switches together, and if all values are different the distance between values might be too small for the microcontroller to reliably measure. how do i find these "goldilocks" resistor values?

  2. Claude Assistant

    This is an excellent problem in analog input design! Let me break down a strategic approach to finding those "just right" resistor values:

    The key challenge is creating a unique voltage signature for each button combination that:

    1. Provides clear, distinguishable analog readings
    2. Maximizes the resolution of your ADC
    3. Handles multi-touch scenarios

    Here's a recommended strategy:

    1. Resistance Spacing Strategy

      • Use a non-linear resistance progression
      • Example progression: 1kΩ, 2.2kΩ, 4.7kΩ, 10kΩ
      • This creates "distance" between voltage readings
    2. Voltage Range Optimization

      • Aim to use most of your ADC's voltage range (e.g., 0-3.3V for ESP32)
      • Ensure each button/combination produces a distinct voltage level
      • Use a spreadsheet to calculate voltage levels for each combination
    3. Practical Implementation

      VDD (3.3V)
        |
        R1 (1kΩ)  -- Button 1
        |
        R2 (2.2kΩ) -- Button 2
        |
        R3 (4.7kΩ) -- Button 3
        |
        R4 (10kΩ)  -- Button 4
        |
       GND
      
    4. Calculation Approach

      • Mathematically model each button/combination's voltage
      • Use a script or spreadsheet to simulate all scenarios
      • Look for clear "steps" in voltage readings
    5. ESP32C3 Specific Considerations

      • The ESP32C3's ADC typically has 12-bit resolution (4096 steps)
      • Aim for at least 100-200 steps between button combinations

    Would you like me to elaborate on any of these points or help you draft a specific resistance calculation strategy?

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.