GpioPinInput

Heute ist Stammtischzeit:
Jeden Donnerstag 20:30 Uhr hier im Chat.
Wer Lust hat, kann sich gerne beteiligen. ;)
  • Hallo,

    kann mir wer sagen wie ich an die Info komme wann ein InputPin ein Signal bekommt??
    Zum beispiel wenn ich vor dem Input nen Taster packe etc....

    mfg

  • Hallo Zebax,

    eine Möglichkeit habe ich hier beschrieben:

    Reset-Taster am GPIO und Programmierung in Icon (EDIT: 08-OKT-2017 Link im alten Forum)

    Der betreffende GPIO-Pin muss auf Eingang gesetzt werden. Dein Programm reagiert auf einen Zustand (0 oder 1) oder Zustandswechsel (0 ==> 1: steigende Flanke oder fallende Flanke 1 ==> 0).

    Beste Grüße

    Andreas

    Hallo Zebax,

    Auszug aus Kapitel 12 meines Icon-Kurses:

    12.3.2 Traditional approach
    At first we want to learn, how GPIO can be
    addressed by shell commands using the terminal.
    For example, if you want to "read" the status of
    the GPIO pin #9, you have to enter:

    Code
    echo "9" > /sys/class/gpio/export
    echo "in" > /sys/class/gpio/gpio9/direction

    The first command causes the creation of a new
    directory gpio9 within /sys/class/gpio,
    containing a file named direction. This file
    direction can be written with either "in" or
    "out", which we perform with the second
    command.
    Another file within the new produced directory
    gpio9 is value. This file contains information
    about the status, e.g. 0 or 1. You can read the
    content by

    Code
    cat /sys/class/gpio/gpio9/value

    The content is displayed, either 0 or 1. Finally,
    you have to "close" what was produced so far, by

    Code
    echo "9" > /sys/class/gpio/unexport

    If you want to "write" (e.g. to turn on/off a LED) to
    that GPIO pin you have to do something like:

    Code
    echo "9" > /sys/class/gpio/export
    echo "out" > /sys/class/gpio/gpio9/direction


    If you want to "write" (for example to turn on/off a
    LED) to that GPIO pin, you have enter:

    Code
    echo "1" > /sys/class/gpio/gpio9/value

    turning on the LED, and

    Code
    echo "1" > /sys/class/gpio/gpio9/value

    respectively, to turn the LED off, again. And,
    finally, to "close" everything

    Code
    echo "9" > /sys/class/gpio/unexport


    If you have some problems because of denied permissions
    and so on, you should try to repeat it within the root
    terminal, or as substitute user, put a "sudo" in front of those
    commands. If it doesn't work, you should try it with

    Code
    chown pi /sys/class/gpio...


    and

    Code
    chmod 777 /sys/class/gpio/...


    And again, if it doesn't work, try
    this as substitute user do:

    Code
    sudo ...


    OK. That's how it works with shell commands.

    Ich bin wirklich nicht darauf aus, Microsoft zu zerstören. Das wird nur ein völlig unbeabsichtigter Nebeneffekt sein.
    Linus Torvalds - "Vater" von Linux

    Linux is like a wigwam, no windows, no gates, but with an apache inside dancing samba, very hungry eating a yacc, a gnu and a bison.

    2 Mal editiert, zuletzt von Andreas (8. Oktober 2017 um 12:26)

  • Hallo Zebax,

    von Java (oder was auch imer) musst Du obige Linux-Kommandos aufrufen - oder entsprechende Befehle von GPIO-Libraries aufrufen.

    Beste Grüße

    Andreas

    Ich bin wirklich nicht darauf aus, Microsoft zu zerstören. Das wird nur ein völlig unbeabsichtigter Nebeneffekt sein.
    Linus Torvalds - "Vater" von Linux

    Linux is like a wigwam, no windows, no gates, but with an apache inside dancing samba, very hungry eating a yacc, a gnu and a bison.

  • Du brauchst natürlich nicht unbedingt aus Java heraus die Shell-Commandos aufrufen, genau so wenig wie du GPIO - Libraries brauchst.

    Sicherlich wird es auch für Java Bibliotheken für Dateisystem-Zugriffe geben (z.b. java.io.* ). Mit denen kannst du genau so auf die o.g. "Dateien" zugreifen. Entsprechende Berechtigungen natürlilch vorrausgesetzt.

Jetzt mitmachen!

Du hast noch kein Benutzerkonto auf unserer Seite? Registriere dich kostenlos und nimm an unserer Community teil!