Hallo,

bin noch blutiger Anfänger im Bereich Mikrocontroller Technik will aber für ein Schulprojekt folgendes realisieren:
Ein Touch Schalter soll eine LED zum leuchten bringen.

Bin über die Seite von Martin Junghans gestolpert:

http://www.jtronics.de/elektronik-av...touch-pad.html

und hab mal versucht dies nachzubauen aber halt nur mit einem Taster und LED als Ausgang.
Mein Programm oder besser das abgeänderte von Martin sieht nun wie folgt aus:

#include <stdlib.h>
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#include <util/delay.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 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)

{
DDRA = 0xff;
PORTA = 0x01;
_delay_ms( 50000 );

if ( PINA & (1<<PINA4) )

{
PORTA = 0x01;
}
}

Leider funktioniert es nicht
Kann mir jemand helfen?