- Vodafone otthoni szolgáltatások (TV, internet, telefon)
- Kaspersky Antivirus és Internet Security Fórum
- 242 millió dolláros szabadalomsértési ügybe keveredett a Microsoft Cortanája
- Call center-forradalom: AI alakítja át az ideges telefonálók hangját
- Telekom otthoni szolgáltatások (TV, internet, telefon)
-
GAMEPOD.hu
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
-
nagyúr
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.[ Szerkesztve ]
Új hozzászólás Aktív témák
- Politika
- Intel Core i5 / i7 / i9 "Alder Lake-Raptor Lake/Refresh" (LGA1700)
- 5.1, 7.1 és gamer fejhallgatók
- Egyszerűsíti termékportfólióját a HP
- Vodafone otthoni szolgáltatások (TV, internet, telefon)
- Kerékpárosok, bringások ide!
- Xbox Series X|S
- Külföldi rendelések: boltok, fizetés, postázás
- Formula-1
- Radeon RX 6700 XT: a Big Navi közepe?
- További aktív témák...
- Macbook Pro 16 M1 PRO 10C/16C 16GB - 1TB Magyar billentyűzet - Garanciális 2025.augusztus 4.-ig
- Sharkoon TG5 számítógép ház Corsair HX650 tápegységgel eladó
- Asus V8460 Ultra ( Geforce 4 Ti 4600 )
- HP Prodesk 600 G5 DM, Tiny i5-9500T , 8-16GB DDR4 , 256GB NvME , 2 év gari , AAM számla
- DOBOZOS Lenovo ThinkPad T14s Gen 3:R7 PRO 6850U,32GB DDR5,2TB,vil.HU bill,Radeon680M,400nit 100%sRGB
Állásajánlatok
Cég: Promenade Publishing House Kft.
Város: Budapest
Cég: Alpha Laptopszerviz Kft.
Város: Pécs