#include "Arduino.h" #define INPUTS 8 byte touchOut=0; //binary encoded sensors uint16_t rawIn[INPUTS]; uint16_t countedLow[INPUTS]; //count the times input was below threshold (touched) #define TOUCHTHRESHOLD 1000 //below which value input counts as touched. 0=ADCREADINTERVAL) { last_adcmicros=micros(); //Sample all analog Inputs rawIn[0]=analogRead(A0); rawIn[1]=analogRead(A1); rawIn[2]=analogRead(A2); rawIn[3]=analogRead(A3); rawIn[4]=analogRead(A4); rawIn[5]=analogRead(A5); rawIn[6]=analogRead(A6); rawIn[7]=analogRead(A7); //Serial.print(analogRead(A1)); //Serial.print(": "); //Serial.println(micros()-mic); /* Serial.print(rawIn[0]); Serial.print(", "); Serial.print(rawIn[1]); Serial.println();*/ for (uint8_t i=0;i=COUNTEDLOWTHRESHOLD) { //upper limit countedLow[i]=COUNTEDLOWTHRESHOLD; //upper limit. prevent overflow } }else{ //released or not pressed hard enough countedLow[i]=0; //reset counter } } //Serial.print("A0="); Serial.println(rawIn[0]); } // ## Calculate Byte ## byte newTouch=0; for (uint8_t i=0;i=COUNTEDLOWTHRESHOLD) { //key pressed/touched newTouch^=1<MINIMUMSENDDELAY) //delay between last send long enough { if (newTouch!=touchOut) { //touched keys have changed touchOut=newTouch; //update last_send=loopmillis; //Serial.println(touchOut, BIN); //Debug output Serial.write(touchOut); //Send byte } } }