warning: comparison between pointer and integer

OP #733461
Lesenswert?

Hallo,

Durch den Code unten soll eine Tasten-Entprellung stattfinden.
Es soll eine positive Flanke abgefragt werden und dann eine Aktion 
auslösen.
Den restlichen Teil des Programmes hab ich mal weggelassen.
Bei dieser Abfrage:
1
if (taster1 == 1) {
Kommt als Compilerwarnung: main.c:85: warning: comparison between 
pointer and integer.
Es funktioniert auch nicht auf dem µC.
Habt ihr eine Idee?
Hier ist mal der betroffene Programmcode:
1
#define TASTERPORT PIND   
2
#define TASTER1    PIND2   
3
#define TASTER2    PIND3  
4

5

6
//############################################################################
7

8
void init(void)
9

10
{
11

12
  TCCR1B |= (1 << CS12) ; TIMSK |= (1 << OCIE1A);
13
  TCCR0 |= (1 << CS00) | (1 << CS02) ; TIMSK |= (1 << TOIE0);
14
  
15
// PORTD = 0b00000000; // Bei Ausgängen: Ausgangsbyte fest setzen. Bei Eingängen: Pullups aktivieren
16
  DDRD = 0b01100000; // Datenrichtungsregister: Eingang = 0, Ausgang =1 (Bit 0-4 und 7 = Eingang, Bit 5 und 6 = Ausgang) Led hängt an PD5 und PD6 gegen GND
17
  Handy_Init();
18
  
19
}
20

21
//Hauptprogramm
22
int main (void)
23
{
24
Handy_Init();
25
init();
26

27

28

29
//############################################################################
30
while (1)
31
{
32

33
char taster1(void)
34
{
35
  static char PinState;
36
  char NewState = TASTERPORT & ( 1 << TASTER1 );
37

38
  if( NewState == PinState )
39
    return 0;
40

41
  NewState = PinState;
42
  return NewState != 0;
43
}
44

45
char taster2(void)
46
{
47
  static char PinState;
48
   char NewState = TASTERPORT & ( 1 << TASTER2 );
49

50
  if( NewState == PinState )
51
    return 0;
52

53
  NewState = PinState;
54
  return NewState != 0;
55
}
56

57

58
if (taster1 == 1) {      // Pin 2 (Taster1) auf 1 abfragen
59
          PORTD |= (1 << PIN5);   // gelbe LED ein für SMS-Versand eingeleidet  
60
      GSM_Init();
61
            }    
62
      else {  
63
        PORTD &= ~(1 << PIN5);     // gelbe LED aus für SMS-Versand eingeleidet
64
      }
65
if (taster2 == 1) {      // Pin 3 (Taster2) auf 1 abfragen
66
      PORTD |= (1 << PIN6);     // gelbe LED ein für SMS-Versand eingeleidet
67
      Send_SMS(); 
68
      }
69
      else {
70
        PORTD &= ~(1 << PIN6);     // gelbe LED aus für SMS-Versand eingeleidet
71
      }      
72
}
73
return (1);
74
}

Schöne Grüße und Frohe Weihnachten

Ello

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