Hirdetés

Keresés

Új hozzászólás Aktív témák

  • mardal84

    tag

    válasz Aryes #12855 üzenetére

    Köszönet aryes-nek hogy ismeretlenül is segített,más forumokban sajnos nem ilyen rendes emberek vannak.

  • mardal84

    tag

    Sziasztok

    Mint teljes amatőr lenne egy kérdésem,lehet nem is jól fogalmazom meg a kérdést
    Van nekem egy arduino leonardom
    ezzel szeretnék kamionos játékhoz buttonboxot csinálni
    találtam is egy alap joystickbutton vázlatot ami működik is a 9-12 lábakon ha nyomógombot teszek rá
    Egy húzókapcsolót szeretnék használni majd a rögzítőfékhez de sajnos most csak akkor működik ha kétszer huzom ki a gombot mert akkor ad impulzust
    Azt szeretném elérni hogy legyen egy "gombnyomás" ha kihúzom és legyen egy "gombnyomás" ha visszatolom a kapcsolót,esetleg ebben tud nekem valaki segíteni?

    Köszönöm

    A használt vázlat

    // Simple example application that shows how to read four Arduino
    // digital pins and map them to the USB Joystick library.
    //
    // Ground digital pins 9, 10, 11, and 12 to press the joystick
    // buttons 0, 1, 2, and 3.
    //
    // NOTE: This sketch file is for use with Arduino Leonardo and
    // Arduino Micro only.
    //
    // by Matthew Heironimus
    // 2015-11-20
    //--------------------------------------------------------------------
    #include <Joystick.h>
    Joystick_ Joystick;
    void setup() {
    // Initialize Button Pins
    pinMode(9, INPUT_PULLUP);
    pinMode(10, INPUT_PULLUP);
    pinMode(11, INPUT_PULLUP);
    pinMode(12, INPUT_PULLUP);
    // Initialize Joystick Library
    Joystick.begin();
    }
    // Constant that maps the phyical pin to the joystick button.
    const int pinToButtonMap = 9;
    // Last state of the button
    int lastButtonState[4] = {0,0,0,0};
    void loop() {
    // Read pin values
    for (int index = 0; index < 4; index++)
    {
    int currentButtonState = !digitalRead(index + pinToButtonMap);
    if (currentButtonState != lastButtonState[index])
    {
    Joystick.setButton(index, currentButtonState);
    lastButtonState[index] = currentButtonState;
    }
    }
    delay(50);
    }

Új hozzászólás Aktív témák