No video

programmable nintendo switch controller (intermediate) anthony explains

  Рет қаралды 9,719

anthonywritescode

anthonywritescode

Күн бұрын

I've been working on this project for quite a while -- it allows me to program a nintendo switch controller using python! In this video I show all the parts I used and how I put it together as well as how I've used it to find shiny pokemon, mass release pokemon and more!
- github.com/aso...
- things I've done with this: • nintendo microcontroll...
playlist: • anthony explains
==========
twitch: / anthonywritescode
dicsord: / discord
twitter: / codewithanthony
github: github.com/aso...
stream github: github.com/ant...
I won't ask for subscriptions / likes / comments in videos but it really helps the channel. If you have any suggestions or things you'd like to see please comment below!

Пікірлер: 112
@biakko5812
@biakko5812 2 жыл бұрын
This is such a brilliant project! I tried so many versions of the Switch-Fightstick library, but for whatever reason, yours was the only one that ended up working on my Arduino. You saved me so much hard work and headache, thank you for sharing it!!
@anthonywritescode
@anthonywritescode 2 жыл бұрын
glad it works! I also spent a ton of time trying a bunch of options and ended up just writing my own
@mvlcek9141
@mvlcek9141 2 жыл бұрын
Thank you sooooo soooo much. After a very long research i have found finally somthing that works. You are the best :)
@kentt5563
@kentt5563 3 жыл бұрын
that's cool!! i'll definately try this out sometime soon!
@SwapPartLLC
@SwapPartLLC Жыл бұрын
Your issue with plugging the arduino into the breadboard might not be so much the tightness, but rather, the alignment of the pin headers. I have a cheap old breadboard which I use for sodering headers. Don't use a good one, because the heat from soldering will ruin it. Basically, I insert all the headers, then put the board on and solder everything. Not only does it result in perfectly aligned pin headers, it also prevents burned fingers.
@anthonywritescode
@anthonywritescode Жыл бұрын
that's also how I solder headers -- this board is just a very tight fit
@SwapPartLLC
@SwapPartLLC Жыл бұрын
@@anthonywritescode I see. Well, too tight is certainly better than too loose. My first breadboard was some cheap eBay special. Had to sit there wiggling components until I got them all making contact.
@sparkyb6
@sparkyb6 3 жыл бұрын
To your question about why it worked without connecting ground and +5V, I have a theory. All voltage is a relative measure, so in order for anything to communicate it has to have a shared reference point. This is what we call ground or 0V, but really it's just 0 volts because we've defined it that way (as our reference). So you should always connect ground. The pro micro is powered by the +5V coming from the USB (from the Switch). The chip on that USB serial board needs power too. It could be getting that power from the +5V that you're hooking up on that external pin so that it is also powered by the USB connected to the pro micro, but I think it is more likely that it powers itself from the +5V on its USB (coming from your PC). If the latter is the case as I suspect, then that 5V pin is probably actually meant as an output so that you could power whatever you connect it to off of the same USB. But in this case you're connecting it to the pro micro which already has power so not only don't you have to connected 5V to each other, it is possible not a great idea to. Try disconnecting the 5V (but leave the ground connected) and let me know if that still works. If it does, it probably always will and be a better way to set it up. But how did it work that one time when you didn't connect the ground either? It is possible that the two USBs already had a shared ground. Like if you plugged both USB cables into the same PC, that'd probably work.
@anthonywritescode
@anthonywritescode 3 жыл бұрын
hmmm interesting theory. I guess the shared ground could be the wall outlet? with my laptop I wasn't plugged into anything. I'll try it without 5vvcc and report what I find!
@sparkyb6
@sparkyb6 3 жыл бұрын
@@anthonywritescode The common ground could be the wall outlet, although I don't know whether computer power supplies that have to convert AC to DC tie the grounds together or whether the DC ground would be isolated from the wall outlet. But if worked on a PC that was plugged into the wall and didn't on one that wasn't, that would support the theory that it is connected to the wall ground. Could test with a multimeter, but kind of sounds like a "don't try this at home kids" kind of experiment.
@anthonywritescode
@anthonywritescode 3 жыл бұрын
btw it totally works without 5VVCC connected -- cool!
@Unicornslayer697
@Unicornslayer697 2 жыл бұрын
@@anthonywritescode I am attempting this project but there seems to be a missing file. "output.hex" listed in the flashing section is not apart of the repository. So when I got to flash it "avrdude: error opening output.hex: No such file or directory"
@anthonywritescode
@anthonywritescode 2 жыл бұрын
@@Unicornslayer697 did you run the `make` target? that should build that file
@SurlyDuff814
@SurlyDuff814 2 жыл бұрын
Fantastic project and one that I was excited enough to try and assemble. When attempting to flash however, I keep getting a 'programmer is not responding' error. I've tried everything I could find searching to no avail, about to just give up completely. But still, a neat project and respect for thinking outside the box for how to shiny hunt!
@anthonywritescode
@anthonywritescode 2 жыл бұрын
hmmmm weird! others have had success following this -- I wonder why yours is having issues -- what platform are you on?
@sadhlife
@sadhlife 3 жыл бұрын
funfact: Vcc is actually a remnant of the labels given to parts of a transistor in physics papers and in eventually in textbooks. I think it stands for collector voltage (transistor has 3 parts, the output is called collector)
@JLSXMK8
@JLSXMK8 Жыл бұрын
23:48 Maybe you could use this to have the Twitch chat play Super Mario Maker 2; That would be an excellent idea!
@sadhlife
@sadhlife 3 жыл бұрын
Ben Eater collab when :0
@seeyditti
@seeyditti Жыл бұрын
In your scripts folder you have _clock.py, engine.py, etc. Can you provide some descriptions on what these are for/do?
@anthonywritescode
@anthonywritescode Жыл бұрын
sorry, code is available at your own use -- you can read and figure out how things use stuff -- but I can't really spend time supporting it
@squirrelbazooka8033
@squirrelbazooka8033 2 жыл бұрын
Very new to this, but I'm curious if it's possible to have a prewritten scripts on an Arduino and just hook it into the switch by itself. Do you need to have that USB to Serial bridge to the computer to make this system functional? Is it the computer acting as the controller, or the microcontroller itself?
@anthonywritescode
@anthonywritescode 2 жыл бұрын
yep -- premade things can be done as well -- but it greatly limits the flexibility
@kentt5563
@kentt5563 3 жыл бұрын
could you explain a little more about the type of the wire that you are using? I kind of don't know what kind of wire that is.
@anthonywritescode
@anthonywritescode 3 жыл бұрын
the wires I'm using are some plain breadboard wire -- I think I have these: amzn.to/3ymmm3u
@dagishere3302
@dagishere3302 Жыл бұрын
I've been trying to replicate the seen on the video but when i try to flash it on the Pro Micro it gives me this message "avrdude: butterfly_recv(): programmer is not responding". I tried everything and nothing seems to work, I'm using Kali on a VM. Sorry for the inconvenience.
@anthonywritescode
@anthonywritescode Жыл бұрын
the device will show up as a different usb device when in programming mode -- make sure to passthrough that device as well
@doodle3115
@doodle3115 Ай бұрын
Hello Hello, I seem to be having an issue where the pro micro isn't entering programming mode. It's the same one you have linked in the readme, I have tried attaching a button and using a headphone jack. But windows never makes the noise and the terminal repeatedly gives me: avrdude ser_send() OS error: unable to write: Resource temporarily unavailable avrdude butterfly_vfy_cmd_sent() error: programmer did not respond to command: leave prog mode and then getting stuck on: avrdude butterfly_vfy_cmd_sent() error: programmer did not respond to command: exit bootloader Is this anything you might have words of wisdom for?
@anthonywritescode
@anthonywritescode Ай бұрын
you mentioned you're on windows -- are you working in a virtual machine like I am? you may need to add the usb device to the auto-attach list if you're using virtualbox (since the programming mode is a separate device itself) I've also had a similar error (though no idea if it's the same message) when I bricked a board -- though I would make sure to try a bunch of stuff first before getting a new one
@doodle3115
@doodle3115 Ай бұрын
​@@anthonywritescode Alright, so the problem was entirely the auto-attach to vm thing. I've got it flashed now, shows up as a pokken controller and everything. That's my bad for missing something covered in the video. Thanks for your help.
@Magoo277
@Magoo277 10 ай бұрын
Is this code able to be used to build your own controller and then sell? I have a few ideas but I'm confused on the license. I'd like to start making my own but I'm not sure if using this code is viable or if I'd have to go about creating my own code for my own controller if I wanted to sell it.
@anthonywritescode
@anthonywritescode 10 ай бұрын
there's a few parts -- the LUFA code is under their particular license. the rest I haven't licensed so you should treat it as source available and proprietary. though there's plenty of permissively licensed versions of similar code out there
@Magoo277
@Magoo277 10 ай бұрын
​@@anthonywritescodethanks for the reply! I really appreciate it. I don't wanna go about using anyone's code the maliciously so I'm just trying to find the best route. What route would you recommend? Thanks again for the reply!!
@anthonywritescode
@anthonywritescode 10 ай бұрын
I'd recommend not ripping off someone's hard work for profit but it seems you don't care about ethics
@Magoo277
@Magoo277 10 ай бұрын
@@anthonywritescode All I was wondering is if this code was open source or not. I don't appreciate the accusations of being unethical especially considering I already stated that I'm not going the malicious route. I was trying to get some advice on how I could go about making this on my own and where to start because I don't want to be ripping anyone off. If I wanted to rip you off I wouldn't have taken the time to even ask you about it, but I did because I AM ethical.
@dominiquedunlap9223
@dominiquedunlap9223 Жыл бұрын
This is a Great Project, I have a question, Could this be used to Take an actual Switch Controller or GameCube Controller and upon certain inputs, run custom macros?
@anthonywritescode
@anthonywritescode Жыл бұрын
I think it would maybe be possible, assuming you can feed those controllers into a computer
@sadhlife
@sadhlife 3 жыл бұрын
microchips don't break that easily :p at least not without some smoke (I've had some work even after smoking!)
@exo7260
@exo7260 3 жыл бұрын
you are quite amazing
@TheCubanGeneral
@TheCubanGeneral 2 жыл бұрын
I have managed to wire everything and setup my board and etc, I am on windows so stupid question but what do I do for "sudo apt install avrdude gcc-avr avr-libc dfu-programmer" on windows? Im trying to follow along and try the regi reset approach. Essentially where would I plug in all those commands at 12:31
@anthonywritescode
@anthonywritescode 2 жыл бұрын
ah, those instructions are for linux -- I'm a lot less familiar with how to flash from windows
@TheCubanGeneral
@TheCubanGeneral 2 жыл бұрын
Hmm, I might be able to just make a VM, you also did mention Ubunto so i might try that. I came too far to stop now
@anthonywritescode
@anthonywritescode 2 жыл бұрын
that's how I have mine set up fwiw -- here's how my VM is configured: kzfaq.info/get/bejne/p7Jjq8Zpzd25Z5c.html
@TheCubanGeneral
@TheCubanGeneral 2 жыл бұрын
@@anthonywritescode I ended up setting everything up and trying to launch the code, Whenever I do (reset and then submit the code) it just tells me can't open device "/dev/ttyACM7": No such file or directory" if I wait too long then it will try to execute but say ".avrdude: butterfly_recv(): programmer is not responding " haha Ive been at this for hours now. I don't know if its fired or something. The ACM number just keeps increasing after failed attempts
@pokeeo
@pokeeo 2 жыл бұрын
Any chance you’re going to work on anything for brilliant diamond/shining pearl?! I’d love help with restarting for my shiny starter but can’t find code anywhere!
@anthonywritescode
@anthonywritescode 2 жыл бұрын
I might! it wouldn't be too difficult to adapt one of the other scripts -- the code lives in github.com/asottile/switch-microcontroller
@pokeeo
@pokeeo 2 жыл бұрын
@@anthonywritescode I have zero coding knowledge but I am going to pass this on to a friend who may be able to help! Thank you!
@nathancombs7122
@nathancombs7122 Жыл бұрын
Would this project with a raspberry pi 400?
@TheCubanGeneral
@TheCubanGeneral 2 жыл бұрын
This is old but I had a project of using CV to shiny reset for a shiny afk. (Still new to python) My plan is to have a true false or something like that with the two images of the Pokemon. If it's the shiny then to stop resetting and if it's not continue running the code. What is your opinion on this.
@anthonywritescode
@anthonywritescode 2 жыл бұрын
that's going to be a lot harder than the approach that I used: kzfaq.info/get/bejne/mLtzrJqcmrS-m5s.html
@TheCubanGeneral
@TheCubanGeneral 2 жыл бұрын
@@anthonywritescode thanks I will try it out! Trying to improve my skills!
@vtech8543
@vtech8543 2 жыл бұрын
This is an amazing project. I have one question tho. Is there a way to hold a button down without giving a time limit. The reason I’m asking this is because I want to get my Xbox controller to work with the switch so I wouldn’t know how long to hold the button down for.
@anthonywritescode
@anthonywritescode 2 жыл бұрын
yeah, at least the way the code I wrote works is any instruction causes a toggle -- so an `A` will cause it to be held until `.` is sent
@jeroldmorphy3764
@jeroldmorphy3764 Жыл бұрын
Say I want to write an AI that does the aiming for me in a shooting game, can I seamlessly switch between chip control and actual control?
@anthonywritescode
@anthonywritescode Жыл бұрын
it's not a great fit for realtime adjustments -- mostly works well for turn based stuff. you could probably feed your controller through the computer and trade off but nothing is written for that
@oscarmg7083
@oscarmg7083 5 ай бұрын
Hi, i don't know if you're still responding questions, but i don't seem to have this working. I finally got to the final part of this video (which is finally plugging in the arduino usb into the dock) but the console doesn't seem to pick up arduino, and after i try to code in the press A code. i either get a "ModuleNotFoundError: No module named 'scripts.switch'" error if i don't have the scripts folder in the nintendo switch or a "SyntaxError: invalid syntax" error when i do. I doubled checked and i have everything done correctly just before this step, so i don't where did i go wrong
@anthonywritescode
@anthonywritescode 5 ай бұрын
the syntax error sounds like you've got an incompatible version of python also the latest version of the firmware doesn't do the boot up sequence any more so you have to press that using the scripts
@oscarmg7083
@oscarmg7083 5 ай бұрын
@@anthonywritescode got it, i had to downgrade my python to 3.7.7 using pyenv bc i had to do some projects with that version, but i can switch it back to my system version (3.10) or upgrade it to the needed version also, the boot up sequence to start the arduino is started using the codes used with press.py, right?
@anthonywritescode
@anthonywritescode 5 ай бұрын
yeah you'll need a moden version of python. you actually don't need the specific bootup sequence -- I usually just use `python3 -m press H` until it connects
@oscarmg7083
@oscarmg7083 5 ай бұрын
​@@anthonywritescode yes, that seemed to be the problem! after switching to python 3.10 (+ installing some programs i had missing for it) i finally got to work, now i can afk shiny hunt shaymin. thanks for your help!
@maxmax-mn1vg
@maxmax-mn1vg Ай бұрын
you did the project very good!!! i really appreciate it , but i have one bugs when working on your project : that it appears Connecting to programmer: . avrdude: butterfly_recv(): programmer is not responding Found programmer: Id = "1023 �"; type = Software Version = 1.0; Hardware Version = 2.3 avrdude: error: buffered memory access not supported. Maybe it isn't a butterfly/AVR109 but a AVR910 device? avrdude: initialization failed, rc=-1 Double check connections and try again, or use -F to override this check. avrdude: error: programmer did not respond to command: leave prog mode avrdude: error: programmer did not respond to command: exit bootloader i hope you can help me to take it look, really thanks
@cilasg
@cilasg Жыл бұрын
Would it be possible to use an arduino uno with a atmega328p instead? Because when i try to make its firmware. It just spits out a bunch of errors
@anthonywritescode
@anthonywritescode Жыл бұрын
it should be, I've seen others build this for uno -- make sure you've got the submodules checked out!
@cilasg
@cilasg Жыл бұрын
It was giving a weird usb_device_only error when trying to make
@archeknight
@archeknight Жыл бұрын
Been trying to work this out, but I've been getting an error when trying to program the Arduino. I get the error 'avrdude: ser_open(): can't open device "/dev/ttyACM0": no such file or directory'. I've tried googling around for a solution but haven't been able to find anything. I'm not familiar with Arduinos or virtual machines, so I was wondering if you knew what might be causing the issue?
@anthonywritescode
@anthonywritescode Жыл бұрын
when it is in flashing mode (after 2 quick resets) it's a different device that you have to mount separately
@archeknight
@archeknight Жыл бұрын
Thanks so much! This is a really cool project and has been super helpful for a project I've been wanting to work on for a while now.
@thesacredsword7230
@thesacredsword7230 Жыл бұрын
I know the chances of you responding to this is low since the video is old, but do you think it’s possible to use two bluetooth chips to control two switches at the same time with just one input?
@anthonywritescode
@anthonywritescode Жыл бұрын
I read all my comments! it's probably possible yeah -- at least given my setup here you'd need to have two controllers and double the signal to them. there's other solutions out there which try and speak the bluetooth protocol directly -- though that wasn't possible when I put this together
@BlazinEdit
@BlazinEdit 2 жыл бұрын
is there a way to read controlers/ring fit movment to translate it using python as a new output for other games?
@anthonywritescode
@anthonywritescode 2 жыл бұрын
yeah you could in theory relay any input to it
@BlazinEdit
@BlazinEdit 2 жыл бұрын
@@anthonywritescode do you have any material on it, I would appreciate the first part how to capture the movment?
@anthonywritescode
@anthonywritescode 2 жыл бұрын
I don't, but presumably the documentation for the input device's sdk can help you with that. I don't have any specialized input devices currently
@YGONerd27
@YGONerd27 5 ай бұрын
Can this work on an Arduino Uno?
@arisameulolson
@arisameulolson 2 ай бұрын
when i try to run make, it tells me "grep: /usr/share/arduino/hardware/arduino/avr/boards.txt: No such file or directory" How do i fix this?
@anthonywritescode
@anthonywritescode 2 ай бұрын
you're missing the package that provides that -- I think it's in the readme
@arisameulolson
@arisameulolson 2 ай бұрын
@@anthonywritescode i dont see anything in the readme. Am i missing something?
@anthonywritescode
@anthonywritescode 2 ай бұрын
there should be an apt install command somewhere
@arisameulolson
@arisameulolson 2 ай бұрын
I ran the apt install multiple times, to make sure it didn't miss something the first time, still nothing.
@anthonywritescode
@anthonywritescode 2 ай бұрын
weird, it's supposed to pull in this transitive dep: arduino-core-avr
@TheCubanGeneral
@TheCubanGeneral 2 жыл бұрын
Anthony once again I have returned, The VM approach would not work for the life of me, I figured how to use windows instead however I require the direct location of the hex file, I tried to find it in the github but could not find it.
@anthonywritescode
@anthonywritescode 2 жыл бұрын
ah the hex file is a build artifact -- so you could build it on linux and then copy it out?
@TheCubanGeneral
@TheCubanGeneral 2 жыл бұрын
@@anthonywritescode So I managed to flash it on windows, to install this on windows, you need to install arduino (for avrdude) set paths to arduino. and essentially type out the same thing but longer C:\Users\....../bin/avrdude -CC:\Users\......./avrdude.conf -v -V -patmega32u4 -cavr109 "-PCOM17" -b57600 -D "-Uflash:w:C:\Users oobi\Desktop/output.hex:i" The com changed for me when resetting so it would appear as COM5 however when I reset it would switch to 17. I successfully paired it after days of trying, now to actually get it to pair with my switch.
@anthonywritescode
@anthonywritescode 2 жыл бұрын
nice! that's awesome!
@TheCubanGeneral
@TheCubanGeneral 2 жыл бұрын
@@anthonywritescode sorry for all the questions, your code is amazing!
@JonathanTash
@JonathanTash Жыл бұрын
Isn't there a way to just run a program on your computer which connects directly to your switch and sends the controller inputs?
@anthonywritescode
@anthonywritescode Жыл бұрын
I could not find a way, the difficult part is making something which the console recognizes as a controller. perhaps through a programmable Bluetooth peripheral but I couldn't find anyone who had attempted that
@raphaeljosephmary7027
@raphaeljosephmary7027 Жыл бұрын
O_O @8:30 lol (reclick for optimal effect. lol okay im being immature :P @8:35 )
@Koopaa543
@Koopaa543 Жыл бұрын
is it possible to control it using buttons connected to the arduino board itself. Cant seem to find an answer to that
@anthonywritescode
@anthonywritescode Жыл бұрын
you'd have to write code for that but yes that's easily possible
@Koopaa543
@Koopaa543 Жыл бұрын
thats good to know. Im startin to make a custom gamepad-like thingy to get around the problem of not being able to use normal controllers
@anthonywritescode
@anthonywritescode Жыл бұрын
ah yeah the original idea for this project was to play via keyboard but then automation sounded more fun
@sadhlife
@sadhlife 3 жыл бұрын
NOOOOOOOO the push pin was painful.
@sadhlife
@sadhlife 3 жыл бұрын
I think you just have bad quality breadboards. The clips are supposed to spread when pushing anything in
@anthonywritescode
@anthonywritescode 3 жыл бұрын
they do spread, but pushing 22 pins at once is too much force to push a chip down :shrugs:
@sadhlife
@sadhlife 3 жыл бұрын
@@anthonywritescode good boards spread 40 clips at once no problems (;
@sadhlife
@sadhlife 3 жыл бұрын
but it's alright, I've had my fair share of cheap breadboards, good ones are actually hard to find
@gcdani271
@gcdani271 10 ай бұрын
Stupid question 🙋‍♂️: if I connect various microcontrollers to the same computer can I control different Nintendo switch(s)
@anthonywritescode
@anthonywritescode 10 ай бұрын
yep! I'm currently running two at once
@anthonywritescode
@anthonywritescode 10 ай бұрын
they'll be attached to different serial ports though
@gcdani271
@gcdani271 10 ай бұрын
@@anthonywritescode thank you
python typing: object vs Any (intermediate) anthony explains #275
6:36
anthonywritescode
Рет қаралды 1,5 М.
Making a Nintendo Switch Controller out of ANYTHING
11:30
WULFF DEN
Рет қаралды 79 М.
Survive 100 Days In Nuclear Bunker, Win $500,000
32:21
MrBeast
Рет қаралды 162 МЛН
Fortunately, Ultraman protects me  #shorts #ultraman #ultramantiga #liveaction
00:10
all about xargs ! (beginner - intermediate) anthony explains #200
17:16
anthonywritescode
Рет қаралды 9 М.
Nintendo Switch 2 Is More Powerful Than You Think...
13:22
AndresRestart
Рет қаралды 22 М.
Why Nintendo Devs Hate Working With Miyamoto
16:02
Video Game Story Time
Рет қаралды 1,4 М.
Which Arduino to Buy for Making Video Game Controllers?
4:53
Insert Controller Here
Рет қаралды 42 М.
what is a deadletter queue? (intermediate) anthony explains #290
11:06
anthonywritescode
Рет қаралды 9 М.
Beating a Pay to Win game with a bot
5:09
Kian Brose
Рет қаралды 2 МЛН
How to Upgrade your Switch Games with Custom Spines
3:38
Renix Pesale
Рет қаралды 124 М.
My Top 5 Arduino Displays
4:59
InterlinkKnight
Рет қаралды 221 М.
I run untested, viewer-submitted code on my 500-LED christmas tree.
45:17
Survive 100 Days In Nuclear Bunker, Win $500,000
32:21
MrBeast
Рет қаралды 162 МЛН