Hallo
Kein Semikolon am Ende der #define-Zeilen, delay.h eingebunden und nach "Richtung ==" geändert:
Code:
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#define PAD_EIN 1
#define PORT_EIN PORTB
#define DDR_EIN DDRB
#define PAD_RS 2
#define PORT_RS PORTC
#define DDR_RS DDRC
#define PAD_RR 4
#define PORT_RR PORTC
#define DDR_RR DDRC
#define PAD_LS 3
#define PORT_LS PORTC
#define DDR_LS DDRC
#define PAD_LR 5
#define PORT_LR PORTC
#define DDR_LR DDRC
int step;
char direction;
void fahren(int Schrittanzahl, char Richtung){
DDR_EIN |= (1 << PAD_EIN);
DDR_LS |= (1 << PAD_LS);
DDR_LR |= (1 << PAD_LR);
DDR_RR |= (1 << PAD_RR);
DDR_RS |= (1 << PAD_RS);
if(Richtung == 1){
PORT_RR |= (1 << PAD_RR);
}
if(Richtung == 0){
PORT_RR &= ~(1 << PAD_RR);
}
if(Richtung == 3){
PORT_LR |= (1 << PAD_LR);
}
if(Richtung == 2){
PORT_LR &= ~(1 << PAD_LR);
}
while(Schrittanzahl--){
PORT_LS = 0;
PORT_RS = 0;
_delay_ms (5);
PORT_LS = 1;
PORT_RS = 1;
_delay_ms (5);
}
}
void tasterabfrage(void){}
int main (void) {
step = 0;
direction = 0;
while(1) {
tasterabfrage();
fahren(step, direction);
}
return(0);
}
Gruß
mic
Lesezeichen