Raspberry Pi Pico - DIY USB Mouse Jiggler

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys it's don here from nova spare tech and welcome back to the channel and today we are going to be creating ourselves a mouse jiggler using the raspberry pi pico so let's get started [Music] so the purpose of this device is actually to prevent your computer from going to sleep and for those of you who are actually working from home where you actually got a computer from your job and you know you can't install special applications in there to automate that process for any means you actually can't install any software and they also know if your computer is going to sleep now funny thing is i've actually seen these products on amazon right over here for like twenty dollars just to do the same thing that you could do on a raspberry pi pico which is for 4.99 and that's what we're going to be coding today just a simple mouse movement so that your mouse can move left and right and prevent your computer from going to sleep now this is a brand new picot i just picked up from pymeroni along with the vga board that i'm going to be playing around with so we're going to start from scratch and if you haven't seen my previous videos on setting up this computer with tawny and a lot of other code with me projects that i have i'll be sure to leave a playlist right over here so you can check that out but first thing we need to do is load this up with circuit python you've seen this before the first thing you do when you plug it in is hold the boot select button and when you plug it in it will become a mass storage device this way you can load your new python coding in there now i'm going to pop over into my firefox and hop over to circuit python search for the pico board and i know this is a new version because the one that i was using on my previous video was 6.1 and this is 6.2 beta 2. so it is a newer version than what i was using which is always good probably had some bug fixes i really didn't look it up now you're going to get this uf2 file i'm just going to copy and paste it right into the raspberry pi board and let it reboot give it a couple of seconds there we have it it rebooted and now i should be able to reach it with my thon tawny okay there we have it so now i have tawny open and i could actually see what's in here i don't have any libraries i just have the base code and everything so we're going to load it up with our adafruit hid module and the easier way to do this now is actually just go over to tools manage packages and look for ada fruit hid and there you go adafruit circuit python hid i'm going to hit install and we're gonna install that okay um that is weird because it's giving me a hard time trying to download that so instead i'm gonna manually download it by downloading clicking on the home page over here which leads me to this code i'm just going to hit download zip save open up my folder and in here i could go into download i should have a zip file i'm going to extract here and now i got my another file over here and this is what i just need to copy so i'm going to copy this over to circuit python lib and paste it right into that folder so now once that's done transferring if i go into let me close this out lib i should have adafruit hid folder and there you go my little thing that i need to download is already there okay now we can get into the coding process so what i ended up doing hopefully it wasn't too confusing was manually installing the hid code right into the lib folder because when you plug in the circuit python you can actually mount as a device and in there is the same as what you would see over here so i just copied and pasted it over there so moving over to the code itself this is going to be similar to what we were doing on our other tutorials on the mouse clicker the mouse auto clicker so first we're going to do import time and then we're going to do import usb usb underscore hid then import oh you know what because we're only going to use mouse so from ada fruit underscore hid mouse import capital mouse so the first letter is capital and then we want to also hit the led on the board so we know when it's working and when it's not working so we're going to import board for the gpio pins and import digital io all right once you get all these imported and typed up next thing we need to do is actually code everything so mouse equals capital mouse usb hid devices now we set the variable of mouse to be a usb hid device and then now we could just use mouse to call up functions like mouse move and all that stuff next we need to set up the led so led equals digital io dot digital in out 4.gp25 capital gp25 now gp25 is the led pin on the raspberry pi pico board so we're going to be using this if you want to use your own leds you could just program it into a gpio pin and just allocate it there now we're going to do led dot direction equals digital io dot direction and hence the capitals that i'm doing here because that makes a difference dot output so we're telling the uh this gpio pin to be an output so to provide voltage or to send voltage you could say now we're going to set the properties of the leds so we're going to do led value equals false so don't turn on the led we're also going to set up a little thing called we're basically going to put the board to sleep for a couple of seconds because when i did the auto clicker example uh you guys were it was activating right away so you guys weren't able to actually click stop or anything as soon as you plugged in the mouse device so what i'm doing here is actually to prevent that set up a timer so i'm going to do time dot sleep and i'm going to set it for five seconds so basically we have five seconds to hit the stop button over here so the code will not execute and i think five seconds is more than enough time if i'm going to code something back in there or fix something now we can actually do the code itself which is while true you know the main loop and in here we're going to set the mouse to move left and right now knowing that we want to turn on the led first make it go one direction maybe sleep for a little bit then go back the other direction with that in mind we're gonna do led value equals true so we're turning on the led so we know it's activated mouse move and x equals 100 so x means to move left and right y is up and down so x move 100 and then once this is done we're going to do led value equals false to turn off the led and we're gonna do time sleep um half a second now we only made it go one direction we kind of want it to go back and forth so we're gonna actually do this copy this code paste it again but instead we're going to do negative 100 so it's going to move 100 one way then 100 back the other way sleep for five sec half a second you know stuff like that and then go back and forth back and forth and this is basically it the entire code now what i'm going to do is save and i'm going to save it to circuit python device go to code hit ok overwrite that because that's the main code when you plug it in that's the main program it's gonna run first and i'm gonna hit stop and hit play so i'm gonna give it five seconds and my mouse okay you go you see it's jiggling right now moving left moving right moving left moving right moving left moving right so that's basically it wherever i move you see the mouse just bouncing left and right it's jiggling the mouse and that is enough to prevent the computer from going to sleep now if you wanted to modify it a little so it don't look as obvious what you can do is hang on let me time it so i can hit the stop there you go you see that how i timed it to get it to the stop button what you can do is actually just make it a smaller movement oh man it did it again because i stopped it now if you're running into problems where you're not able to connect again like if you hit stop and it's still having issues all you have to do is actually hit ctrl c and control c will actually kill whatever code is happening so you can actually go back into the fixed stuff now i never really had this problem except for this one time so uh yeah that's good to mention that control c will actually stop the or interrupt the current code now since i'm going back in here and i'm modifying this i could actually set this to be a little bit less obvious which is setting it to 10 by 10. so i'm gonna save the code again and stop and run it's gonna give me five seconds before it actually runs the code and you're gonna see how my little mouse is just moving left and right so it looks like it's just shaking so it's not as obvious and you could actually code a button into it if you follow my previous tutorial for the macro keyboard stuff where you can actually enable or disable using a button itself anyway that's it for me guys i'm gonna actually upload this code onto my github so you guys could just copy and paste it if you wanted to if you guys have any questions about this hit it down in the comments below or if you guys want to see any other projects that you guys have off the top of your head let me know down in the comments below if you guys are new to this channel consider subscribing also hitting that bell notification icon so you know when the next video is going to be out and as i say my nerd cave hack till it hearts
Info
Channel: Novaspirit Tech
Views: 33,462
Rating: undefined out of 5
Keywords: novaspirit, tech, mouse jiggler without software, mouse jiggler, diy mouse jiggler, prevent computer from sleeping, windows 10, mac, linux, simulate mouse movements, simulate mouse, mouse, jiggler, diy mouse, diy, micropython, raspberry pi pico, pico, circuit python, usb_hid, python, pico python, adafruit
Id: MjCFJCfq8ko
Channel Id: undefined
Length: 9min 50sec (590 seconds)
Published: Fri Mar 05 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.