Jump to content
View in the app

A better way to browse. Learn more.

Tinkerunity

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Geschrieben

Hallo

Ich möchte meine Lichtschranken über das IO4 auslesen, was im BrickViewer auch einwandfrei funktioniert. Mit dem Beispielcode bekomme ich auch die entsprechenden Ergebnisse, weiß aber nicht, wie ich sie dem Zustand oder dem richtigen Pin zuordnen soll. Kann mir das vielleicht jemand erklären?

Danke schon mal

 

The values are a bit mask that specifies which interrupts occurred and the current value bit mask of the port.

 

For example:

 

        (1, 1) means that an interrupt on pin 0 occurred and currently pin 0 is high and pins 1-3 are low.

        (9, 14) means that an interrupt on pins 0 and 3 occured and currently pin 0 is low and pins 1-3 are high.

 

 

Ergebnis vom Testlauf:

Interrupt by: 0b1
Value: 0b1110
Interrupt by: 0b1
Value: 0b1111
Interrupt by: 0b1
Value: 0b1110

Geschrieben

Der Interrupt den du bei der IO4 bekommst besteht aus 2 Werten: Eine Bitmaske die angibt wer den Interrupt ausgelöst hat und eine Bitmaske die den momentanen Wert darstellt.

 

überprüfen kannst du die Werte folgendermaßen (ungetestet):

 

if bitmask & (1 << 0):
    print "pin 0 high"
else:
    print "pin 0 low"

if bitmask & (1 << 1):
    print "pin 1 high"
else:
    print "pin 1 low"

if bitmask & (1 << 2):
    print "pin 2 high"
else:
    print "pin 2 low"

if bitmask & (1 << 3):
    print "pin 3 high"
else:
    print "pin 3 low"

Geschrieben
  • Autor

so weit so gut, vielen dank. ;D

 

Und schon kommt das zweite Problem. Mit :

io.set_interrupt(1 << 0)

setze ich den Interrupt für Pin 0 und das Kann ich auch durch 1 oder 3 für meine Lichtschranken ersetzen. Aber wie bekomme ich für alle drei Pinne einen Interrupt?

 

Okay, hab die Zeile jetzt durch:

io.set_interrupt(0b1111)

ersetzt...scheint so richtig zu sein, oder?  ;D

Join the conversation

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

Gast
Reply to this topic...

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.