Difference between revisions of "QTouchADC Library for Arduino"
(→QTouchADC Library for Arduino) |
(→forked from jgeisler0303 on Github) |
||
Line 9: | Line 9: | ||
It's the first time I tried to write a library, so please don't be too hard on me :-) | It's the first time I tried to write a library, so please don't be too hard on me :-) | ||
− | [[File: | + | [[File:QTouchADC_example.png|400px]] |
== Notes on the QTouchADC library == | == Notes on the QTouchADC library == |
Revision as of 15:42, 18 February 2015
Contents
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.
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?
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
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!!!