- LiFePO4 Speicher Test         
Ergebnis 1 bis 10 von 14

Thema: Pinabfrage mehrerer Pins

Baum-Darstellung

Vorheriger Beitrag Vorheriger Beitrag   Nächster Beitrag Nächster Beitrag
  1. #1
    Neuer Benutzer Öfters hier
    Registriert seit
    10.02.2011
    Beiträge
    26

    Pinabfrage mehrerer Pins

    Tag zusammen! Ich möchte PORTB 1 bis 4 abfragen?
    Habe schon vieles probiert aber nichts hat wirklich funktioniert!

    Hier mein letzter versuchUnd wenn das denn mal geht.... giebt es eine kürzere Möglichkeit???)

    Code:
    int anzahl_Zyl(void)        //fragt BP1-PB4 ab und giebt Einstellung Zylinderanzahl zurück
    {
    
    DDRB |= 0x00;   
    int a = 0;
                                                                                                     //PORTB   765 4 321 0
    if((PINB |= ~(1<<PINB1) && (PINB |= ~(1<<PINB2) && (PINB |= ~(1<<PINB3) && (PINB &   (1<<PINB4))a =1;    //000 1 000 0
    if((PINB |= ~(1<<PINB1) && (PINB |= ~(1<<PINB2) && (PINB &   (1<<PINB3) && (PINB |= ~(1<<PINB4))a =2;    //000 0 100 0
    if((PINB |= ~(1<<PINB1) && (PINB |= ~(1<<PINB2) && (PINB &   (1<<PINB3) && (PINB &   (1<<PINB4))a =3;    //000 1 100 0
    if((PINB |= ~(1<<PINB1) && (PINB &   (1<<PINB2) && (PINB |= ~(1<<PINB3) && (PINB |= ~(1<<PINB4))a =4;    //000 0 010 0
    if((PINB |= ~(1<<PINB1) && (PINB &   (1<<PINB2) && (PINB |= ~(1<<PINB3) && (PINB &   (1<<PINB4))a =5;    //000 1 001 0
    if((PINB |= ~(1<<PINB1) && (PINB &   (1<<PINB2) && (PINB &   (1<<PINB3) && (PINB |= ~(1<<PINB4))a =6;    //000 0 110 0
    if((PINB |= ~(1<<PINB1) && (PINB &   (1<<PINB2) && (PINB &   (1<<PINB3) && (PINB &   (1<<PINB4))a =7;    //000 1 110 0
    if((PINB   & (1<<PINB1) && (PINB |= ~(1<<PINB2) && (PINB |= ~(1<<PINB3) && (PINB |= ~(1<<PINB4))a =8;    //000 0 001 0
    if((PINB   & (1<<PINB1) && (PINB |= ~(1<<PINB2) && (PINB |= ~(1<<PINB3) && (PINB &   (1<<PINB4))a =9;    //000 1 101 0
    if((PINB   & (1<<PINB1) && (PINB |= ~(1<<PINB2) && (PINB &   (1<<PINB3) && (PINB |= ~(1<<PINB4))a =10;   //000 0 101 0
    if((PINB   & (1<<PINB1) && (PINB |= ~(1<<PINB2) && (PINB &   (1<<PINB3) && (PINB &   (1<<PINB4))a =11;   //000 1 101 0
    if((PINB   & (1<<PINB1) && (PINB &   (1<<PINB2) && (PINB |= ~(1<<PINB3) && (PINB |= ~(1<<PINB4))a =12;   //000 0 011 0
    
    return a;
    
    }
    Und die einzelne Abfrage eines Pins auf logisch 0 habe ich bis jetzt auch nicht gefunden!

    Grüße Stephan
    Geändert von masterx (07.03.2011 um 18:42 Uhr)

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •  

Solar Speicher und Akkus Tests