Hirdetés
- Luck Dragon: Asszociációs játék. :)
- sziku69: Szólánc.
- sziku69: Fűzzük össze a szavakat :)
- sh4d0w: Kalózkodás. Kalózkodás?
- Lalikiraly: Kaáli Autó-Motor Múzeum
- gban: Ingyen kellene, de tegnapra
- Brogyi: CTEK akkumulátor töltő és másolatai
- WireGuard VPN a mindennapokra
- GoodSpeed: Ágymatrac keresési kálvária
- sh4d0w: StarWars: Felismerés
-
LOGOUT
Arduino hardverrel és szoftverrel foglakozó téma. Minden mikrovezérlő ami arduinoval programozható, és minden arduino program, board, és hardverrel kapcsolatos kérdések helye.
Új hozzászólás Aktív témák
-
válasz
mardal84
#12854
üzenetére
Szia!
Ha a 9-es gombot helyettesíted húzókapcsolóval, akkor mondjuk így:// 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]) && index == 0 ) { // 0 index = a húzókapcsoló a 9-es pinre kötve
lastButtonState[index] = currentButtonState;
Joystick.setButton(index, 1);
delay(10); // vár 10ms-ot, hogy a program észlelje a gombnyomást
Joystick.setButton(index, 0);
}
else if (currentButtonState != lastButtonState[index]) {
Joystick.setButton(index, currentButtonState);
lastButtonState[index] = currentButtonState;
}
}
delay(50);
}Ha másik gombra szeretnéd, akkor az index == 0 helyett 1,2 stb kell.
A kód azt csinálja, hogy minden húzás után 10ms-ig gombnyomás küld, majd elengedi. Ha ez kevés lenne, növeld a delay(10) értékét.
Új hozzászólás Aktív témák
- Z790 Strix-A, 14700K, 2x16GB 7200 mhz, Tuf 4080, Corsair H1000i
- -ÚJ,2 ÉV GAR- GAMER PC: RYZEN 7 5700/5800X +RX 6600/6700XT +16-64GB DDR4! SZÁMLA! 70 féle ház!
- Üzletből, garanciával, DeLL Inspiron 16 5630 -i5-1340P-16 szál/16RAM/512SSD/16,1"FULLHD IPS
- -ÚJ,2 ÉV GAR- GAMER PC: i5-14400F (10mag/16szál) +RX 6600/6700XT +16-64GB DDR4! SZÁMLA! 70 féle ház!
- Thrustmaster T-GT II bázis - Thrustmaster Sparco P310 - Thrustmaster T3PM pedál - Playseat Evolution
- 159 - Lenovo LOQ (15APH8) - AMD Ryzen 7 7840HS, RTX 4060
- ÁRGARANCIA!Épített KomPhone i5 13400F 32/64GB RAM RX 7800 XT 16GB GAMER PC termékbeszámítással
- ÚJ Microsoft Surface Laptop 7 13.8" 2K - 120Hz Érintő - Snapdragon X Elite - 16GB - 512GB-2 év gari
- GYÖNYÖRŰ iPhone 13 mini 256GB Red -1 ÉV GARANCIA - Kártyafüggetlen, MS3905, 100% Akksi
- MCDODO T03 fejhallgató
Állásajánlatok
Cég: Laptopműhely Bt.
Város: Budapest
Cég: NetGo.hu Kft.
Város: Gödöllő
ekkold
