Raspberry Pi Pico Tutorial - Joystick ( MicroPython )

Поделиться
HTML-код
  • Опубликовано: 26 окт 2024
  • ХоббиХобби

Комментарии • 89

  • @hermandarr6274
    @hermandarr6274 2 года назад +3

    Dude, you rock Pico tutorials, keep up the good work.

    • @NerdCaveYT
      @NerdCaveYT  2 года назад

      Thank you, for the feedback really appreciate it.

  • @hopi9927
    @hopi9927 2 года назад +1

    I love your pico tutorials series so much .please make awesome projects related to the pico a lot .thank you 👍👍👍

    • @NerdCaveYT
      @NerdCaveYT  2 года назад

      Thank you, cool projects are coming soon.

  • @richiethebartender
    @richiethebartender Год назад +1

    Great series of videos - super useful, thank you!!

  • @Kris-cd9qs
    @Kris-cd9qs Год назад

    Thanks, great video. All clear and understandable 👍👍

  • @yannmassard3970
    @yannmassard3970 2 месяца назад +2

    i was like wtf is this ADC sorcery, then found out pico has ADC channels .... good to know

    • @NerdCaveYT
      @NerdCaveYT  Месяц назад

      yes, this is something I hope future Raspberry PI's will have a lot of people want this tutorial for the PI well you can use external ADC should probably make a video on that

    • @yannmassard3970
      @yannmassard3970 Месяц назад

      @@NerdCaveYT you are absolutely right, there are actually ZERO tutorial on how to connect a 5pins 5.5v joystick on the rapsberry4b via a 1X115 ADC board and the code that goes with it. Had to find out myself. I also discovered that i2c BUS 1 didnt work properly on 4b with ADCs, it s preferable to use BUS 0, moist of the time, bus1 would simply never find the ADC (through i2dcDetect -y 1). Took me hours before trying bus 0 (on pins 27 28). And managed to get a joystick to controll the mouse.
      peace

  • @lorisrobots
    @lorisrobots 2 года назад

    Great video. Thanks for sharing.

  • @chenqingzhi6845
    @chenqingzhi6845 Год назад

    quite detailed

    • @NerdCaveYT
      @NerdCaveYT  11 месяцев назад

      Thank you, I think this could probably made a bit more stable using capacitors

  • @planetsurgery
    @planetsurgery 14 дней назад

    I’m on a quad pico extender and my analog pins seem to trip out over this. Joystick and sensor values are all over the place. How do I fix this?

  • @Explore-Gobal
    @Explore-Gobal Год назад

    Add me to the list of people that would love to see this type of joystick controlling the cursor on a Raspberry Pi.

    • @NerdCaveYT
      @NerdCaveYT  Год назад

      I was AFK for a long while, where you able to solve it or you still need a video?

  • @muhammadfarooqi
    @muhammadfarooqi 2 года назад

    instead of setting values what you did at 5:43 .. you can write something like this. .
    round((yValue / 65535)*100) ...
    round((xValue / 65535)*100) ...
    This can give you percentage for a little more close to understandable value.

  • @gggg-bk7md
    @gggg-bk7md 2 года назад +1

    hi... can this applied to make an atari joystick adapter?? Thanks for your tutorials

    • @NerdCaveYT
      @NerdCaveYT  2 года назад +1

      Hi so if I understand correct you want to take an Atari joystick connect it to pico to be used as input for pc

    • @gggg-bk7md
      @gggg-bk7md 2 года назад

      @@NerdCaveYT yes... That´s Right...

    • @NerdCaveYT
      @NerdCaveYT  2 года назад

      @@gggg-bk7md that should be possible saw someone do it on Arduino and explain which each pin does and how to connect it, it will be easy to rewrite in CircuitPython then on the Pico

    • @gggg-bk7md
      @gggg-bk7md 2 года назад

      @@NerdCaveYT ok, thanks por your answer... ✌

  • @dooogfella
    @dooogfella 2 года назад +1

    Awesome! Saw your post on reddit OP 😁
    Question:
    What would happen if you put the joy stick in between 2 direction? Would it lit both LED or you need another line for that?

    • @NerdCaveYT
      @NerdCaveYT  2 года назад

      It will both be on since the two if statements would be true and thus both will be one if you want to put an extra LED between the two direction you can make another if statement that will trigger if both is true and then you make the other normal direction to be 0.

  • @mortallychallenged1436
    @mortallychallenged1436 2 года назад +1

    How would I make this a simple joystick/"controller" on Windows 10?

    • @NerdCaveYT
      @NerdCaveYT  2 года назад +2

      I would probably use an old arcade joystick module with some arcade buttons to give that authentic feel, this would actually be a nice project to do, but I would use CircuitPython since it allows the Pico to be used as an HID device. This is a good question I will make something next week

    • @mortallychallenged1436
      @mortallychallenged1436 2 года назад

      @@NerdCaveYT Thank you for the quick response!
      If it helps you any way.
      The idea behind it is due to me having a project to modify a keypad.
      Like in this video. ruclips.net/video/0aBWoCRPxiU/видео.html
      The use was as a smooth secondary joystick in a simulators for all kinds of things that need to turn (like, turrets, missiles, devices...) next to the airplane (controlled via a proper joystick) but also softer character controls (slow walking, walking, jogging, runnning,...) .
      Unfortunately I could not get the same hardware components as the man here.
      So I figured out that what he did was setting up a small "joystick" while ignoring the old lackluster hardware via some programmable USB board.
      Your tutorials so far are good. It showed me that my soldering was ok and the components work without an issue (cables are still movable from pin to pin).
      I will see where the journey with programmable devices will bring me.
      Maybe I will make my own HOTAS system or something fancy like this: store.azeron.eu/

  • @itsqqgaming8212
    @itsqqgaming8212 Год назад

    Ok i have all this set up it shows the buttons being pressed in thonny but how do i get this to move a character in a game with wasd

    • @NerdCaveYT
      @NerdCaveYT  Год назад

      Will have to use circuit python and set up as a joystick, let me have a look at it and make a video lot of people asking about this

  • @venomkraft1752
    @venomkraft1752 Год назад

    could this be used in pc gaming , or is it to complicated, im new to this

    • @NerdCaveYT
      @NerdCaveYT  Год назад +1

      well I would say for like old school arcade games it will work great but for fps shooters the values fluctuate a lot so will have to add filters to circuit and little bit better coding then it should work.

  • @gwm249
    @gwm249 2 года назад

    Hey boet. Nice video. I wanted to ask if you know of any HID library to get these to work as joysticks for a PC, kind of making your own controller thing.

    • @NerdCaveYT
      @NerdCaveYT  2 года назад

      Hello thank you, CircuitPython has a great HID library: docs.circuitpython.org/projects/hid/en/4.0.1/_modules/adafruit_hid/gamepad.html I used it for a Macro Keyboard and Midi before, I assume you will want the joystick to send certain values that part you might to code like something similar I did in my last value to see the value of the joystick position since those modules fluctuate a lot when they are connected to the ADC channel. If you need more help got a discord channel not much going on there now: discord.gg/A4zegrBp

  • @PotatoGunCamper
    @PotatoGunCamper 2 дня назад

    How to make it correspond with keyboard presses?

    • @NerdCaveYT
      @NerdCaveYT  День назад

      You will need to use circuitpython HID library on my channel I did convert joystick to mouse, so instead of using mouse HID library you can use the keyboard, are you building a gamepad?

  • @aleksandarbozic7050
    @aleksandarbozic7050 7 месяцев назад

    where have you bought the joystick, please?

    • @NerdCaveYT
      @NerdCaveYT  7 месяцев назад +1

      Hi, unfortunately don't think I can provide link because I bought it from a shop in China through a local e-commerce site Taobao. I live here in China, but you can find many of these on aliexpress or amazon. Search "Dual-axis XY Joystick Module KY-023" or just Arduino Dual-axis XY Joystick Module

    • @aleksandarbozic7050
      @aleksandarbozic7050 7 месяцев назад

      Thank you very much. You are most kind. I have bought it. Btw-keep giving us these amazing videos! Thank you.

  • @RainbowSheep_was_taken
    @RainbowSheep_was_taken 2 года назад +1

    u can use a pico as hid right? if so, then can you make the joystick control the mouse cursor? and even better, can you make it into an actual controller? like using the axis to as controller axis
    please make a tutorial on this, please

    • @NerdCaveYT
      @NerdCaveYT  2 года назад +2

      You can do this, it was something I was looking into doing. At this moment all my stuff is packed away and really hope in two weeks can move and start my videos again

    • @RainbowSheep_was_taken
      @RainbowSheep_was_taken 2 года назад

      @@NerdCaveYT Great! Can't wait!

    • @hola_chelo
      @hola_chelo 2 года назад +1

      @@NerdCaveYT If you have the time and managed to get some time, would you please do the tutorials? I want to create a controller with the raspberry Pi pico but don't know how to haha. Thanks for your videos!

    • @NerdCaveYT
      @NerdCaveYT  2 года назад +1

      @@hola_chelo I will was looking at making controllers and one for clone hero, I have few visa related documents but hope to have my apartment ready and everything sorted by the 7th things are a bit different where I am people not used to seeing a foreigner in my area.

    • @hola_chelo
      @hola_chelo 2 года назад +1

      @NerdCave that'd be awesome, no worries, there's no rush mate, hope all goes well for you. I just wanted to know if you were going to do it at all so I will turn on notifications! cheers!

  • @oneandonlyarajivp
    @oneandonlyarajivp 2 года назад

    hi what is the joystick model here? do you have a link from where i can buy it? thanks

    • @NerdCaveYT
      @NerdCaveYT  2 года назад

      Hi, if you just search KY-023 you will find it either on aliexpress or amazon. I use a Chinese app to buy things since I am currently working here so if I create links to things I bought won't be helpful to anyone.

  • @christopherlyons7613
    @christopherlyons7613 2 года назад

    Thanks for the video. What joystick are you using? Can you please leave a link to it.

    • @NerdCaveYT
      @NerdCaveYT  2 года назад

      Sure thing I looked on AliExpress it is this PS2 module one: Dual-axis XY Joystick Module Higher, PS2 Joystick Control Lever Sensor KY-023
      a.aliexpress.com/_vtAGvw

  • @ofirgaash
    @ofirgaash 2 года назад

    Thanks for the video!
    Is there a way to use the Joystick as a mouse pointer on the computer using MicroPython?

    • @NerdCaveYT
      @NerdCaveYT  2 года назад +1

      Hi, yes circuit python has a great HID library which can do it, I get this question a lot will look at making a video soon once I settle in to new place

    • @ofirgaash
      @ofirgaash 2 года назад

      @@NerdCaveYT thanks!
      i was hoping to find someone who managed to run HID on MicroPyhon, not circuitpython

  • @deathkoala3
    @deathkoala3 2 года назад

    Do you know if there is any way to run two analog sticks off the one board?

    • @NerdCaveYT
      @NerdCaveYT  2 года назад

      Hi Callum, so since the Pico only has 3 ADC channels you will have to add external ADC which you can by using something like the ADS1115 16-Bit ADC

  • @полинакомарова-х5ы

    Hi, can I use this code with a regular raspberry pi 3?

    • @NerdCaveYT
      @NerdCaveYT  Год назад

      I just checked the raspberry pi 3 does not have ADC chip but you can use an external ADC such as the MCP3008

  • @BechirSeven
    @BechirSeven 2 года назад

    can i change the code and make the joystick on raspberry pi 4 as mouse

    • @NerdCaveYT
      @NerdCaveYT  2 года назад +1

      Hello, well I am not sure about this one because I have not programmed the raspberry pi 4 if you for example use to joystick with the pico and use the HID library in CircuitPython and connect it to raspberry pi 4 it will work as a mouse

    • @BechirSeven
      @BechirSeven 2 года назад

      @@NerdCaveYT thank you for the answer

  • @MrSiciro
    @MrSiciro 2 года назад

    Dankie dankie

  • @cjveeneman
    @cjveeneman 2 года назад

    Consider using 'else if' 😀

    • @NerdCaveYT
      @NerdCaveYT  2 года назад +2

      Thank you for your suggestion. I should use elif or else, I am trying to keep the code as simple as possible for beginners. I will make a simple introduction to MicroPython to cover it in more detail which I can then refer to.

  • @armand9910
    @armand9910 2 года назад

    Good video :)

  • @rorogamer09
    @rorogamer09 8 месяцев назад

    Can someone help me when i pull the joystick up to set the y or x to 65000 then both the y and x value goes up to 65000.

    • @NerdCaveYT
      @NerdCaveYT  7 месяцев назад

      Hi, so you can just in code if you pull up for example y goes above a certain threshold then you can just set both y and x to 65000 with an if statement

    • @rorogamer09
      @rorogamer09 7 месяцев назад

      @@NerdCaveYT But what should i do to fix it that only y or x goes up to 65000

  • @windadar211
    @windadar211 Год назад

    How to mix that with control motor ?

    • @NerdCaveYT
      @NerdCaveYT  Год назад

      check my video using the l298n motor driver

    • @windadar211
      @windadar211 Год назад

      @@NerdCaveYT y have a L293D motor driver

  • @nielitgangtok1231
    @nielitgangtok1231 3 месяца назад

    can i do this using rpi 4

    • @NerdCaveYT
      @NerdCaveYT  3 месяца назад

      The rpi4 does not have ADC pin or IC, so an external ADC module or IC will be needed to read analog data

  • @barlowanimations1517
    @barlowanimations1517 2 года назад

    Hey nerdcave!
    Could you do a tutorial where instead of lights, it sets a variable in python?

    • @NerdCaveYT
      @NerdCaveYT  2 года назад

      Hi, in this video there is a variable being changed due to the Analog in, do you mean if you push the joystick forward it will add for example 1 to another variable? I am just not completely sure how you want to control the variable what is should do if you push forward, backward, left or right.

    • @barlowanimations1517
      @barlowanimations1517 2 года назад

      @@NerdCaveYT yeah! That's great.
      I'm trying to do a game in python dependent on the joystick for a mini arcade cabinet, so it'd control the y-axis of a pong paddle.

    • @NerdCaveYT
      @NerdCaveYT  2 года назад

      So at this moment you have the line yValue = yAxis.read_u16() this will read the "middle" value which will give you a minimum value of 0 to maximum 65,536 depending in which direction you push the joystick. Now in your game you will then set the paddle equal to this yvalue. The only issue is you will need a few if statements like my last example because the value fluctuate in middle if joystick is not pushed.

  • @chrtrv4245
    @chrtrv4245 Год назад

    How i can use this project as a real joystick, on a pc?

    • @NerdCaveYT
      @NerdCaveYT  Год назад +1

      Will have to use circuit python and set up as a joystick, let me have a look at it and make a video lot of people asking about this

    • @Elmorji
      @Elmorji Год назад

      @@NerdCaveYT can you keep me updated on if this can be done your toutorials have been the best on RUclips for sure! My goal is to have the joystick output for the number pad on a keyboard in the direction it’s pointing then button press for the “5” key can this be done?

    • @NerdCaveYT
      @NerdCaveYT  Год назад +1

      @@Elmorji how will the number pad look like? push upwards "1" right "2" etc. ?

    • @Elmorji
      @Elmorji Год назад

      @@NerdCaveYT yea so if I could get the code to make the push button be number 5 . Then “up” as number 8 . Left as number 4 . Right as number 6 . Down as number 2 . That would be perfect.

    • @Elmorji
      @Elmorji Год назад

      @@NerdCaveYT I am 2 days new into programming a pico . Is there a way to have windows automatically recognize this pico as the keyboard that’s programmed to a joystick or do you Allways have to open thoony and press the play button.

  • @phamngocquapham5472
    @phamngocquapham5472 Год назад

    I can use it for raspberry pi 4

  • @TheJavaSync
    @TheJavaSync Год назад

    Add HID feature, pls 🙏

    • @NerdCaveYT
      @NerdCaveYT  Год назад

      Will this week quickly make something by HID do you want to use it for mouse or as wasd or arrow movement?

    • @TheJavaSync
      @TheJavaSync Год назад

      @@NerdCaveYT I'll use it as gamepad controller to PC games