Hallo, ich würde gerne lesen was an einem einzelenen Portpin für ein Signal anliegt. Ich würde es gerne über ein
1 | #define
|
machen. Zuerst dachte ich ich könnte
1 | #define MEINPORTPIN PINK2
|
sagen. Das geht aber nicht. Hat jemand eine elegante lösung für mich. Wie mache ich das?
1 | //ATmega2560
|
2 | #define MEINPORTPIN ((PINK & 0x04)>>2)
|
3 | |
4 | |
5 | void main(void) |
6 | {
|
7 | DDRK&=0xFB;PORTK&=0xFB // Port K, Bit 2 -> INPUT, TRISTATE |
8 | |
9 | |
10 | while(1) |
11 | {
|
12 | if (MEINPORTPIN == 1) |
13 | {
|
14 | //mache das
|
15 | }
|
16 | else if (MEINPORTPIN == 0) |
17 | {
|
18 | //mache das
|
19 | }
|
20 | }
|
Grüße