Guten Tag zusammen, Hab ein kleines Problem: Und zwar wollte ich die Reihenfolge von tastern in einem array abspeichern und nach 5 eingaben diese auf dem LCD wieder ausgeben. wenn ich nun das Programm starte wird zwar "Taste Nr. 0" angezeigt aber wenn ich auf den tastern rum drücke passiert gar nichts??? kann mir da vll jemand behilflich sein? Hier mein Code:
1 | #include <avr/io.h> |
2 | #include "lcd-routines.h" |
3 | #include <stdlib.h> |
4 | #include <util/delay.h> |
5 | |
6 | #define taster_a (!(PIND & (1<<PIND3)))
|
7 | #define taster_b (!(PIND & (1<<PIND2)))
|
8 | #define taster_c (!(PIND & (1<<PIND4)))
|
9 | #define u_int unsigned int
|
10 | |
11 | volatile u_int taster[5], a = 0; |
12 | |
13 | void long_delay(uint16_t ms) |
14 | {
|
15 | for(; ms>0; ms--) _delay_ms(1); |
16 | }
|
17 | |
18 | void kein_taster(void) |
19 | {
|
20 | a = 1; |
21 | while(a == 1) |
22 | {
|
23 | long_delay(20); |
24 | if((!(taster_b)) && (!(taster_a)) && (!(taster_c))) |
25 | {
|
26 | a = 0; |
27 | }
|
28 | }
|
29 | }
|
30 | |
31 | int main(void) |
32 | {
|
33 | taster[0] = 0; |
34 | taster[1] = 0; |
35 | taster[2] = 0; |
36 | taster[3] = 0; |
37 | taster[4] = 0; |
38 | lcd_init(); |
39 | for (u_int counter = 0; counter < 5; counter ++) |
40 | {
|
41 | lcd_clear(); |
42 | set_cursor(0,0); |
43 | char Buffer[20]; |
44 | itoa( counter, Buffer, 10 ); |
45 | lcd_string("Taste Nr."); |
46 | lcd_string( Buffer ); |
47 | while (taster[counter] == 0) |
48 | {
|
49 | if (taster_b) |
50 | {
|
51 | kein_taster(); |
52 | taster[counter] = 1; |
53 | }
|
54 | else if (taster_a) |
55 | {
|
56 | kein_taster(); |
57 | taster[counter] = 2; |
58 | }
|
59 | else if (taster_c) |
60 | {
|
61 | kein_taster(); |
62 | taster[counter] = 3; |
63 | }
|
64 | }
|
65 | }
|
66 | lcd_clear(); |
67 | set_cursor(0,0); |
68 | |
69 | for (u_int counter = 0; counter < 5; counter ++) |
70 | {
|
71 | if (taster[counter] == 1) |
72 | {
|
73 | lcd_string("b"); |
74 | }
|
75 | else if (taster[counter] == 2) |
76 | {
|
77 | lcd_string("a"); |
78 | }
|
79 | else if (taster[counter] == 3) |
80 | {
|
81 | lcd_string("c"); |
82 | }
|
83 | else
|
84 | {
|
85 | lcd_string("err."); |
86 | }
|
87 | }
|
88 | long_delay(5000); |
89 | }
|