Ich danke euch allen für euer bemühen hab es gelöst bekommen.Ich sollte mir mal angewöhnen tutorialsbis zum ende zu lesen.Hier der Code.
Code:
/* Timer0 8-Bit Vorteil = 1024 mit 1Mhz */
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/signal.h>
#include <avr/iom32.h>
#include <avr/delay.h>
volatile int counter;
int main() {
DDRD |= (1<<PD6); /*Ausgang*/
TCCR0 = (1<<CS00)|(1<<CS02);/*CPU-Takt / 1024*/
TIMSK = (1<<TOIE0); /* Timer0 Overflow Interrupt enable*/
TCNT0 = 0; /*Timer auf o setzen*/
sei(); /* Global Enable Interrupt Flag setzen */
while(1)
{
if (counter == 1) {
PORTD |= (1<<PD6);/*Pull up an*/
PIND |= (1<<PD6); /*High*/
_delay_ms(100);
counter = 0;
}
if (counter == 0)
{
PORTD &= ~(1<<PD6);/*Pull up an*/
PIND &= ~(1<<PD6); /*High*/
}
}
}
SIGNAL (SIG_OVERFLOW0) /*Interrupt-Routine*/
{
counter++; /*um eins inkrementieren*/
}
Lesezeichen