sparkfun DEV-11520 Скачать руководство пользователя страница 22

if (vertValue

 

!= 0)

    

Mouse.move(0,

 

vertValue/sensitivity,

 

0);

  

//

 

move

 

mouse

 

o

n

 

y

 

axis

if (horzValue

 

!= 0)

    

Mouse.move(horzValue/sensitivity,

 

0,

 

0);

  

//

 

move

 

mouse

 

o

n

 

x

 

axis

if ((digitalRead(selPin)

 

== 0)

 

&& (!mouseClickFlag))

  

//

 

if

 

the

 

joystick

 

button

 

is

 

pressed

  

{

 

    

mouseClickFlag

 

= 1;

    

Mouse.press(MOUSE_LEFT);

  

//

 

click

 

the

 

left

 

button

 

down

  

}

 

else if ((digitalRead(selPin))&&(mouseClickFlag))

 

//

 

if

 

the

 

joystick

 

button

 

is

 

not

 

pressed

  

{

 

    

mouseClickFlag

 

= 0;

    

Mouse.release(MOUSE_LEFT);

  

//

 

release

 

the

 

left

 

button

  

}

 

}

 

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 22 of 27

Содержание DEV-11520

Страница 1: ...acting as an intermediary between your Arduino and your computer The SparkFun Pro Micro is a really cool little development board It s an Arduino compatible microcontroller micro sized and it accompl...

Страница 2: ...d Arduino addon on Mac Example 1 Blinkies A simple Hello world sketch specifically suited to the Pro Micro and Fio v3 Example 2 HID Mouse and Keyboard An introduction to the HID USB capability of the...

Страница 3: ...tage at this pin will be about 4 8V USB s 5V minus a schottkey diode drop On the other hand if the board is powered externally through this pin the applied voltage can be up to 12V VCC is the voltage...

Страница 4: ...nterrupts which allow you to instantly trigger a function when a pin goes either high or low or both If you attach an interrupt to an interrupt enabled pin you ll need to know the specific interrupt t...

Страница 5: ...e USB cable can be connected to either a computer USB hub or a USB wall adapter which can in most cases provide more power Alternatively if your Pro Micro is living out in the wild out of reach of USB...

Страница 6: ...Fio v3 is what makes it unique a footprint for an XBee on the bottom and a LiPo charging circuit on the top The Pinout All of the Fio v3 s pins are broken out to either side of the board Some pins are...

Страница 7: ...can be used to interface with digital devices like serial LCDs IMUs and other serial sensors The Fio v3 has five external interrupts which allow you to instantly trigger a function when a pin goes ei...

Страница 8: ...the LiPo Charger The Fio v3 has a LiPo charge management circuit based around the MCP73831 built onto it which handles the signal conditioning required to safely charge a single cell LiPo battery To u...

Страница 9: ...n install these drivers you ll need to disable driver signature enforcement Please check out our quick Disabling Driver Signature Enforcement tutorial for help with that Step 1 Download the Driver Bef...

Страница 10: ...all the driver is through the Device Manager To get to the Device Manager click the Start button then open the Control Panel In the Control Panel click System and Maintenance and then open the Device...

Страница 11: ...r folder click OK then select Next Windows will attempt to do its driver install thing but not before complaining about the driver being unsigned It s safe to select Install this driver software anywa...

Страница 12: ...y work with Arduino 1 5 and up If you re using an earlier version of Arduino either update and get some cool new features or download the older version of the Addon Where s your Arduino sketchbook Wel...

Страница 13: ...board you have Check the bottom of the board where you should find either a 5V or 3 3V box checked You should also see your Pro Micro s COM port under the Tools Serial Port menu Select it and head ov...

Страница 14: ...ures or download the older version of the Addon With that downloaded follow these steps to enable the Pro Micro in your Arduino environment 1 The addon files are supplied in a zip folder so you ll nee...

Страница 15: ...etch Example 1 Blinkies The Arduino standard Blink sketch won t have any visible effect on the Pro Micro there s no LED on pin 13 In fact the only LEDs on the board are the power indicator and RX TX b...

Страница 16: ...e defined macros TXLED1 TXLED0 to control that We could use the same macros for the RX LED too RXLED1 and RXLED0 void setup pinMode RXLED OUTPUT Set RX LED as an output TX LED is set as an output behi...

Страница 17: ...mably nothing is listening This begs the age old question if a Pro Micro is saying Hello over the hardware serial port and nothing is there to hear it does the Pro Micro really say anything at all Why...

Страница 18: ...a class which defines what its general purpose is There are loads of classes printers hubs speakers and webcams to mention a few but in this example we ll be emulating HID Human Interface Device The...

Страница 19: ...0 delay so there aren t a kajillion z s In this sketch connecting pin 9 to ground will make the Pro Micro spit out a z character If you have a simple momentary button handy tie one end to pin 9 and th...

Страница 20: ...gle byte each bit of which represents a different button You can set it equal to any of the following or OR them together to click multiple buttons at once MOUSE_LEFT Left Mouse button MOUSE_RIGHT Rig...

Страница 21: ...joystick int vertZero horzZero Stores the initial value of each a xis usually around 512 int vertValue horzValue Stores current analog output of each axis const int sensitivity 200 Higher sensitivity...

Страница 22: ...ck 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...

Страница 23: ...rduino back up check the Serial Ports menu again Reset to Bootloader We ship the Pro Micro with a modified version of the Arduino Leonardo bootloader with one major enhancement When a Leonardo or any...

Страница 24: ...rly unusable It s not uncommon for Pro Micro s to become bricked and unprogrammable But in most cases the bricking is reversible The most common source of Pro Micro bricking is uploading code to it wi...

Страница 25: ...to compile first it may help to hit upload first and then reset Frequently Asked Questions If you re having technical difficulties with your Pro Micro or Fio v3 see if any of the answers to these FAQs...

Страница 26: ...gs to work on this chip How Do I Reinstall the Bootloader Check out or reinstalling the bootloader tutorial which should work for both ATMega32U4 and ATMega328 boards If you have the tools to do so re...

Страница 27: ...Arduino Comparison Guide Connecting Arduino to Processing Using the Arduino Pro Mini 3 3V Page 27 of 27 2 12 2015 https learn sparkfun com tutorials pro micro fio v3 hookup guide...

Отзывы: