Kurzer Code Attiny 13 wo ist der fehler?

Gast #2668626
Lesenswert?

Sorry für meine blödheit, kann mir jemand sagen, wieso meine rote led 
nicht aufhört zu leuchten (alle anderen blinken wie sie sollen)?

Schaltung: Pins schalten je eine BC548C base, der je eine led (rot, 
gelb, weiß, blau) treibt.
1
/*=================================================================================== 
2
Alle möglichen Portanschlüsse am ATtiny 13 : 
3
               ==============          === 
4
        dW, /RESET, (PB5)   1   20   Vcc                    
5
 PCINT3, CLKI, ADC3,(PB3)   2   19   (PB2), SCK, T0, ADC1, PCINT2 
6
       PCINT4, ADC2,(PB4)___3   18___(PB1), MISO, INT0, AIN1, PCINT1, OC0B 
7
                      GND   4   11   (PB0), MOSI, AIN0, PCINT0, OC0A */
8

9

10
#include <stdbool.h>
11
#include <stdlib.h>
12
#include <stdint.h>
13

14
#include <avr/io.h>
15
#include <avr/interrupt.h>  
16

17
#define F_CPU 9.6E6        
18
#include <util/delay.h>    
19

20

21
void red_on()
22
{
23
  PORTB |= (1 << PB0); 
24
}
25

26
void red_off()
27
{
28
  PORTB &= ~(1 << PB0); 
29
}
30

31
void yellow_on()
32
{
33
  PORTB |= (1 << PB1);
34
}
35

36
void yellow_off()
37
{
38
  PORTB &= ~(1 << PB1);
39
}
40

41
void blue_on()
42
{
43
  PORTB |= (1 << PB2); 
44
}
45

46
void blue_off()
47
{
48
  PORTB &= ~(1 << PB2); 
49
}
50

51
void white_on()
52
{
53
  PORTB |= (1 << PB3); 
54
}
55

56
void white_off()
57
{
58
  PORTB &= ~(1 << PB3); 
59
}
60

61
void clear()
62
{
63
  PORTB &= ~((1<<PB0)|(1<<PB1)|(1<<PB2)|(1<<PB3));
64
}
65

66

67
int main(void) 
68
{        
69
  DDRB  = 0xff;
70

71
  while(1)
72
  {
73
    int mode =0;
74

75
    if (PORTB & 0x10)
76
    {
77
      mode = 1;
78
    }
79

80

81

82
    red_on();
83
    _delay_ms(100);
84
    yellow_on();
85
    _delay_ms(100);
86
    blue_on();
87
    _delay_ms(100);  
88
    white_on();
89
    _delay_ms(100);
90
    
91
    clear();
92
  
93
  
94

95

96
  }
97
                                              
98
  return 0;                        
99
}

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