Jump to content

Recommended Posts

Posted

Hallo,

 

ich habe mal eine Frage zum Interrupt beim Industrial Digital In 4 Bricklet mit PHP.

 

Aus der Doku geht folgendes hervor:

 

// Enable interrupt on pin 0
$idi4->setInterrupt(1 << 0);

 

setzte ich statt 0 die 15 um auf alle vier Eingänge eine Reaktion zu erhalten passiert nichts, wenn ich aber "1 << " wegfallen lasse funktioniert es.

 

Für was also ist das "1 << " zuständig? Irgendwie steh ich da auf dem Schlauch.

 

Gruß

Posted

Meinst Du sowas?

$idi4->setInterrupt(1 << 15);

Das wird nicht geht, da hier das eine Bit um 15 Stellen geshiftet wird.

 

Du kannst sowas nutzen:

1 << 0  -> 1 shift um 0 Bits == 1

1 << 1  -> 1 shift um 1 Bits == 2

1 << 2  -> 1 shift um 2 Bits == 4

1 << 3  -> 1 shift um 4 Bits == 8

 

oder natürlich die Zahlen 1,2,4,8 und Summen davon verwenden.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...