Gast
#1930562
Hallo, bin blutiger Anfänger in Sachen Mikrocontroller und brauche bei dem Touch Sensor Programm etwas Hilfe: Wollte das Programm von Peter Danneger mal testen Beitrag "Re: qtouch - sekt oder selters" bekomm es aber irgendwie nicht zum laufen: Hab alle benötigten Komponenten besorgt: 33nF Kondensator welcher an Pin A0 und B0 angeschlossen wird 1kOhm Widerstand (muss der an A0 oder B0 angeschlossen werden 1 Elektrode (einfache Leiterplatte mit dem Draht zum Widerstand) Das Programm hab ich nur um die Ansteuerung der LED erweitert (weiß leider nicht ob das korrekt ist) Hier mal das Programm: #include <avr\io.h> #include <util\atomic.h> #define SK_A0 (1<<5) #define SK_B0 (1<<4) #define SK_A1 (1<<2) #define SK_B1 (1<<3) #define SK_A2 (1<<0) #define SK_B2 (1<<1) #define SK_A012 (SK_A0 | SK_A1 | SK_A2) #define SK_B012 (SK_B0 | SK_B1 | SK_B2) #define MAX_CYCLE 2000 uint16_t keys[3]; void read_senskey( void ) { uint16_t i = MAX_CYCLE; uint8_t a, b, x, y; ATOMIC_BLOCK(ATOMIC_FORCEON){ a = DDRA & ~(SK_A012 | SK_B012); b = PORTA & ~(SK_A012 | SK_B012); y = SK_B012; // input mask do{ DDRA = a; // tristate PORTA = b | SK_B012; DDRA = a | SK_B012; // Bx = strong high DDRA = a; // tristate PORTA = b; DDRA = a | SK_A012; // Ax = strong low if( --i == 0 ) // timeout break; x = y & PINA; // not immediately after set DDRA !!! if( x ){ if( x & SK_B0 ) keys[0] = i; if( x & SK_B1 ) keys[1] = i; if( x & SK_B2 ) keys[2] = i; } y ^= x; // clear processed input }while( y ); // all inputs done DDRA = a | SK_A012 | SK_B012; // discharge } } int main (void) { if ( PINA & (1<<PINA0) ) { PORTC = PORTC | 0x01; } } Mal noch ne andere Frage muss die Elektrode mit GND verbunden werden? Hab das Programm mal aufgespielt aber leider tut sich nichts. LED ist in Ordnung und auch richtig verbunden. Hab auch mal ein Multimeter an den Kondensator geklemmt, tut sich leider auch nichts. Hoffe ihr könnt mir helfen, im Grunde genommen will ich nur eine Led über eine Touch Elektrode anschalten können.