/* * mega8_2xtouch.c * * Created: 2013-08-25 18:01:44 * Author: Olek * MCU: ATTINY13A * LED = TP.0 to ground * TOUCH1 = PortD.2 * TOUCH2 = PortD.3 */ #include #include #include #include //TP #define TP PORTB #define TD DDRB #define TI PINB #define LEDPIN1 3 #define LEDPIN2 4 #define TOUCH1 2 #define TOUCH2 0 #define TRIG 1 uint32_t cal1=0, cal2=0; void init(void); uint32_t measure_cap(uint8_t pin); uint32_t calibrate(uint8_t pin); #define NOOP asm volatile("nop" ::) int main(void) { init(); cal1 = calibrate(TOUCH1); cal2 = calibrate(TOUCH2); while(1) { if (measure_cap(TOUCH1)>(cal1+2)) { TP |= (1<(cal2+2)) { TP |= (1<max) { max = ptemp; } } return max; }