EasyManuals Logo

sparkfun Pro Micro User Manual

sparkfun Pro Micro
27 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #22 background imageLoading...
Page #22 background image
if (vertValue!= 0)
Mouse.move(0,vertValue/sensitivity,0);//movemouseo
nyaxis
if (horzValue!= 0)
Mouse.move(horzValue/sensitivity,0,0);//movemouseo
nxaxis
if ((digitalRead(selPin)== 0)&& (!mouseClickFlag))//if
thejoystickbuttonispressed
{
mouseClickFlag=1;
Mouse.press(MOUSE_LEFT);//clicktheleftbuttondown
}
else if ((digitalRead(selPin))&&(mouseClickFlag))//ifthe
joystickbuttonisnotpressed
{
mouseCl
ickFlag=0;
Mouse.release(MOUSE_LEFT);//releasetheleftbutton
}
}
This sketch is set up so that an analog joystick connected to analog pins A0
and A1 can be used to move your mouse cursor.
The
loop() of this code continuously monitors the horizontal and vertical
analog values of the joystick and sends the
Mouse.move() command based
on what it reads. It’ll move the mouse in steps, depending on what the
sensitivity variable is set to. With sensitivity set to 2, the cursor will move in
either 1 or 2 pixel steps.
The select switch on the joystick is used to control the mouse left click.
Notice this code is using
Mouse.press() and Mouse.release() , rather
than just calling a single
Mouse.click() . This requires a bit more coding,
but it allows you to do things like drag-and-drop, double click, etc.
For more HID example code, check out the Arduino-supplied examples
under the ‘File’ > ‘Examples’ > ‘09.USB’ menu.
Troubleshooting and FAQ
On this page you’ll find troubleshooting tips and FAQs. Here’s a directory of
the subjects covered:
Troubleshooting
Serial Port Not Showing Up in “Tools > Board” menu
How to Reset to Bootloader
How to Revive a “Bricked” Pro Micro
Page 2
2
of 2
7

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the sparkfun Pro Micro and is the answer not in the manual?

sparkfun Pro Micro Specifications

General IconGeneral
MicrocontrollerATmega32U4
Operating Voltage5V
Input Voltage5-12V
Digital I/O Pins12
PWM Channels5
DC Current per I/O Pin20 mA
SRAM2.5 KB
EEPROM1 KB
Dimensions1.3 x 0.7 inches
Analog Input Channels4
Flash Memory32 KB (ATmega32U4)
Clock Speed16 MHz

Related product manuals