Skip to content

Implement on the esp32 with a multiplexer #4

@hughage

Description

@hughage

Hi there,

Thankyou for this library, tested on the arduino uno and it works great!

I would like to convert this to run the ESP32 using also the 74hc4067 multiplexer. The issues I'm aware of are:

  • Working with 3.3V logic, could be an issue with the multiplexer
  • Adding a dictionary to divert anlogue pins of uno/mega "A0 to A16" calls to relevant analogue read GPIO pins of ESP32
  • Alter "MultiTouchKit::setupPWM()" for the following:
  1. Method to set the timer output pin to esp32 GPIO alternative
  2. Set frequency of PWM to 4MHz, 25% duty cycle (possibly using "ledcSetup(PWM_CHANNEL,PWM_FREQ,PWM_RESOLUTION);"
  3. Alter "analogReference(INTERNAL); //change reference to 1.1V" to ESP32 equivalent

Thinking the following might work:

`void MultiTouchKit::setupPWM() {

#define PWM_PIN 14          // PWM pin output used
#define PWM_FREQ 4000       //set frequency to 4000
#define PWM_CHANNEL 2       // internal timer channel 0
#define PWM_RESOLUTION 12      // bit resolution

ledcSetup(PWM_CHANNEL,PWM_FREQ,PWM_RESOLUTION);  // define which PWM channel, frequency and resolution
ledcAttachPin(PWM_PIN,PWM_CHANNEL);  // Attach to GPIO pin
ledcWrite(PWM_CHANNEL,1024);  // write at 25% duty cycle 
analogSetAttenuation(ADC_0db); // similar function to analogReference(INTERNAL) method?

`
Is there anything that I could be missing or overlooking here?

Thank you in advance for your time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions