ADCTouch icon indicating copy to clipboard operation
ADCTouch copied to clipboard

Attiny 0/1 series

Open agrimagsrl opened this issue 3 years ago • 3 comments

Is there any chance you can support the new Attiny 0/1 series? ADMUX is not defined (in the Arduino IDE at least).

agrimagsrl avatar Dec 09 '21 11:12 agrimagsrl

Hi Simone, I currently don't have time to work on adding support for new chips. That said, if you (or someone else) want to work on it, I'd be happy to accept pull requests 😉 Cheers

martin2250 avatar Dec 12 '21 09:12 martin2250

I wish I could understand half the code you wrote... I know nothing about registers. I found a different approach that works for my use-case. I will report here just in case someone else needs it. It's dirty naive, but I only need to get a rough idea of how much a touch sensor was "touched".

uint16_t read(uint8_t pin) {
        // write HIGH to pin, then LOW, then read its voltage
        pinMode(pin, OUTPUT);
        digitalWrite(pin, HIGH);
        delay(50);
        digitalWrite(pin, LOW);
        pinMode(pin, INPUT);
      
        uint16_t readings[numReadings];
        uint16_t sum = 0;
      
        for (int i = 0; i < numReadings; i++)
          readings[i] = analogRead(pin);
      
        for (int i = 0; i < numReadings; i++)
          sum += readings[i];
          
        return sum / numReadings;
    }

agrimagsrl avatar Dec 14 '21 10:12 agrimagsrl

Seems like this should do it?
https://github.com/SpenceKonde/ADCTouch/tree/master/src

hghile avatar Feb 27 '24 00:02 hghile