die pollswitch funktion
Code:
unsigned char PollSwitch (void)
{
  unsigned int i;
  int ec_bak = autoencode;              // Sichert aktuellen Zustand

  /*
     Autoencode-Betrieb vom ADC-Wandler unterbinden.
  */
  autoencode = FALSE;

  DDRD |= SWITCHES;                     // Port-Bit SWITCHES als Output
  SWITCH_ON;                            // Port-Bit auf HIGH zur Messung
  ADMUX = (1 << REFS0) | SWITCH;        // AVCC reference with external capacitor
  Sleep (10);

  ADCSRA |= (1 << ADSC);                // Starte AD-Wandlung
  while (!(ADCSRA & (1 << ADIF)))       // Ende der AD-Wandlung abwarten
    ;
  ADCSRA |= (1 << ADIF);                // AD-Interupt-Flag zuruecksetzen

  i = ADCL + (ADCH << 8);               // Ergebnis als 16-Bit-Wert

  SWITCH_OFF;                           // Port-Bit auf LOW
  Sleep (5);

  /*
     Autoencode-Betrieb vom ADC-Wandler wiederherstellen.
  */
  autoencode = ec_bak;

  return (long)i;
}
und das Programm:

Code:
#include <stdlib.h>
#include "asuro.h"

int main(void)
{
  uint8_t t1;
  unsigned char text[16];

  Init();
  SerPrint("\r\nTastsensor Test\r\n");
  while (1)
  {
    t1 = PollSwitch();
    itoa(t1, text, 10);     /* Tastenwert senden */
    SerPrint(text);
    Msleep(500);
  }
}
funktioniert jetzt so :>