QTouchADC Library for Arduino
Contents
QTouchADC on GitHub
https://github.com/dusjagr/QTouchADCTiny/
https://github.com/dusjagr/QTouchADC
QTouchADC finally getting it to work on the Attiny85
Documentation will follow veeeeery soon...
QTouchADC for the CocoMake7 based on Attiny84
QTouch for Water Level Sensing
QTouchADC Library for Arduino
forked from jgeisler0303 on Github
dusjagr converted the code from jgeisler0303 into a library "QTouchADCduino" and tested it again and again.
download here: https://github.com/dusjagr/QTouchADCArduino
It's the first time I tried to write a library, so please don't be too hard on me :-)
Notes on the QTouchADC library
Overview and functionalities
- up to 5 touch sensors can be attached to the AnalogIn pins, one is reserved as referencePin
- allows averaging over many measurements
- reading is very fast, ca 150µs for 1 reading. Averaging will increase to measurement time
- baseline is stable, especially if it runs alone and on battery.
- when the arduino is plugged into a laptop that is on the mains power, noise increases a lot and the measurement is very succeptible to how your body is connected to the room.
Compare to CapSense
- no need of that huge resistor
- fixed measurement time below 1ms
- less (but still) troubles with grounding
http://playground.arduino.cc/Main/CapacitiveSensor
Still needs to be checked / optimized
- playing around with the CHARGE_DELAY and TRANSFER_DELAY (in the library) impacts the noise. needs optimization
- do the reference measurement in the .init? how to use that result in the other part of the library?
- make all measurements for the ref in the .init. but how to save it into a variable that can be used later again and is mapped to the right analog in?
- define the reference pin in the QTouchADCduino.int(refPin) function, so the rest of the .sense is simpler?
- add extra class for just "touch" reading, with a threshold calue. QTouchADCduino.touch(pin, threshold) that gives back a 1 or 0.
- the range of urban's code is higher, but measurement slower... and still getting some massive outliers. could be optimized, fixing the variable definitions? maybe completely change to that one?
Example measurements and tests
Usage
QTouchADCduino.init();
// initializez the analog registers. put it in the void setup() of your code.
QTouchADCduino.sense("sensePin", "refPin", "samples");
//this will give you back the result comparing the ADC measurements from the reference pin and the sensepin, and it will take a number "samples" of measurement and averages them. The resulting difference might go from a negative number to positive, up to values of 600-700 when touched.
A single and averaged reference measurement during the void setup() can be later substracted from the measured values to create positive values only.
Code Example
find more examples on github
<syntaxhighlight lang="c">
- include <QTouchADCduino.h>
void setup() {
Serial.begin(9600);
QTouchADCduino.init();
int ref1 = QTouchADCduino.sense(0, 1, 64);
}
void loop() {
int value1 = (QTouchADCduino.sense(0, 1, 16) - ref1);
Serial.println(value1);
delay(10);
}
</syntaxhighlight>
Links
More on QTouchADC
Urban's original code on SGMK wiki
discussion on mikrocontroller.net
How to make Buttons, Sliders and Wheels
Nice description and implementation on ATMega32u4
https://www.youtube.com/watch?v=Ncu2GZJbluI
QTouch on Attiny and Arduino
Very smoothly working implementation for Arduino ->> can someone translate it to the attiny register-ports? (dusjagr tried and failed...) or even make it into a library?
Library for Arduino for ADC Touch, noisy...
TinyTouch library for attiny (I can't get this to run from the arduino IDE), looks very nice!!!
CapSensing touch library from Dave Mellis