Control your mouse with Arduino! Automate simple tasks!

preview_player
Показать описание
🤩 FREE Arduino Crash Course 👇👇

Want to learn more? Check out our courses!

***Get the code, transcript, challenges, etc for this lesson on our website***

***Get your Free Trial of Altium PCB design Software***

We designed this circuit board for beginners!



FOLLOW US ELSEWHERE
---------------------------------------------------

______________________________

Do you ever find yourself doing repetitive tasks on your computer and you think to yourself, I know this could be automated.

Well, what's cool is a lot of stuff can be automated using an Arduino and the USB libraries that come pre-installed in the Arduino IDE. This lesson is part two in a series doing a deep dive into those USB libraries.

In the previous lesson, we talked about controlling your keyboard with Arduino. In this lesson, you're gonna learn how to use the Arduino to emulate your mouse.

We're gonna go through every single function in the mouse USB library. You're gonna learn the ins and outs of each function, which functions don't work. You'll learn to avoid the common mistakes when you're programming with the mouse library.

Then we'll demonstrate a really simple program to move the mouse around and do some keyboard controls that I've been using when I'm writing test code for Python. Stay tuned. Subscribe to our YouTube channel to get more videos like this.

All right, let's dive right in. First off, it's important to know that the USB mouse library that comes pre-installed on the Arduino IDE doesn't work with all types of Arduino boards. It only works with a specific subset of Arduino boards.

And those are the ones that are designed with the 32u4 or the SAMD micro based boards. So that's gonna be a Leonardo, Esplora, Zero, a Due, the Micro and the MKR Family boards. So if you're trying to use this on an Arduino or a Mega, it's not gonna work.

It's these other ones that can emulate a USB. That's where these USB libraries will function. Now we're talking about these USB libraries, and if you go to the Arduino reference, which is my favorite page on the Arduino website, and you go to Libraries, down at the bottom, you can see there are two USB libraries, the Keyboard library and the Mouse library.

Now the Keyboard library we talked about in the previous video. So if you're interested in controlling the keyboard with your Arduino, definitely check out the previous video. We walked through every single one of these functions.

And just like this library, the Mouse library, which we're gonna look at today, has a very similar setup. You're gonna be able to click with the mouse. You'll be able to move your mouse around, press the mouse, release the mouse, check if the mouse is released.

Some pretty straightforward functions, but we're gonna walk through each one of them so you'll know how to use all of these. So right here, these are all of the functions inside the Mouse library. Now, like I mentioned, the Mouse and Keyboard library, these are the USB libraries, they come pre-installed on the Arduino IDE.

CONTINUED…

***About Us:***
This Arduino lesson was created by Programming Electronics Academy. We are an online education company who seeks to help people learn about electronics and programming through the ubiquitous Arduino development board.

***We have no affiliation whatsoever with Arduino LLC, other than we think they are cool.***
Рекомендации по теме
Комментарии
Автор

This video helped me a lot with my Davinci Resolve controller project. Some of the functions are not available from their keyboard shortcut list so I had to program a series of mouse movements and left clicks to get to a specific menu. Awesome tutoria! Thank you!

dezmach
Автор

thanks so much i didnt feel like reading and going through the arduino code so i decided to find a video and you taught me everything i needed to know to code my controller lol

devmarboy
Автор

Thanks very much for sharing your knowledge around this. If it helps anybody, as stated in the video, there's a limit to how much you can move the mouse in one movement (the range of -127 to 128). If you want to move it more, simply call the function more than once. Maybe there's a better way to do this?

davidbristoll
Автор

Great video!
The mouse moves in a relative way. Would be good to have an "absolute move" function to have mouse click in the same spot repetitively like an icon in the task bar.. I guess a workaround would be to move an incredibly ridiculous amount first to guarantee the mouse is in 0, 0. Then move relatively.

TheMarbo
Автор

One more suggestion ( that I should have mentioned in the last comment) if you put a delay of say 15 seconds somewhere in your setup Loop this will give you a 15-second buffer between when you plug in your Arduino and your sketch starts running giving you the 15 seconds to uploaded a corrected sketch once you've perfected your sketch you simply comment out or remove the delay.

frazier
Автор

At 27:00 you make the "move window" rutine and just say cool it works. It did not do what we expected? Why did the window move twice as far as the mouse?

ProcrastinatingGameCat
Автор

Skip Ad button automatically clicked 😁

firstnamesecondname
Автор

Is there a possible way to do this using an Arduino UNO R3?

hadhas
Автор

Hi Could you make a video on Auto Mouse Clicker/Jiggler for WFH environment to keep system awake🙏

gjsanu
Автор

hallo, maybe this is a funny question, but how can I do this with Arduino to right mouse button "release the button is pressing and holding, pressing is release the button" its like to reverse the function. :DD

bksauamatungkas
Автор

Hi there, awesome video. I have been looking for something like this for project, emulating a mouse over mqtt for my cctv. I have experience with esp8266. Can the mouse library be combined with the Esp8266 modules to make a mouse over mqtt?

sheminasalam
Автор

Does this lobrary allso work on esp8266

talicz
Автор

is there anyway i can make the mouse register only one click. and how to i make the right click aswell?

Fysh-gnlq
Автор

19:15 who else held there screen trying to guess where the mouse would move

Darkstar
Автор

but when i plugged it in hostshield the cursor not moving any help ????

enimv
Автор

my mouse does not move when i connect it to the usb host shiel but it stays on can anyone help me?

Maxkoy
Автор

What about being able to READ data from a mouse?

TheJimtanker
Автор

i want to connect pc keyboard with arduino and control mouse crouser
Please

ownyourself