Leonardo Button Mouse Control Example

Leonardo ボタンマウスの制御例

When a button is pressed in this example, a mouse cursor movement is sent to the computer as if you had moved your mouse.


Four buttons are used to send mouse movements of up, down, left, and right, and a fifth button is used to send a left mouse-button click.


Start by building the circuit. You’ll need five pushbuttons, as shown in Figure 6-1.


As usual, open a new sketch in the Arduino IDE.

いつものように、Arduino IDEで新しいスケッチを開きます。

Name your sketch Button Mouse Control, and type the Example 6-2 code into Arduino.

スケッチの名前を「Button Mouse Control」にして、例6-2のコードをArduinoに入力します。

You can also download it from the example code link on the book’s catalog page, or open File→Examples→09.USB→Mouse→Button Mouse Control in the IDE.

また、書籍のカタログページにあるサンプルコードのリンクからダウンロードするか、IDEでFile→Examples→09.USB→Mouse→Button Mouse Controlを開くこともできます。

Upload the sketch, and then press the movement buttons (the ones attached to pins 2, 3, 4, or 5) one at a time.


You should see the cursor on your computer move around.


Move the cursor over a partially hidden window and press the button that corresponds to clicking the left mouse-button.


The hidden window should be brought to the front.


トップ   編集 凍結解除 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2021-11-30 (火) 10:12:24