-
Notifications
You must be signed in to change notification settings - Fork 162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Created KeyboardandMousecontrol.ino #32
Open
Arsh0508
wants to merge
5
commits into
arduino-libraries:master
Choose a base branch
from
Arsh0508:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2f4be95
Create KeyboardandMousecontrol.ino
Arsh0508 54abe4a
Updated examples/KeyboardandMouseControl/KeyboardandMousecontrol.ino
Arsh0508 f8a0a7f
Rename KeyboardandMousecontrol.ino to KeyboardandMouseControl.ino
Arsh0508 e5ff3c6
Update KeyboardandMouseControl.ino
Arsh0508 f1549dc
Add files via upload
Arsh0508 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
99 changes: 99 additions & 0 deletions
99
examples/KeyboardandMouseControl/KeyboardandMouseControl.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/* | ||
This example has been moved to File > Examples > USB > KeyboardAndMouseControl | ||
https://github.com/arduino/Arduino/tree/master/build/shared/examples/09.USB/KeyboardAndMouseControl | ||
*/ | ||
|
||
/* | ||
KeyboardAndMouseControl | ||
|
||
Controls the mouse from five pushbuttons on a native USB board (e.g., Leonardo, | ||
Micro, MKR, Nano 33 IoT, Zero, Due) | ||
|
||
Hardware: | ||
- five pushbuttons attached to D2, D3, D4, D5, D6 | ||
|
||
The mouse movement is always relative. This sketch reads four pushbuttons, and | ||
uses them to set the movement of the mouse. | ||
|
||
WARNING: When you use the Mouse.move() command, the Arduino takes over your | ||
mouse! Make sure you have control before you use the mouse commands. | ||
|
||
created 15 Mar 2012 | ||
modified 27 Mar 2012 | ||
by Tom Igoe | ||
|
||
This example code is in the public domain. | ||
|
||
http://www.arduino.cc/en/Tutorial/KeyboardAndMouseControl | ||
*/ | ||
|
||
#include "Keyboard.h" | ||
#include "Mouse.h" | ||
|
||
// set pin numbers for the five buttons: | ||
const int upButton = 2; | ||
const int downButton = 3; | ||
const int leftButton = 4; | ||
const int rightButton = 5; | ||
const int mouseButton = 6; | ||
|
||
void setup() { // initialize the buttons' inputs: | ||
pinMode(upButton, INPUT); | ||
pinMode(downButton, INPUT); | ||
pinMode(leftButton, INPUT); | ||
pinMode(rightButton, INPUT); | ||
pinMode(mouseButton, INPUT); | ||
|
||
Serial.begin(9600); | ||
// initialize mouse control: | ||
Mouse.begin(); | ||
Keyboard.begin(); | ||
} | ||
|
||
void loop() { | ||
// use serial input to control the mouse: | ||
if (Serial.available() > 0) { | ||
char inChar = Serial.read(); | ||
|
||
switch (inChar) { | ||
case 'u': | ||
// move mouse up | ||
Mouse.move(0, -40); | ||
break; | ||
case 'd': | ||
// move mouse down | ||
Mouse.move(0, 40); | ||
break; | ||
case 'l': | ||
// move mouse left | ||
Mouse.move(-40, 0); | ||
break; | ||
case 'r': | ||
// move mouse right | ||
Mouse.move(40, 0); | ||
break; | ||
case 'm': | ||
// perform mouse left click | ||
Mouse.click(MOUSE_LEFT); | ||
break; | ||
} | ||
} | ||
|
||
// use the pushbuttons to control the keyboard: | ||
if (digitalRead(upButton) == HIGH) { | ||
Keyboard.write('u'); | ||
} | ||
if (digitalRead(downButton) == HIGH) { | ||
Keyboard.write('d'); | ||
} | ||
if (digitalRead(leftButton) == HIGH) { | ||
Keyboard.write('l'); | ||
} | ||
if (digitalRead(rightButton) == HIGH) { | ||
Keyboard.write('r'); | ||
} | ||
if (digitalRead(mouseButton) == HIGH) { | ||
Keyboard.write('m'); | ||
} | ||
|
||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes no sense. The example has not been moved to File > Examples > USB > KeyboardAndMouseControl. The example has always been there. The whole point of your pull request is to move (or copy) that sketch FROM File > Examples > USB > KeyboardAndMouseControl TO File > Examples > Mouse > KeyboardAndMouseControl.
There is no benefit to providing a link to the copy of the sketch in the arduino/Arduino repository. If they saw that comment, the user is already looking at the sketch.