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 #21 background imageLoading...
Page #21 background image
/*HIDJoystickMouseExample
by:JimLindblom
date:1/12/2012
license:MITLicenseFeelfreetousethiscodeforanyp
urpose.
Norestrictions.Justkeepthislicenseifyougoontous
ethis
codeinyourfutureendeavors!Reuseandshare.
Thisisverysimplisticcodethatal
lowsyoutoturnthe
SparkFunThumbJoystick(http://www.sparkfun.com/products/9
032)
intoanHIDMouse.Theselectbutton onthejoystickisse
tup
asthemouseleftclick.
*/
int horzPin= A0;//Analogoutputofhorizontaljoystickpin
int vertPin= A1;//Analogoutputofverticaljoystickpin
int selPin=9;
//selectbuttonpinofjoystick
int vertZero,horzZero;//Storestheinitialvalueofeacha
xis,usuallyaround512
int vertValue,horzValue;//Storescurrentanalogoutputof
eachaxis
const int sensitivity= 200;//Highersensitivityvalue=sl
owermouse,shouldbe<=about500
int mouseClickFlag=0;
void setup()
{
pinMode(horzPin,INPUT);//Setbothanalogpin
sasinputs
pinMode(vertPin,INPUT);
pinMode(selPin,INPUT);//setbuttonselectpinasinput
digitalWrite(selPin,HIGH);//Pullbuttonselectpinhigh
delay(1000);//shortdelaytoletoutputssettle
vertZero= analogRead(vertPin);//gettheinitialvalues
horzZero= analogRead(horzPin);//Joystickshouldbeinne
utralpositionwhe nreadingthese
}
void loop()
{
vertV
alue= analogRead(vertPin) vertZero;//readvertica
loffset
horzValue= analogRead(horzPin) horzZero;//readhorizon
taloffset
Page 21 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