Тёмный

Pico RP2040 HID Joystick Library for Arduino IDE 

Real Robots
Подписаться 2,7 тыс.
Просмотров 31 тыс.
50% 1

UPDATE: For your board, you need to use the "Arduino Mbed OS RP2040 Boards"-"Raspberry Pi Pico" which you can get from the boards manager. It includes the lower level libraries required for this one.
I don't think that ones the most commonly used one anymore, but it was back when I made this :-(
UPDATE: If you want to skip the coding altogether I've made an configurator that does all the work for you at realrobots.net/configurator
I'm going to show you how to make your own HID gamepad / joystick using a Raspberry Pi Pico RP2040 in the Arduino IDE. C++ all the way, no Circuit Python here.
You'll need the following library from Realrobots (that's me!)
gitlab.com/realrobots/PicoGam...
Here is the final circuit
realrobots.net/img/youtube/ci...
and the RP2040 pinout which comes in handy since they printed the pin numbers on the wrong side of the board with these things.
realrobots.net/img/youtube/ra...
If you like stuff like this, buy me a coffee at
/ realrobots
STL files for the gamepad (originally uses an ESP32 but the Pico will fit too)
www.thingiverse.com/thing:484...
0:00 Set up library
1:12 Open Code Example
2:09 Circuit Diagram
2:28 Connect Potentiometer
3:44 Connect Push Button
7:17 Connect Thumbstick

Опубликовано:

 

1 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 266   
@WithProfessorTom
@WithProfessorTom 2 года назад
I've had a look for something like this for various projects over the years and this is brilliant - thanks!
@PatrickJohnsen48
@PatrickJohnsen48 2 года назад
Just came here to say thank you - used the pi to upcycle my old 90's era joystick! Kudos!
@real_robots
@real_robots 2 года назад
Nice one!
@wayneshephard
@wayneshephard 2 года назад
Definitely appreciative of the amount of effort you put into these explanations, thankyou for your contributions that help us who do not know how to program these devices
@ComputerGuy404
@ComputerGuy404 2 года назад
Thank you, I am learning about DIY electronics. I had a pi pico, some perfboard and buttons laying around so I created a genesis style controller using your library and it works great.
@colinjacobs176
@colinjacobs176 2 года назад
Thanks for making this. A real public service! This is actually much simpler to get going that with Circuitpython, the HID stuff can be tricky unless you're doing vanilla keyboard/mouse stuff.
@real_robots
@real_robots 2 года назад
No problem, glad you're getting some use out of it.
@s10jam
@s10jam Год назад
I was beating my head against the wall trying to get that to work. I never used Circuit Python before and failed. Miserably.
@joelhavinga8366
@joelhavinga8366 Год назад
this is great. I have been working on getting this working for the last month now but I think this library will do the trick. thank you so much! i'll let you know if it has worked for my project.
@Wrigglevision
@Wrigglevision 2 года назад
Thank you very much for this! I'm planning on attaching a Pico to one of my Game Boy common ground boards, and this is *perfect* for that task.
@Wrigglevision
@Wrigglevision 2 года назад
Works like a charm. I just need to add some debouncing and life will be great.
@davydbar
@davydbar 2 года назад
Excelente, muy bueno!! hace tiempo que tenía ganas de un joystick hecho en casa. Gracias!
@jlnrdeep
@jlnrdeep 2 года назад
Awesome tutorial, i was just looking for something like this for a custom controller.
@Concodroid
@Concodroid 2 года назад
Spent 10 hours messing around with micropython and circuitpython after initially looking at this video and going "C++, nope, that's too hard for me." as soon as I saw the description. I decide to do this as a last-ditch thing, and the example file worked. I spent 30 seconds installing arduino, the libraries, and opening the example file and it worked. 30 seconds vs 10 hours, holy crap. Thank you.
@anupsonawane1420
@anupsonawane1420 Год назад
hhey i have seen many videos about maming joystick using pico and using micropython and circuit python and i observer that its an easy job with the hid adafruit library but i never tried on my own so i want to ask you is whether what issues you faced while using micro python and circuit python
@Concodroid
@Concodroid Год назад
@@anupsonawane1420 it wouldn't register as a USB device iirc. It was a while ago. I can't remember the specifics.
@ChongMcBong
@ChongMcBong 6 месяцев назад
thank you Mr Wizard :) i have wasted about 5 whole days fighting arduinos and GPT and everything trying to get another flight stick working, i eventually found this video, and used your excellent configurator page. many thanks, i think you saved the last bit of my sanity from escaping :)
@thebyzocker
@thebyzocker Год назад
thank you so much, it took me so long to find this i'm definitely going to try this out later today
@anonyxlher
@anonyxlher 10 месяцев назад
Yeeeees, thank you bro. Finally someone who can simply describe how to program an analog input for HID.
@ChinuNicks
@ChinuNicks Год назад
just made a simple controller using this :D was fun and learned a lot of stuff, gonna use some other microcontroller for more analog stuff next time ty for this library and rrconfigurator 😊
@oriel360
@oriel360 2 года назад
Gread vid. Should have alot more views thanks for the help!
@monkeypunchent
@monkeypunchent 2 года назад
Dude you're super underrated!!!!!!!!!
@thepelvis
@thepelvis 2 месяца назад
Worked perfectly, thank you so much! 🙂
@msx80
@msx80 2 года назад
awesome library, thank you !
@s10jam
@s10jam Год назад
After 2 days of fooling with MicroPython for the first time. I failed. After watching less than 2 minutes of your video I was light years ahead. I did have to refer to another video to figure out how to load the code in the Arduino IDE as I received an error the first time. Now to map the inputs directly and test my wiring. Thank you.
@s10jam
@s10jam Год назад
It works! My Guitar Hero controller works with the whammy bar! Thank you so much for this library!!!!!!
@real_robots
@real_robots Год назад
@@s10jam Nice one!
@meinnameistmenko.4207
@meinnameistmenko.4207 2 года назад
saved my evening!
@TodoSobresaliente_oficial
@TodoSobresaliente_oficial 4 месяца назад
Hi. Can It be used for 2 or more HID devices in a single pico?
@fon-tijn
@fon-tijn Год назад
TYSM man this is going to save me a lot lot of money!
@real_robots
@real_robots Год назад
No probs, try out the graphical, no code version I'm working on. realrobots.net/configurator
@fon-tijn
@fon-tijn Год назад
@@real_robots ill try tomorrow for my use this will save a lot of money and time if that works it will get even better the only real alternative board for my use are leo bodnar cards
@RetroBreezeYT
@RetroBreezeYT 2 года назад
Thanks so much for this library. How would you implement a switch matrix into this library? For example, I have 3 columns and 5 rows of switches in a matrix. Can the library support this setup?
@real_robots
@real_robots 2 года назад
You can definitely run a matrix through this, but the library will only pass on the inputs to HID, it won't work out the matrix stuff for you. It's not too hard to do the code, I'll link a tutorial (not mine) below. www.baldengineer.com/arduino-keyboard-matrix-tutorial.html
@cristhianvillca5276
@cristhianvillca5276 7 месяцев назад
Tu librería para arduino es muy bueno..... Me encantó lo fácil de modificarlo en el ide.... Me gustaría que pudieras hacer una librería igual de sencillo pero para un hid de teclado.... Para así funcionar el gamepad y también tener teclado como nativo sin emular por joy to key
@dlednik
@dlednik 6 месяцев назад
Love it and the lib will come handy for my project. Stupid question maybe, but does the HID controller gets recognised by Android too. Or more specifically with Steam on Android?
@psteja1993
@psteja1993 2 года назад
Hi! Thank you so much for this. I am planning a little button box and to prevent the game from 'forgetting' the bindings, I was wondering if there is a way to assign a name for this joystick. For e.g., could I call it RacingButtonBox1? My Pico is on the way and it seems to be a very economical and a better choice for button boxes.
@real_robots
@real_robots 2 года назад
Unfortunately that device name sits on a lower level than my code so it's not (to my knowledge) possible to change it so easily, I believe it's grabbed from the bootloader. I haven't actually looked into it but the same problem exists with the other Arduino hid libraries.
@LordOfWizardurl
@LordOfWizardurl 2 года назад
Youarethebest
@MrBenedictHeyer
@MrBenedictHeyer Год назад
Thanks in advance for developing this library! I have a question. I want to simulate multiple gamepads, would I be able to use multiple instances of the PicoGamepad class?
@real_robots
@real_robots Год назад
Hmmm, I'm not sure. Let me know if you try it.
@javiernaranjo2395
@javiernaranjo2395 Год назад
Thanks a lot for this library it has been very useful for me... I deleted the delay, and Serial and works like a charm. Is there a way to meassure the input lag I really need a aproximate number?
@real_robots
@real_robots Год назад
To get the input lag you'd need some way to measure the time between the device and when it arrives at your computer, or effects your game. I'm not sure how you would do that. If you want to know how long between each time the input is sent to the computer you can uncomment the first two lines in the loop() function of rr_controller.ino. BUT sending the serial message is slowing it down so you're going to get a slower loop. The best way would be to average the time over several loops and then send it once at the end. Try this (i haven't tested it) Add these two lines to the variables at the top of rr_controller.ino int loopTime[32]; uint8_t loopCount = 0; And this to the start of the loop() function if (loopCount < 32){ loopTime[loopCount] = millis() - loopStart; loopCount++; } else { float total = 0; for (int i = 0; i < 32; i++){ total += loopTime[i]; } total = total / 32; Serial.print("Average milliseconds between each loop: "); Serial.println(total); loopCount = 0; } loopStart = millis(); This records the time between loops 32 times then sends you the average, then it'll do it again.
@ChewyCalibra
@ChewyCalibra 7 месяцев назад
This is a really cool project i like to do, but if i want to upload the code it says "...\libraries\PicoGamepad/PicoGamepad.h:21:10: fatal error: PluggableUSBHID.h: No such file or directory " i searched for this Lib but cant find any solution.. Can you please help!?
@tehnubrises5533
@tehnubrises5533 3 года назад
I was sort of expecting rotary encoders but i realized it's a joystick/gamepad library. It's all good tho cuz most of them are all useful for a custom gamepad
@real_robots
@real_robots 3 года назад
Yeah the lack of rotary coder support is a little embarassing, I've mostly implemented them but need a bit more testing before I put them in the main branch.
@tehnubrises5533
@tehnubrises5533 3 года назад
@@real_robots side question, do you know how to change the name of the pi pico? (as in the name displayed in the joystick listing)
@real_robots
@real_robots 3 года назад
@@tehnubrises5533 I'm not sure how to do that, I think it's being picked up from somewhere in the Arduino boards files but I haven't tried changing it.
@soupnazi22
@soupnazi22 3 года назад
@@real_robots Do you have any update on when you might release rotary encoder support? I tried adding another rotary encoder library to this but am struggling to get it to work. Thanks for the great work!
@real_robots
@real_robots 3 года назад
@@soupnazi22 am actually working on this right now, check gitlab.com/realrobots/rr_configurator in a couple of days and it should be up.
@Flowtimess
@Flowtimess 2 года назад
Hello and thanks for that! Big Idea et good execution. But Impossible for me to run rr_configurator-master with RP2040. Port and multiples tests no results.
@RealKanashii
@RealKanashii 2 года назад
Thanks a lot for the library and the tutorial. I used Arduino but be able to use Pico is nice. I will try it. Just a question, is it possible to daisy chain two Pico or use I2C to have max allowed buttons in Windows ?
@real_robots
@real_robots 2 года назад
It's possible to daisy chain them using I2C absolutely, but I haven't integrated this into my rr_controller firmware that would do that for you though so you'd have to write the code yourself. You'd still hit that max limit of buttons in windows though, daisy chaining them would just get your more inputs than a single RP2040 would provide. I think the way to get around the button limit would be to have two separata HID devices, though I know not all games will accept multiple gamepads/joysticks which is why I made the rr_controller firmware in the first place.
@RealKanashii
@RealKanashii 2 года назад
@@real_robots Thanks for your answer.
@bringinghomethebananas
@bringinghomethebananas Год назад
Thanks for a great tutorial. I'm actually rebuilding a flight stick with a Pico, and while it's not strictly a problem, would you happen to know if there's a way to NOT have the library create the full array of all 32 buttons and all of the sliders, etc?
@real_robots
@real_robots Год назад
You're welcome. I haven't coded any easy way to change the inputs. If you wanted to do that you'd go into picogamepad.cpp and change the descriptor, it's what reports to your computer what inputs to expect. You'd have to change the data packet that gets sent to match any changes you make.
@elshiftos
@elshiftos 2 года назад
Thanks for sharing your code, but I am having getting this to work! Although not a big coder, I am familiar with Arduino and have the board manager and libraries setup correctly. My Pico has previously had both micropython and circuitpython installed on it. When I upload your code, a gamepad appears in windows control panel as expected, but when I short various IO pins to ground nothing happens. The only response I get is pulling GP28 to ground makes button 1 on the gamepad light up. Oh, and the LED flashes and I can change the speed by altering the delay(100) value at the bottom of the code. Any idea what I'm missing here? Many thanks
@real_robots
@real_robots 2 года назад
If you run my example then pin 28 is the only one mapped to a button. Watch the video, it shows you how to duplicate that functionality to other buttons and pins. Basically though you have to set a pin to input_pullup mode "pinMode(28, INPUT_PULLUP);", then apply it's state to a gamepad button "gamepad.SetButton(0, !digitalRead(28));" If you find those lines in the example, duplicate them, and add a different pin that 28 and a button other than 0 then your other buttons will work too.
@wave6020
@wave6020 Год назад
how would you go about making another joystick input? The library I have downloaded from you works as a left joystick and I would like to use 2 joysticks, one for a left joystick and one for a right joystick so i could use it as a gamepad for fps games where you move with the left joystick and look around with the right.
@real_robots
@real_robots Год назад
You just assign them to different axis, one joystick would be x and y, the other z and Rx or some other combination of analog axes
@jmuellerdrenkberg
@jmuellerdrenkberg 5 месяцев назад
Great Tutorial. How can I rename the device?
@maniamone
@maniamone 8 дней назад
Hi there, thank you for this great walk-through; could you please specify what HID libraries are needed in order to run this code? i think i dont quite have the right set of HID libraries set up for my arduino and the file doesnt run on my system.
@real_robots
@real_robots 8 дней назад
For your board, you need to use the "Arduino Mbed OS RP2040 Boards"->"Raspberry Pi Pico" which you can get from the boards manager. It includes the lower level HID libraries that my library uses.
@jfrefe3939
@jfrefe3939 2 года назад
Wow! Cool stuff. Can you make a sample of this code with output to light up RGB led? (WS2812B) everytime you hit a button? Not really good in coding, but Arduino Leonardo can't handle the data needed to light up 255 leds per button. I only needed 4 button and each should light up a 16 x 16 RGB matrix. I hope you can help me.
@Flowtimess
@Flowtimess 2 года назад
Pour la simplicité arduino micro fera parfaitement le travail et facilement. Pas besoin d'un code joystick pour cela.
@RogueKnight78
@RogueKnight78 Год назад
@AaronNies
@AaronNies 2 года назад
Does the library support doing button grids or is it one button per pin? I'm trying to squeeze out as many inputs as I can from the Pico
@real_robots
@real_robots 2 года назад
You absolutely can do a button matrix using this, the library won't do it for you. I do a tutorial on how to wire up a matrix and use it with my other software in this video. ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-dop0SoD2XL8.html&ab_channel=realrobots But I haven't added pico support for that yet, the code is easy though, you can copy and paste the code from this tutorial and put the joystick button press code at line 42. www.baldengineer.com/arduino-keyboard-matrix-tutorial.html
@danilocedeno9765
@danilocedeno9765 2 года назад
Brilliant work. Super clean! I am using this for a sim racing wheel I 3D printed. I was just wondering, my pot is a bit noisy, is there a way I can fix this without having to get super pricey parts?
@real_robots
@real_robots 2 года назад
There's a feature in the firmware that I haven't implemented in the gui yet. Go to line 167 of Inputs.ino and remove the "//" from the line there. It activates noise filtering for one of your axes. You can set which axis by changing inputs[2] to inputs[whatever]. That's not the pin number though, it's the index in the list, so if the axis you want is the first in the list in the GUI, that's number 0, the second is number 1 etc.
@danilocedeno9765
@danilocedeno9765 2 года назад
@@real_robots Thank you for the quick reply, at first I was just using the example PicoGamepad.ino and flashing it to my pico with the Arduino IDE. But then after actually reading your documentation I saw all about the configurator you created. I edited the inputs.ino file just like you suggested but I am having trouble flashing the rr_controller to my pico, I keep getting a missing EEPROM.h error. I'd appreciate some help with that if possible. Thanks again!
@real_robots
@real_robots 2 года назад
@@danilocedeno9765 Oops that's my bad, wrong software. I thought yorur comment was on my rr_controller project. This library was made to integrate RP2040 support into rr_controller, but I haven't done that yet so you can't use rr_controller for your pico project. Since this library just passes your inputs straight to your PC via HID you'll have to do the noise filtering yourself. You can do it with hardware, google "low pass filter", it just needs a resistor and capacitor. The easier way is to average out the inputs in code. Make a rolling buffer, an array of 8(for example) integers that holds the most recent 8 samples from the pot. then you average out the number before you pass it over to HID. If you increase the samples from 8 to more it's be smoothed more, depending on how fast your loop is you might start to get some lag but probably not until you're up over 16 or 32 samples. int inputBuffer[8]; int inputCount = 0; void UpdateInput(){ inputBuffer[inputCount] = analogRead(A0); inputCount++; if (inputCount == 8) inputCount = 0; int total = 0; for (int i = 0; i < 8; i++){ total += inputBuffer[8]; } int avg = total/8; gamePad.setX(avg) }
@Spookeyo
@Spookeyo 3 года назад
This look great! I was wondering is there a plan to support rotary switches with resistor ladders?
@real_robots
@real_robots 3 года назад
Do you mean rotary encoders? The latest update added support for those. I hadn't considered resistor ladders, I'll add them to the list. That's all for my gitlab.com/realrobots.com/rr_configurator software though. The library in this video only does the HID stuff between the pico and your computer. To make it do resistor ladders you'd just need an if statement that triggered a button when the analog pin was between some threshold values.
@Spookeyo
@Spookeyo 2 года назад
@@real_robots Thought I replied to this, but thanks for considering it. I would be interested in using your library and configurator for Sim Racing use, making custom steering wheels or button boxes. Rotary Switch support would be great to have, I've used FreeJoy and SimHub in the past but looking to use RP2040 in a custom PCB next. It's something I can try to add in myself for now though. Thanks, keep up the good work with this project it has big potential.
@PatrickJohnsen48
@PatrickJohnsen48 2 года назад
@@real_robots how would one utilize the rotary encoder? as an axis? looking to add two to a button box for a flight sim for heading and altitude. Thanks!
@real_robots
@real_robots 2 года назад
@@PatrickJohnsen48 I'll link a tutorial below on how to connect and code a rotary encoder. Following it's instructions you either pass on the counter value as an axis or replace the lines "counter++" and "counter--" with button presses. If you do it as an axis you'll probably want to increase the counter increments and prevent the value going out of range. howtomechatronics.com/tutorials/arduino/rotary-encoder-works-use-arduino/
@PatrickJohnsen48
@PatrickJohnsen48 2 года назад
@@real_robots thanks, will report back!
@RB-tc8ru
@RB-tc8ru 2 года назад
Hi, thanks for a great resource. I'm interested to find out how you get 8-axis inputs? I'm aware of the 4 ADC pins on the Pico, one being the onboard temperature sensor. In your Github example, it only shows X and Y potentiometers and I'm building a project where I would like to use more than three-axis inputs if possible, 8 would be fantastic! I also have no idea how to repurpose the 4th ADC from the onboard temperature sensor to an axis input.
@real_robots
@real_robots 2 года назад
There's a few ways you can more analog (ADC) inputs, the easiest is probably to get a GPIO expander. I haven't used this one, it's just the first one I googled. This is the kind of thing you want. www.adafruit.com/product/3657 I've never tried to get more ADCs out of the Pico so I don't know about using the onboard temp sensor one. Is the pin exposed? What happens if you use a regular analogInput on it?
@RB-tc8ru
@RB-tc8ru 2 года назад
@@real_robots ahh that makes sense. I haven’t used a GPIO expander, but from the quick research I did it seems they use I2C to get additional ADC inputs? Does this require additional coding? As for the 4th ADC, my initial post was incorrect. There is no pin available, only pin access is to obtain the temp output. So it seems it’s unusable as an input unfortunately. I’m going to purchase a GPIO expander and fiddle. I’ve not got much arduino or pi coding experience but there’s only one way to get it! Thanks for the quick reply.
@real_robots
@real_robots 2 года назад
@@RB-tc8ru They don't need much coding so long as you can find a library for whichever expander you get. The more popular GPIO expanders will have libraries that make them pretty much like the normal Arduino code. If you find one that doesn't have a library it's a little more complicated as you'll need to work out how to communicate using the I2C protocol.
@Flowtimess
@Flowtimess 2 года назад
@@RB-tc8ru the uPesy RP2040 is good equivalent with more analog pin ;)
@ZebbeBa
@ZebbeBa 2 года назад
I would love if there was a Example including Rotary encoders - understood you added support for them. would make it a bit more accessible from more ppl.
@real_robots
@real_robots 2 года назад
That's fair, I do need to update the documentation to accomodate the newer features. That said it's not too hard to set up an encoder, they have a common ground, the A, B and button pins get connected to your microcontroller GPIO pins, then in the ENCODERS tab inthe gui you just assign those pins and you should be golden
@ZebbeBa
@ZebbeBa 2 года назад
@@real_robots that would be super nice! Thanks! It would lower the threshold for less code oriented ppl like my self :) - my skillset are being cute and Nice, not coding 😝
@Skhillz_FN
@Skhillz_FN 5 месяцев назад
Cant wait to abuse steam binds Thank you sir i could very well be using this to compete in fort
@Channel9001
@Channel9001 Год назад
What pins would you connect the potentiometer to to make it the Z Axis? I am doing research to try and DIY some USB Atari Paddles.
@real_robots
@real_robots Год назад
You can use pins 26, 27, and 28 for analog inputs such as potentiometers
@Channel9001
@Channel9001 Год назад
@@real_robots Thanks! I'll keep researching!
@PDRIFT86
@PDRIFT86 Год назад
If I have a pico that I already installed circuit python on, what would i need to do to get this to work on it? I'm also not running windows, I'm on Linux.
@real_robots
@real_robots Год назад
I haven't done it in a while so if this doesn't work go grab an online tutorial. But pretty much you open up the Arduino IDE, go to Tools->Boards->Board Manager and install the Arduino Mbed OS RP2040 Boards. Once you've done that you can go to Tools->Boards and choose youre Pico RP2040 from the list and upload. I think you have to press a boot button when it powers up as well, so hold the button down when you plug it in so it starts in flash mode
@xantrax9359
@xantrax9359 Год назад
Hi and thank you for the library. I usually use Arduino clones for my projects, but would love to replace them with Pi Pico. Quality board with properly soldered USB and more PIOs for the half price of clones. All together with Arduino IDE? That would be fantastic! I'm creating button boxes. With your library and attached example I managed to use Pi Pico as a controller for 26 buttons without needs for button matrix and diodes preventing from ghosting. Super useful when you got a lots of switches or controllers with common ground. But button boxes without encoders are unfinished, and unfortunately I cannot make them work :( I used button matrix with encoders sketch I found on some Arduino forum long time ago. Works like a charm on Arduino with MHeironimus joystick library and keypad.h library. I removed the part responsible for buttons leaving only one encoder. Removed also references to joystick and keypad library, replacing it with yours. To my surprise compiling went successful so I uploaded the code. Computer recognized Pi Pico gamepad but encoder was not working. Copied the line responsible for button from your example and added to my sketch, just to check if Pi Pico sending any signals to PC. After uploading button is working but encoder still not. I'm not a programmer and I don't know what I'm missing there. The code for encoders looks quite complicated. Is there any chance you will be able to help me with this and have a look on the code please? I can post the sketch to any suitable place for you. Thank you for this great library again.
@real_robots
@real_robots Год назад
If you post your code somewhere and link it I'll take a look
@xantrax9359
@xantrax9359 Год назад
@@real_robots Thank you for quick response, really appreciate that. I was not sure if RU-vid will not delete my post with link instantly so I created new issue in your GitLab's PicoGamepad repository. I wish all the information provided will be enough for you to find my mistake in the code. Thank you for your time.
@KimchiEnjoyer
@KimchiEnjoyer 2 года назад
Hey I was wondering how I could disable various things like if I wanted to only use a few buttons, or disable the joystick and Z axis, etc and just use the sliders how would i go about doing that ? Thanks
@real_robots
@real_robots 2 года назад
If you just don't use them then it won't override any data sent by another joystick or gamepad. If you want them to be totally gone from the list of inputs in the USB thing it's a bit trickier, you'll have to go into picogamepad.cpp and remove the inputs from the descriptor. It's a bit of a pain. You're probably best off just using the inputs you want to use and ignore the rest.
@KimchiEnjoyer
@KimchiEnjoyer 2 года назад
@@real_robots ah alright thank you for the quick reply! i was worried the noisy unconnected joystick would cause issues some how
@campionpesate4647
@campionpesate4647 2 года назад
Can gamepad.SetButton use booleans instead of digitalRead? Reason - 3 position ON OFF ON switch. Middle position must activate gamepad.SetButton with two negative digitalReads simultaneously. I've tried using a bool but was unsuccessful. It kinda works, activates the button, but can't control it properly, very confused.
@real_robots
@real_robots 2 года назад
Yes, SetButton() takes a bool. What you would usually do with an ON OFF ON switch is have OFF connected to ground and each of the ON poles connected to a different GPIO in INPUT_PULLUP mode. Then you would do SetButton(0, !digitalRead(GPIO1)) and SetButton(1, !digitalRead(GPIO2)). You could also store each of the two values to a bool first and then pass that through SetButton, but digitalRead returns a bool anyway so it's not really necessary unless you're doing somethign more fancy.
@campionpesate4647
@campionpesate4647 2 года назад
@@real_robots Yeah you're right, finally got it working with a bool. So with my switch, it didn't send a signal in the middle so I set a bool that activates a SetButton when both left and right are off. Best I could do but finally works Thank you,, fantastic video.
@hubertnovak5919
@hubertnovak5919 Год назад
GREAT VIDEO, THANK YOU. I am trying to use this video to just simply add 4 rotary encoders. i have some idea of the coding but not enough to know what to write in the code. Is there a place i can get that info. I need it to be a game pad output and serve as a USB so that the software (flight simulator) recognises the pi co. Your current code and example the flight sim already recognises it, so i figured if i just added encoders, only encoders i should be able to assign then to different function in the sim. Thanks for your help.
@real_robots
@real_robots Год назад
If you're using encoders the coding can be a little bit more complicated than a regular button, as they do a staggered pulse across 2 pins and you need to write the code to recognise the different pulses. Have a look at this. lastminuteengineers.com/rotary-encoder-arduino-tutorial/ Once you've got that handled, just use my library to fire a button down on pulse.
@monkeypunchent
@monkeypunchent 2 года назад
Is it possible to use this configuration to code 2 controllers to function as one? (Similar to how the switch or the wii nunchucks work)
@real_robots
@real_robots 2 года назад
I actually wrote software to do this but I haven't added the Pico to it yet. If you want to use an Arduino Pro Micro or ESP32 my other software www.gitlab.com/realrobots/rr_configurator will let you network as many of those as you like (and Arduino Uno or Mega) and report through the Pro Micro or ESP32 as a single HID device. No need to code either, just upload the firmware then configure it with my GUI. You can definitely do what you want to do with this library as well, but you'll have to write the code yourself as this is just a library for sending HID reports to your computer from the Pico.
@soupnazi22
@soupnazi22 2 года назад
@@real_robots Do you have any plans to add Pico support to rr_controller? I think the low cost of the Pico could make this very compelling.
@real_robots
@real_robots 2 года назад
@@soupnazi22 Absolutely, making this library was the first step, the next release of rr_controller should have pico integrated.
@mrburns366
@mrburns366 11 месяцев назад
Could i do the same thing with Arduino Leonardo? I know the io pin are different numbers but with some tweaks should it be able to work? I'm a total newb. Doing this as a learning experience
@real_robots
@real_robots 11 месяцев назад
Yeah absolutely, this library won't work with the Leonardo but there's a great one for the atmega32u4 called joystick.h from a guy called mheironimus
@mktaia
@mktaia 2 года назад
Hello, how are you? do you know if there is already any firmware or programming for this palca works on the Playstation 4 natively? Thanks
@real_robots
@real_robots 2 года назад
If you try it let me know. I've read that the PS4 can use third party devices, but I'm not sure if there are some caveats to that like there are with the Xbox. It may or may not work.
@titaniummedical5053
@titaniummedical5053 2 года назад
Hello, how do i get the USB input check on the raspberry pi 4 please
@real_robots
@real_robots 2 года назад
You'll need to download a gamepad tester that works in Linux try this web based one gamepad-tester.com/ or this one jstest-gtk.gitlab.io/ I haven't tried either on a raspberry pi but they look like the way to go.
@dennisbalagna
@dennisbalagna 2 года назад
Will this work with any rp2040 board, like the seeed xiao rp2040?
@real_robots
@real_robots Год назад
So long as its supported by Arduino it should be okay
@dennisbalagna
@dennisbalagna Год назад
Could you revisit this project as a wireless controller with a Pico W now that it supports bluetooth?
@real_robots
@real_robots Год назад
There's a good chance of that. I'm working on a new version of the software that'll support more modern chips. Right now it does bluetooth HID using ESP32 and USB HID on the Pico / RP2040. I'll have to see about getting a Pico W now that the bluetooth stack is available. This is the new configurator, it's still pretty basic and new features/board support is coming. realrobots.net/configurator
@nigelcleaver
@nigelcleaver 2 года назад
Many thanks for posting this video - it got me interested in using an old analogue joystick with the Pico. I seem to have an issue using the Arduino IDE and your sketch in that an error is generated related to the PluggableUSBHID.h - no such file or directory being reported when trying to compile. I note you moved the reference to the library. I cannot find this file, and was trying to figure out what's missing / where I can obtain this file. Many thanks - hoping you may be able to help point me to a solution. Nigel
@real_robots
@real_robots 2 года назад
That file should be included in the Arduino Mbed OS RP2040 Boards files. I think you probably have the earlier arduino RP2040 libraries from earlephilhower. In the boards manager you want "Arduino Mbed OS RP2040 Boards by Arduino
@nigelcleaver
@nigelcleaver 2 года назад
@@real_robots Many thanks for responding so quickly. I checked through the Arduino IDE, did some clearing out etc, installed the board manager as suggested. I have had some success, in that the PicoGamepad compiles and uploads, however it doesn't show as a game controller. I note in the IDE when compiling the following messages (heavily edited): Detecting libraries used... Alternatives for PluggableUSBHID.h: [USBHID@1.0] -> candidates: [USBHID@1.0] Compiling library "PicoGamepad" Compiling library "USBHID" Using library USBHID Do you think the IDE is finding the USBHID@1.0 and this might be the issue and that I'm still missing the PluggableUSBHID.h file? Sorry to be a pain asking more questions. Nigel
@real_robots
@real_robots 2 года назад
@@nigelcleaver If it's compiling successfully then it's PROBABLY a compatibility issue. My ESP32 can connect via bluetooth to my PC and my modern(ish) thinkpad, but won't connect to an older thinkpad or my mates MacBook. Some guys on my discord found it wouldn't connect to quite a few bluetooth dongles. If you've got something else with bluetooth maybe give that a try, just to confirm if that's the issue.
@nigelcleaver
@nigelcleaver 2 года назад
@@real_robots Thanks for your reply. Not sure what's going on here; running RPi PICO with Windows8.1, uptodate Arduino, boards, libraries etc. i'll carry on investigating to see if I can crack the issue(s).
@real_robots
@real_robots 2 года назад
@@nigelcleaver Sorry, my bad, when I was talking about compatibility and dongles I was thinking we were talking about my BLUETOOTH library :-) If you're running my example and it's compiling properly I'm not sure why it wouldn't be working.
@marwan.naasan
@marwan.naasan Год назад
Thank you for this video .. I'm asking ... can I connect Gyro with it ? To play motion games ?
@real_robots
@real_robots Год назад
Sure, you'd just have to write the code to translate the gyro output to the input range of one of the gamepad axes
@marwan.naasan
@marwan.naasan Год назад
@@real_robots thank you Bro ..for your comment .. I'll do that!! and sorry about my bad English .... I wonder if I can make the gamepad working wireless like Bluetooth to connect PC ... Can I ?
@real_robots
@real_robots Год назад
@@marwan.naasan not with a standard pico, the newer ones have a Bluetooth chip but I wrote this library long before that came out. If you really want Bluetooth, try an esp32
@marwan.naasan
@marwan.naasan Год назад
@@real_robots thanks Bro 😊
@MarcusArmstrong037
@MarcusArmstrong037 2 года назад
How would my code need to change if my buttons are on a breakout board connected by I2C?
@real_robots
@real_robots 2 года назад
Not very much, if you can get the input states from your i2c board you just have to feed it into the .SetButton(idx, state) function.
@v1ol3t59
@v1ol3t59 3 года назад
Hey man! I love your videos your last videos helped me lot with my arduino HOTAS I guess you remember me i mailed you my HOTAS videos. i need a little help the potentiometer readings are not stable can you help me with that? What do i do to make it stable? Though I replaced potentiometer with hall effect sensor it works just fine but the values are not stable. the values were unstable for both potentiometer and hall sensor.
@real_robots
@real_robots 3 года назад
If you've got noise from your pot or hall effect sensor you can take the hardware of software option. Hardware would be make a low pass filter, just need a capacitor and a resistor. You'll have to hit Google to find out how exactly to make it as I've not made one before. The software way, which it looks like I'd better work into rr_controller, is a rolling average. Basically you keep a running count of the last x readings and give the average. It introduces a little delay, but if done right it's nothing you'd ever notice. I describe one in detail at the link below. www.reddit.com/r/HotasDIY/comments/oewevh/hall_sensors_with_jumping_values/h4c2mqx/ I might see if there's an easy way to hack it in to rr controller
@v1ol3t59
@v1ol3t59 3 года назад
@@real_robots thankx a bunch
@Elmorji
@Elmorji Год назад
Is there a line in the code I can put to press the x button on a controller or a key on a keyboard
@real_robots
@real_robots Год назад
Gamepads/joysticks only have numbered buttons, if you mean like the X on an xbox or PS controller you can reassign the numbered buttons in game or through Steam. If you want to press the letter 'x', use the built in keyboard library in Arduino, it's in the examples. I think you can use it and mine together but I haven't tried.
@Elmorji
@Elmorji Год назад
@@real_robots ok thanks is there a way to have a pi work as a keyboard on an Xbox?
@real_robots
@real_robots Год назад
@@Elmorji Xbox uses a slightly different hid protocol. You want to search for one that does xinput rather than the directinput system everything else uses. I don't know if one exists
@kabecon
@kabecon 2 года назад
Hello! Thanks for the video, I am working with the board and I was able to configure all the buttons, but I don't know how I can configure the HATs. like on a joystick. Could you guide me?
@real_robots
@real_robots 2 года назад
Sure, most hatswitches you find are sort of like 4 buttons mashed together, you'll have one common pin and 4 directional pins. Your common pin connects to your GND pin and each of the rest go to one of your digital pins. Then you just treat each of those digital pins the same as any other button. I talk about the wiring of a hat in one of my other videos ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-z3BSJLGnW4c.html From the code side, if you want to specifically map those as hat switch directions, instead of SetButton(idx, state) use SetHat(idx, dir), since they're connected you'll have to wrap them all in an IF statement or switch case. The below code will check if any of the buttons are pushed and will send the appropriate HID signal. If none are pushed, then it assumes the hat is centered. You can find the details of the API in the gitlab repo www.gitlab.com/realrobots/PicoGamepad if (!digitalRead(pin_N)){ SetHat(0, 0); } else if (!digitalRead(pin_E)){ SetHat(0, 2); } else if (!digitalRead(pin_S)){ SetHat(0, 4); } else if (!digitalRead(pin_W)){ SetHat(0, 6); } else { SetHat(0, 8); }
@kabecon
@kabecon 2 года назад
@@real_robots Thanks for the answer!! My problem is mostly with the code. I tried this and it worked, mark the 4 directions in the windows test (for some reason the arrows are different colors in the POV section). The problem itself is that it doesnt mark the diagonals, instead it show "Down-Right" at the same time. Im from Argentina so, im sorry for my english. Here ir the code that I used: int hatup0 = 8; if (!digitalRead(PIN_BTN_UP)){ hatup0 = 0; } else{ hatup0 = 8; } gamepad.SetHat(0, hatup0); int hatdown4 = 8; if (!digitalRead(PIN_BTN_DOWN)){ hatdown4 = 4; } else{ hatdown4 = 8; } gamepad.SetHat(1, hatdown4); int hatleft6 = 8; if (!digitalRead(PIN_BTN_LEFT)){ hatleft6 = 6; } else{ hatleft6 = 8; } gamepad.SetHat(2, hatleft6); int hatright2 = 8; if (!digitalRead(PIN_BTN_RIGHT)){ hatright2 = 2; } else{ hatright2 = 8; } gamepad.SetHat(3, hatright2);
@real_robots
@real_robots 2 года назад
@@kabecon You're getting different colour arrows because each time you run SetHat(idx, state) you're giving a different idx, they should all be 0 if you're only using one hatswitch. When you do that you'll have trouble though because you're treating each switch seperately, you need all of them in one IF, ELSEIF block like the code I showed you. With the down-right thing I'm not sure, though I've noticed some software will pick it up as SE, some will read it as S+E so it might just depend on what game you're playing.
@kabecon
@kabecon 2 года назад
@@real_robots Thanks a lot! It worked! I really appreciate your work and I appreciate the time you took to reply! Greetings!
@kabecon
@kabecon 2 года назад
@@real_robots Hi, it's me again hehe. I've been testing the diagonals, but I couldn't get them to work. There would be some possibility to add them to the code. Let's say that if we press the PINs assigned Left-Down together, it shows the corresponding diagonal?
@javiernaranjo2395
@javiernaranjo2395 2 года назад
what if I delete that "delay(100)" or make it faster like "delay(25)". Will it work? Will it be any better?
@real_robots
@real_robots 2 года назад
Absolutely, the delay is only set to 100 so the serial monitor doesn't get spammed. You could drop that delay right down to 1.
@kacpe8766
@kacpe8766 8 месяцев назад
Can you modify the code to act as an Xbox 360 gamepad?
@DIYSimParts
@DIYSimParts Год назад
Hi, I uploaded your configurator uf2 file to test it but now when i flash the board back to factory defaults to remove the configurator i can no longer program it manually with arduino ide like in your video, it wont recognise the device with a com port. any idea how to fix this?
@real_robots
@real_robots Год назад
That's odd, uploading any uf2 shouldn't effect uploading new ones through the Arduino ide. Could you do it before?
@John.Steensen
@John.Steensen 2 года назад
Question for you Real Robots: Is there a way to customize the name of how it displays the device name on windows, so if I have multiple devices, I can name them differently from each other?
@real_robots
@real_robots 2 года назад
Sorry, not using this library. The name is reported elsewhere in the USB stack and I never worked out how to change it.
@Enthcreations
@Enthcreations Год назад
​@@real_robots I managed in flashing withlegacy ide 1.8. on 2.0 it fails.
@real_robots
@real_robots Год назад
@@Enthcreations that makes sense, I haven't installed Arduino ide 2 yet
@Enthcreations
@Enthcreations Год назад
@@real_robots by the way. I made a few tests, building a really basic version of the controller, it's average latency is 3.5ms circa - response time over the native 1ms polling rate. Calculated on 1000 inputs.
@LukasAslan
@LukasAslan Год назад
Great Library! However, while all inputs appear to be working in the Windows gamepad manager, None of my games (that support controllers like xbox360) register any Button presses. Is there a solution to make it compatible with popular games (fps etc.)?
@real_robots
@real_robots Год назад
It should definitely be working with all your windows games and the gamepad manager. Double check your code, you can post it here or on my discord if you like and I'll have a look at it. discord.gg/wvGk2V46
@mutazgaming9640
@mutazgaming9640 2 года назад
Does the joustic work on adroid tv boxes?
@real_robots
@real_robots 2 года назад
It uses standard usb HID so if android tv boxes can use usb gamepads it should be able to use this too.
@stevenhuber2434
@stevenhuber2434 2 года назад
Hello, having trouble uploading to my pico "An error occurred while uploading the sketch" do you have any tips?
@real_robots
@real_robots 2 года назад
I don't know a lot about the eccentricities of the pico, does it work when you upload a blank sketch?
@stevenhuber2434
@stevenhuber2434 2 года назад
@@real_robots I got it worked out, this is my first project of this type.
@MistaLuai
@MistaLuai Год назад
Is there is something similar to this that works on ps4?
@real_robots
@real_robots Год назад
Not that I'm aware of.
@abderrahimmakrem7465
@abderrahimmakrem7465 Год назад
how can we reduce the number of buttons also axis ?
@real_robots
@real_robots Год назад
I've not written in any easy way, you'll need to manually edit the description in picogamepad.cpp
@ragunathtikiri480
@ragunathtikiri480 Год назад
Hey! Is there any easy way I can get switches working with this? I've been going through the header and source files and I understand nothing LMAO. Would be awesome if you could help!
@real_robots
@real_robots Год назад
A switch will usually have two pins just like a button, so follow that part of the tutorial and you should be good. If it's a 3 pin switch it's two buttons with one shared pin. Theres an example of a 3 pin toggle switch in the circuit diagram at 2:09
@federicokrum
@federicokrum Год назад
Nice! Can I emulate several gamepads in only one Raspberry Pi Pico RP2040?
@real_robots
@real_robots Год назад
Hmmm, it would definitely be possible but you'd have to hack my code a bit. I imagine you'd have to send a different ID for each instance of the gamepad object.
@requiem4adreamc
@requiem4adreamc Год назад
Can we make this device Bluetooth?
@heloelo3203
@heloelo3203 2 года назад
I am asking for help @real robots you would convert this library so that you could use it in visual studio code (pico SDK C / C ++) I really care about it because I need to use DFROBOT i2c 16-Bit ADC converter, thank you very much for any help
@heloelo3203
@heloelo3203 2 года назад
I translated with translate google
@real_robots
@real_robots 2 года назад
Why not just implement the ADC through the Arduino IDE? Just use the DFRobot libary and follow the examples on how to get your inputs from the ADC then pass them through my library with .SetX() .SetY() etc. wiki.dfrobot.com/Gravity__I2C_ADS1115_16-Bit_ADC_Module_Arduino_%26_Raspberry_Pi_Compatible__SKU__DFR0553
@eminentbadge60
@eminentbadge60 Год назад
Hi, is it possible to connect a joysticks with the Pico instead of the potentiometer. Does the Pico have 2 analog inputs?
@real_robots
@real_robots Год назад
Hi, you need 2 analog inputs for each joystick, a 2 axis joystick is just two potentiometers basically. unfortunately the Pico only has 3 analog inputs you can use so unless you use extra components you can't run 2 joysticks through it
@eminentbadge60
@eminentbadge60 Год назад
@@real_robots I actually just made it using Arduino. I meant I needed 4 analog inputs on the Pico for 2 joysticks...
@real_robots
@real_robots Год назад
@@eminentbadge60 nice one, so you ended up using something with an atmega32u4?
@eminentbadge60
@eminentbadge60 Год назад
@@real_robots No, i used something called "Arduino Uno Joy" which basically changes an arduino's bootloader to be recognised as a joystick by windows
@real_robots
@real_robots Год назад
@@eminentbadge60 oh cool, I've never tried that, all my Uno's are cheap Chinese knockoffs which use a cheaper USB interface so wouldn't work with that
@mickeyevans2905
@mickeyevans2905 Год назад
I'm getting "Failed uploading: uploading error: exit status 1" when I try to upload to Pico, any idea what I'm doing wrong?
@real_robots
@real_robots Год назад
I'm not familiar with that error, try following the instructions on the link below, it's what I got when I did a seach for it. www.circuitsnoop.com/2022/08/raspberry-pi-pico-with-arduino-ide-1-8-or-2-0-fix-failed-uploading-uploading-error-exit-status-1-windows/
@javiernaranjo2395
@javiernaranjo2395 Год назад
Sorry to bother you but is it possible use the pico as a gamepad and keyboard at the same time?
@real_robots
@real_robots Год назад
I've not tried it but I'm pretty sure you can if you run an HID keyboard library alongside this one. I did it a few years ago with an Arduino Pro Micro, each library sends a different HID report so they stay separate.
@javiernaranjo2395
@javiernaranjo2395 Год назад
@@real_robots Thanks I will try that. One last question, is it possible to use the pico as two gamepads at the same time?
@Brychu665
@Brychu665 Год назад
I have some on off toggle switches, I would like them to send a trigger when I flip them on and then the same trigger when I flip them off. Is this possible ?
@real_robots
@real_robots Год назад
absolutely, you just need to write a little code to remember the previous state of the input, then send the trigger on the change rather than just reflecting it being on/off
@real_robots
@real_robots Год назад
Something like this. bool previousButtonState = 0; void loop(){ bool buttonState = digitalRead(5); if (buttonState != previousButtonState){ gamepad.SetButton(0, true); gamepad.send_update(); gameBad.SetButton(0, false); gamepad.send_update(); } previousButtonState = buttonState; }
@Brychu665
@Brychu665 Год назад
@@real_robotswill be trying soon ! Very novice programmer. But excited you responded so quickly.
@Brychu665
@Brychu665 Год назад
@@real_robotsthe number inside digital read is the PIN number right ?
@real_robots
@real_robots Год назад
@@Brychu665 That's right
@omgg4031
@omgg4031 3 года назад
I've notice one axis of the joystick was noisy, how do you deal with it?
@real_robots
@real_robots 3 года назад
It's really minimal noise that you're not really going to notice in game, if you've got noise that's a problem theres a few options. If it's the game picking up the crossover from -1 to 1 near the center you can just create a deadzone, ignoring any input within a small range close to zero. If you've got bad noise you can introduce a low pass filter, basically a little capacitor and resistor which swallow up the noise. I'd usually write a little rolling average, software filter, I've got an example of that in the link below. www.reddit.com/r/HotasDIY/comments/oewevh/hall_sensors_with_jumping_values/h4c2mqx/
@omgg4031
@omgg4031 3 года назад
@@real_robots Many thanks! I'm experiencing this issue but it's with a esp32 on a modified flighstick.
@real_robots
@real_robots 3 года назад
@@omgg4031 No probs, are you using my rr_configurator software for that? I haven't worked in the filtering code yet but it will let you expand your dead zone if that's the problem. www.gitlab.com/realrobots/rr_configurator
@omgg4031
@omgg4031 3 года назад
@@real_robots Sorry i only found about your channel today, had no idea about the rr_controler and rr_confgurator, will give it a try! I basically repurposed an old joystick with an esp32 to work as a BL HID and IBUS for USB control via vJoySerialFeeder, i think the lack of eletronics knowledge is what's causing the issue as i'm getting spikes due to ground bouncing whenever i press buttons or move potentiometers.
@real_robots
@real_robots 3 года назад
@@omgg4031 Whatever works, rr_controller will give you direct bluetooth HID and a gui for setting up your inputs. I haven't put any software filtering in it though.
@fon-tijn
@fon-tijn Год назад
can i rename the device now its shows up as raspberry pi pico with a lot of numbers
@real_robots
@real_robots Год назад
You can't just change it like a typing a string, but you can give it a different VID and PID. I haven't really implemented it in this library though.
@x1roboticxs
@x1roboticxs Год назад
This is the simplest yet easy way to get hid on the RPI pico. Btw I am facing one issue is that it shows up as a raspberry Pi pico on the devices and printers dialogue box on windows when it's supposed to show as a generic gamepad And windows could not consider it as a gamepad and it seems that the RPI pico also crashes when windows checks for the missing drivers. Anyway I hope someone can respond fast with a solution
@real_robots
@real_robots Год назад
The pico crashing is odd, the name should be Pi Pico gamepad (or something generic like that) so I don't think that's causing the trouble. Are you using the basic example? What have you added to the circuit?
@x1roboticxs
@x1roboticxs Год назад
@@real_robots oh wait now its working. Anyways thanks for responding atleast. 🙂
@jarvex
@jarvex 17 дней назад
First Thank you very much for this. I have an old madcatz joystick and want to mod it. Till that happens, as i am new on micro controles, how can I "unload" this code and bring my pico back to default?
@real_robots
@real_robots 17 дней назад
You can write new code to your pico whenever you want. If you want it to accept UF2 files you have to reset it while holding the boot button
@jarvex
@jarvex 16 дней назад
@@real_robots Thx. Interesting, if I use arduino IDE I have a delay on bottons. But using your web configurator it doesn't have the botton lag. Any ideas to a beginer?
@real_robots
@real_robots 15 дней назад
@@jarvex are you using your own code in the Arduino ide? My guess would be you've got some inefficient code, can you post it somewhere I can see?
@jarvex
@jarvex 15 дней назад
@@real_robots No sir. Its yours, I just change the pins and bottons. I tested both: the UF2 file, wich is no delay and the one loaded with arduino IDE, wich has the lag. I'll check it again, I'm kinda busy now. Just reporting. My board, by the way, its that chinese one with reset botton and RGB LED. Cheers!
@real_robots
@real_robots 15 дней назад
@@jarvex that's weird, thanks for the heads up
@So-Now
@So-Now Год назад
Nice idea but just gives: C:\Users\User\Documents\Arduino\libraries\PicoGamepad/PicoGamepad.h:21:10: fatal error: PluggableUSBHID.h: No such file or directory as the result.
@real_robots
@real_robots Год назад
There's two ways of setting up rp2040 for Arduino, only one includes pluggablehid. I can't remember right now which one you need, the earlphilhower one or the later one that's built into the Arduino board libraries.
@TheJavaSync
@TheJavaSync Год назад
Is it work to another boards? (Ex - ESP8266 Dev Kit) Thank You for this amazing tutorial
@real_robots
@real_robots Год назад
Sorry no, this one only works with the rp2040
@robomaster53
@robomaster53 2 года назад
All of a sudden I can't compile the gamepad program getting the following error messages. I am unable to find the problem Arduino: 1.8.19 (Windows 10), Board: "Raspberry Pi Pico, 2MB (no FS), 125 MHz, Small (-Os) (standard), Disabled, Disabled, None, Pico SDK" In file included from C:\Users\Robot\Documents\Arduino\libraries\PicoGamepad-master\examples\PicoGamepad\PicoGamepad.ino:19: C:\Users\Robot\Documents\Arduino\libraries\PicoGamepad-master/PicoGamepad.h:21:10: fatal error: PluggableUSBHID.h: No such file or directory 21 | #include "PluggableUSBHID.h" | ^~~~~~~~~~~~~~~~~~~ compilation terminated. exit status 1 Error compiling for board Raspberry Pi Pico. Invalid library found in C:\Users\Robot\Documents\Arduino\libraries\Nano-33-BLE-Sense-master: no headers files (.h) found in C:\Users\Robot\Documents\Arduino\libraries\Nano-33-BLE-Sense-master Invalid library found in C:\Users\Robot\Documents\Arduino\libraries\PicoGamepad: no headers files (.h) found in C:\Users\Robot\Documents\Arduino\libraries\PicoGamepad Invalid library found in C:\Users\Robot\Documents\Arduino\libraries\Nano-33-BLE-Sense-master: no headers files (.h) found in C:\Users\Robot\Documents\Arduino\libraries\Nano-33-BLE-Sense-master Invalid library found in C:\Users\Robot\Documents\Arduino\libraries\PicoGamepad: no headers files (.h) found in C:\Users\Robot\Documents\Arduino\libraries\PicoGamepad Could not find boards.txt in C:\Users\Robot\AppData\Local\Arduino15\packages\arduino\hardware\mbed\1.3.2. Is it pre-1.5? Invalid library found in C:\Users\Robot\Documents\Arduino\libraries\Nano-33-BLE-Sense-master: no headers files (.h) found in C:\Users\Robot\Documents\Arduino\libraries\Nano-33-BLE-Sense-master Invalid library found in C:\Users\Robot\Documents\Arduino\libraries\PicoGamepad: no headers files (.h) found in C:\Users\Robot\Documents\Arduino\libraries\PicoGamepad Invalid library found in C:\Users\Robot\Documents\Arduino\libraries\Nano-33-BLE-Sense-master: no headers files (.h) found in C:\Users\Robot\Documents\Arduino\libraries\Nano-33-BLE-Sense-master Invalid library found in C:\Users\Robot\Documents\Arduino\libraries\PicoGamepad: no headers files (.h) found in C:\Users\Robot\Documents\Arduino\libraries\PicoGamepad Invalid library found in C:\Users\Robot\Documents\Arduino\libraries\Nano-33-BLE-Sense-master: no headers files (.h) found in C:\Users\Robot\Documents\Arduino\libraries\Nano-33-BLE-Sense-master Invalid library found in C:\Users\Robot\Documents\Arduino\libraries\PicoGamepad: no headers files (.h) found in C:\Users\Robot\Documents\Arduino\libraries\PicoGamepad Invalid library found in C:\Users\Robot\Documents\Arduino\libraries\Nano-33-BLE-Sense-master: no headers files (.h) found in C:\Users\Robot\Documents\Arduino\libraries\Nano-33-BLE-Sense-master Invalid library found in C:\Users\Robot\Documents\Arduino\libraries\PicoGamepad: no headers files (.h) found in C:\Users\Robot\Documents\Arduino\libraries\PicoGamepad Invalid library found in C:\Users\Robot\Documents\Arduino\libraries\Nano-33-BLE-Sense-master: no headers files (.h) found in C:\Users\Robot\Documents\Arduino\libraries\Nano-33-BLE-Sense-master Invalid library found in C:\Users\Robot\Documents\Arduino\libraries\PicoGamepad: no headers files (.h) found in C:\Users\Robot\Documents\Arduino\libraries\PicoGamepad Invalid library found in C:\Users\Robot\Documents\Arduino\libraries\Nano-33-BLE-Sense-master: no headers files (.h) found in C:\Users\Robot\Documents\Arduino\libraries\Nano-33-BLE-Sense-master Invalid library found in C:\Users\Robot\Documents\Arduino\libraries\PicoGamepad: no headers files (.h) found in C:\Users\Robot\Documents\Arduino\libraries\PicoGamepad Invalid library found in C:\Users\Robot\Documents\Arduino\libraries\Nano-33-BLE-Sense-master: no headers files (.h) found in C:\Users\Robot\Documents\Arduino\libraries\Nano-33-BLE-Sense-master Invalid library found in C:\Users\Robot\Documents\Arduino\libraries\PicoGamepad: no headers files (.h) found in C:\Users\Robot\Documents\Arduino\libraries\PicoGamepad Invalid library found in C:\Users\Robot\Documents\Arduino\libraries\Nano-33-BLE-Sense-master: no headers files (.h) found in C:\Users\Robot\Documents\Arduino\libraries\Nano-33-BLE-Sense-master Invalid library found in C:\Users\Robot\Documents\Arduino\libraries\PicoGamepad: no headers files (.h) found in C:\Users\Robot\Documents\Arduino\libraries\PicoGamepad Invalid library found in C:\Users\Robot\Documents\Arduino\libraries\Nano-33-BLE-Sense-master: no headers files (.h) found in C:\Users\Robot\Documents\Arduino\libraries\Nano-33-BLE-Sense-master Invalid library found in C:\Users\Robot\Documents\Arduino\libraries\PicoGamepad: no headers files (.h) found in C:\Users\Robot\Documents\Arduino\libraries\PicoGamepad Invalid library found in C:\Users\Robot\Documents\Arduino\libraries\Nano-33-BLE-Sense-master: no headers files (.h) found in C:\Users\Robot\Documents\Arduino\libraries\Nano-33-BLE-Sense-master Invalid library found in C:\Users\Robot\Documents\Arduino\libraries\PicoGamepad: no headers files (.h) found in C:\Users\Robot\Documents\Arduino\libraries\PicoGamepad Invalid library found in C:\Users\Robot\Documents\Arduino\libraries\Nano-33-BLE-Sense-master: no headers files (.h) found in C:\Users\Robot\Documents\Arduino\libraries\Nano-33-BLE-Sense-master Invalid library found in C:\Users\Robot\Documents\Arduino\libraries\PicoGamepad: no headers files (.h) found in C:\Users\Robot\Documents\Arduino\libraries\PicoGamepad Invalid library found in C:\Users\Robot\Documents\Arduino\libraries\Nano-33-BLE-Sense-master: no headers files (.h) found in C:\Users\Robot\Documents\Arduino\libraries\Nano-33-BLE-Sense-master Invalid library found in C:\Users\Robot\Documents\Arduino\libraries\PicoGamepad: no headers files (.h) found in C:\Users\Robot\Documents\Arduino\libraries\PicoGamepad Invalid library found in C:\Users\Robot\Documents\Arduino\libraries\Nano-33-BLE-Sense-master: no headers files (.h) found in C:\Users\Robot\Documents\Arduino\libraries\Nano-33-BLE-Sense-master Invalid library found in C:\Users\Robot\Documents\Arduino\libraries\PicoGamepad: no headers files (.h) found in C:\Users\Robot\Documents\Arduino\libraries\PicoGamepad Invalid library found in C:\Users\Robot\Documents\Arduino\libraries\Nano-33-BLE-Sense-master: no headers files (.h) found in C:\Users\Robot\Documents\Arduino\libraries\Nano-33-BLE-Sense-master Invalid library found in C:\Users\Robot\Documents\Arduino\libraries\PicoGamepad: no headers files (.h) found in C:\Users\Robot\Documents\Arduino\libraries\PicoGamepad Invalid library found in C:\Users\Robot\Documents\Arduino\libraries\Nano-33-BLE-Sense-master: no headers files (.h) found in C:\Users\Robot\Documents\Arduino\libraries\Nano-33-BLE-Sense-master Invalid library found in C:\Users\Robot\Documents\Arduino\libraries\PicoGamepad: no headers files (.h) found in C:\Users\Robot\Documents\Arduino\libraries\PicoGamepad Invalid library found in C:\Users\Robot\Documents\Arduino\libraries\Nano-33-BLE-Sense-master: no headers files (.h) found in C:\Users\Robot\Documents\Arduino\libraries\Nano-33-BLE-Sense-master Invalid library found in C:\Users\Robot\Documents\Arduino\libraries\PicoGamepad: no headers files (.h) found in C:\Users\Robot\Documents\Arduino\libraries\PicoGamepad Invalid library found in C:\Users\Robot\Documents\Arduino\libraries\Nano-33-BLE-Sense-master: no headers files (.h) found in C:\Users\Robot\Documents\Arduino\libraries\Nano-33-BLE-Sense-master Invalid library found in C:\Users\Robot\Documents\Arduino\libraries\PicoGamepad: no headers files (.h) found in C:\Users\Robot\Documents\Arduino\libraries\PicoGamepad This report would have more information with "Show verbose output during compilation" option enabled in File -> Preferences.
@real_robots
@real_robots 2 года назад
Hmm, did you have it working at any point? Did you set up the Pico for Arduino by choosing "Arduino Mbed OS RP2040 Boards" from the boards manager? I think there's another route for installing the pico in Arduino that doesn't have the HID libraries built in that this relies on.
@paulb36utube
@paulb36utube 3 года назад
If you had 2 joysticks Could you define them as x1 y1 and x2 y2?
@real_robots
@real_robots 3 года назад
The HID protocol doesn't have those inputs. You've got X, Y, Z, Rx, Ry, Rz, Throttle and Slider available in this one. If you need more axes in your game you can use one of those and hopefully assign them in game. Did you mean two joysticks on one microcontroller or two microcontrollers connected separately? To do that I need to implement deviceIDs so Windows doesn't confuse the two. That will be in the next update. It's easy to do, I just need to test it. If you want to try it that, let me know and I'll show you where to change it in the library.
@paulb36utube
@paulb36utube 3 года назад
@@real_robots 2 joysticks on the one controller. I have been able to get x1 y1 and x2 y2 joysticks working in the past with 2 seperate joysticks but the USB connector broke on the arduino micro (Noooooooo) and struggled to find the code again. I may have to resort to you suggestion and just allocate the second joystick as a secondary function.
@real_robots
@real_robots 3 года назад
@@paulb36utube That's interesting, usually when you have two joysticks on one device you'd have X/Y on one side and Roll/Yaw, Accel/Thrust, Rx/Ry on the other. It's worth noting you can't actually do any of that with a pico because it's only got 3 ADC pins :-) Yeah those micro usbs come off easily, there are a few Pro Micros out there with USB mini plugs which are way chunkier and have 4 huge pcb mounts but they don't seem to be very available these days.
@ukaszhankus4683
@ukaszhankus4683 3 года назад
@@real_robots Could you tell me what to change to use 2 microcontrollers? One Pico has too little pins.
@real_robots
@real_robots 3 года назад
@@ukaszhankus4683 If you need more pins than the pico can provide you can use Arduino Pro Micros and my software gitlab.com/realrobots/rr_configurator I'll be adding pico support to that software in the future but for the moment you can use it to string together multiple Pro Micros, which allow far more analog inputs. It also has a GUI you can use to configure everything.
@eijikong1660
@eijikong1660 2 года назад
any estimate about the latency?
@real_robots
@real_robots 2 года назад
It's native USB talking directly through HID, there will be bugger all latency here.
@eijikong1660
@eijikong1660 2 года назад
@@real_robots thank you so much for this video and the code, tried it and it works but can SetHat handle 2 buttons at once so we can get NE,NW,SE,SW input?
@yusufylmaz8098
@yusufylmaz8098 Год назад
Hi, i am using your library. I was succesful in the first attempts. I had 2 axis and 22 buttons joystick. Used it for months. Then for one reason i wanted to increase button number to 23. But whatever i do i cant even get ArduinoIDE to compile. First i received "PluggableUSBHID.h No such file or directory" error. Then i managed to find the header file. But this does not solved the problem. Next error is "USBDescriptor.h: No such file or directory". I just end up with header files missing one after another. I used the same computer. Tried reinstalling arduino and libraries. But cant resolve anything.
@real_robots
@real_robots Год назад
Pluggableusbhid.h comes with the rp2040 Arduino install, whatever steps you did to set that up, try repeating those
@yusufylmaz8098
@yusufylmaz8098 Год назад
@@real_robots thanks for your comment. Problem fixed itself somehow. 😄 RP2040 boards are a mess right now. Maybe an update fixed my files.
@yusufylmaz8098
@yusufylmaz8098 Год назад
@@real_robots by the way thank you very much for the library too. I made an F16 sidestick with 2 axis and 22 buttons. This was the easiest pico library that enabled me to finish the project with cheapest board.
@Sleth0theoriginal0
@Sleth0theoriginal0 9 месяцев назад
Update to those watching in 2023 or later: Make sure you uninstall the libraries and reinstall version 2.2.0! Spent a whole day troubleshooting and forgot the basics.
@giangluong2017
@giangluong2017 3 года назад
Hello
@real_robots
@real_robots 3 года назад
hi!
@noawe_
@noawe_ 2 года назад
have my kids
@robomaster53
@robomaster53 2 года назад
Better Version of the error code. Arduino: 1.8.19 (Windows 10), Board: "Raspberry Pi Pico, 2MB (no FS), 125 MHz, Small (-Os) (standard), Disabled, Disabled, None, Pico SDK" In file included from C:\Program Files (x86)\Arduino\libraries\PicoGamepad\examples\PicoGamepad\PicoGamepad.ino:19: C:\Program Files (x86)\Arduino\libraries\PicoGamepad/PicoGamepad.h:21:10: fatal error: PluggableUSBHID.h: No such file or directory 21 | #include "PluggableUSBHID.h" | ^~~~~~~~~~~~~~~~~~~ compilation terminated. exit status 1 Error compiling for board Raspberry Pi Pico. Invalid library found in C:\Users\Robot\Documents\Arduino\libraries\PicoGamepad: no headers files (.h) found in C:\Users\Robot\Documents\Arduino\libraries\PicoGamepad
@StevenCookFX
@StevenCookFX 2 года назад
This sends serial signals only. It doesn't mimic the same functionality of an actual joystick. It will not work with the web built in joystick api either. :/
@real_robots
@real_robots 2 года назад
Not sure why you're only getting serial messages but this absolutely does HID communication and works with your PC as any other game controller/joystick. Did you get any error messages during compilation? Did you run the example sketch?
@tonorubina46
@tonorubina46 2 года назад
Xbox 360 buttons
@stalkerelias6442
@stalkerelias6442 Год назад
Hello, I have a problem that I wanted to know if you know how to solve it😕. I was doing a test of the program with 2 tact switch to see if it worked but when I upload it to the Raspberry Pi Pico RP2040W, although it is uploaded and appears as a device on the computer, it cannot be configured, the RR_Configurator does not work when it is select (hangshake timeout) and in general, although the games identify it, the buttons do not work, the program that I compiled was: #include #include #define PIN_BIN_1 19 #define PIN_BIN_2 20 PicoGamepad gamepad; void setup() { Serial.begin(115200); pinMode(PIN_BIN_1, INPUT); pinMode(PIN_BIN_2, INPUT); } void loop() { gamepad.SetButton(1, !digitalRead(PIN_BIN_2)); gamepad.SetButton(0, !digitalRead(PIN_BIN_1)); gamepad.send_update(); } Sorry if the message is mistranslated, I'm using Google Translate. From already thank you very much
@real_robots
@real_robots Год назад
The rr_configurator doesn't work with this, it's just an HID library and you'll have to program the buttons and bindings yourself
@stalkerelias6442
@stalkerelias6442 Год назад
@@real_robots hello, thank you very much for the answer, the problem that happens to me is that as I said it does not let me assign the buttons and keys in the games, no does it open the properties windows configuration, for example in War Thunder i want to bind the buttons but nothing happens
@real_robots
@real_robots Год назад
@@stalkerelias6442 hmm, I'm not sure why, your code looks okay. Did it have any errors when compiling and uploading?
@stalkerelias6442
@stalkerelias6442 Год назад
@@real_robots No, I have not had errors compiling, but I have done the test on another computer and this one does allow me to configure it as if it were a joystick, the issue now is that the two buttons that I wanted to test always appear normally closed, they are always on for more than In the programming there is nothing that says that they are always high, they are on pins 19 and 20, In addition, I even tried to send it to GND with a resistor to test, but it did not work
@real_robots
@real_robots Год назад
@@stalkerelias6442 strange, the simolest way to wire buttons on a pro micro is one side to gnd and the other side to the digital pin, don't need a resistor. Set the pinmode to INPUT_PULLUP
@ewartmouton
@ewartmouton Год назад
Worked great until recently but now the default code gives: PicoGamepad.h:21:10: fatal error: PluggableUSBHID.h: No such file or directory
@real_robots
@real_robots Год назад
PluggableUSBHID.h should be included with the pico board files, try reinstalling the Pico2040 using the board manager.
Далее
How to use Analog Joysticks with the PICO
16:07
Просмотров 5 тыс.
Ютуб был хороший...
00:52
Просмотров 323 тыс.
So I Made My Own GAME CONTROLLER...
5:40
Просмотров 4,8 тыс.
Ultimate FPS Controller Design & Build
29:06
Просмотров 2 млн
The Raspberry Pi Pico WAS Overrated! But that changed!
10:18
My New Linear Actuators are SO MUCH BETTER! | PDJ #21
21:03
Arduino Joystick 2.0  Library  - Beginners Guide
25:22
Просмотров 82 тыс.
Battle of the Zeros
19:44
Просмотров 54 тыс.