Compare commits
3 Commits
12a0d80bbe
...
295fbaef2a
Author | SHA1 | Date |
---|---|---|
interfisch | 295fbaef2a | |
interfisch | 5e3ffbc1a0 | |
interfisch | b5a00b9926 |
|
@ -5,13 +5,12 @@ byte touchOut=0; //binary encoded sensors
|
||||||
uint16_t rawIn[INPUTS];
|
uint16_t rawIn[INPUTS];
|
||||||
|
|
||||||
uint16_t countedLow[INPUTS]; //count the times input was below threshold (touched)
|
uint16_t countedLow[INPUTS]; //count the times input was below threshold (touched)
|
||||||
#define TOUCHTHRESHOLD 700 //below which value input counts as touched. 0<x<1024
|
#define TOUCHTHRESHOLD 1000 //below which value input counts as touched. 0<x<1024
|
||||||
#define COUNTEDLOWTHRESHOLD 10 //how many times input has to be sampled as low in a row to count as real touch.
|
#define COUNTEDLOWTHRESHOLD 10 //how many times input has to be sampled as low in a row to count as real touch.
|
||||||
// Inputdelay is given by: COUNTEDLOWTHRESHOLD*ADCREADINTERVAL
|
// Inputdelay is given by: COUNTEDLOWTHRESHOLD*ADCREADINTERVAL
|
||||||
|
|
||||||
unsigned long last_adcmicros=0;
|
unsigned long last_adcmicros=0;
|
||||||
//#define ADCREADINTERVAL 2000 //in microseconds. interval to read all adc values
|
#define ADCREADINTERVAL 2000 //in microseconds. interval to read all adc values
|
||||||
#define ADCREADINTERVAL 20000 //in microseconds. interval to read all adc values
|
|
||||||
|
|
||||||
unsigned long last_send=0;
|
unsigned long last_send=0;
|
||||||
#define MINIMUMSENDDELAY 10 //in milliseconds. minimum delay between serial sends
|
#define MINIMUMSENDDELAY 10 //in milliseconds. minimum delay between serial sends
|
||||||
|
@ -50,11 +49,11 @@ void loop() {
|
||||||
//Serial.print(analogRead(A1));
|
//Serial.print(analogRead(A1));
|
||||||
//Serial.print(": ");
|
//Serial.print(": ");
|
||||||
//Serial.println(micros()-mic);
|
//Serial.println(micros()-mic);
|
||||||
|
/*
|
||||||
Serial.print(rawIn[1]);
|
Serial.print(rawIn[0]);
|
||||||
Serial.print(", ");
|
Serial.print(", ");
|
||||||
Serial.print(rawIn[1]);
|
Serial.print(rawIn[1]);
|
||||||
Serial.println();
|
Serial.println();*/
|
||||||
|
|
||||||
for (uint8_t i=0;i<INPUTS;i++){ //for all inputs
|
for (uint8_t i=0;i<INPUTS;i++){ //for all inputs
|
||||||
if (rawIn[i]<=TOUCHTHRESHOLD) { //touch detected (input low at this sample)
|
if (rawIn[i]<=TOUCHTHRESHOLD) { //touch detected (input low at this sample)
|
||||||
|
@ -89,7 +88,7 @@ void loop() {
|
||||||
touchOut=newTouch; //update
|
touchOut=newTouch; //update
|
||||||
last_send=loopmillis;
|
last_send=loopmillis;
|
||||||
//Serial.println(touchOut, BIN); //Debug output
|
//Serial.println(touchOut, BIN); //Debug output
|
||||||
//Serial.write(touchOut); //Send byte
|
Serial.write(touchOut); //Send byte
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue