µC Software Schwierigkeiten bei Eingang/Ausgang

Gast #3636365
Lesenswert?

Hallo Leute,
ich habe mal eine Frage zu meiner Software (geht leider nicht).
Ich möchte PD0, PD1 als Eingang.
Ich möchte PD3,PD5,PD6,PD7 als Ausgang.
Super wäre es noch wenn man nicht PD0 auslösen kann wenn gerade PD1 
"beschäftigt" ist...

Vielen Dank :)
1
#define F_CPU 1000000
2
#include <avr/io.h>
3
#include <util/delay.h>
4
#include <avr/interrupt.h>
5

6
int main(void)
7
{
8
  DDRD = ( 1 << PD5 )|( 1 << PD6 )|( 1 << PD7 )|(1<<PD3); //ausgänge
9
  PORTD |= (1 << PD0) | (1<<PD1);   //eingänge
10

11

12
  while(1)
13
  {
14
    if(!(PIND & (1 << PD0)))   //eingang PD0 auf GND
15
    {
16
      PORTD |= ( 1 << PD5 );
17
      _delay_ms(100);
18
      PORTD |= ( 1 << PD6 );
19
      _delay_ms(100);
20
      PORTD |= ( 1 << PD7 );
21
      _delay_ms(100);
22
      PORTD &= ~(( 1 << PD5 ) | ( 1 << PD6 ) | ( 1 << PD7 ));
23

24
      while(!(PIND & (1 << PD0))); 
25
    }
26
    
27
    
28
    
29
    if(!(PIND & (1 << PD1)))   //eingang PD1 auf GND
30
    {
31
      PORTD |= ( 1 << PD5 );
32
      _delay_ms(100);
33
      PORTD |= ( 1 << PD6 );
34
      _delay_ms(100);
35
      PORTD |= ( 1 << PD3 );
36
      _delay_ms(100);
37
      PORTD &= ~(( 1 << PD5 ) | ( 1 << PD6 ) | ( 1 << PD3 ));
38

39
      while(!(PIND & (1 << PD1)));
40
    }       
41
  }
42
}

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren