Reference.MouseMove History

Hide minor edits - Show changes to output

April 11, 2013, at 12:10 PM by Roberto Guido - corrected datatype of parameters for Mouse.move(). Thanks Uwe Federer for alert
Changed lines 16-19 from:
xVal: amount to move along the x-axis - ''int''\\
yVal: amount to move along the y-axis - ''int''\\
wheel: amount to move scroll wheel - ''int''\\
to:
xVal: amount to move along the x-axis - ''signed char''\\
yVal: amount to move along the y-axis - ''signed char''\\
wheel: amount to move scroll wheel - ''signed char''\\
April 27, 2012, at 10:20 PM by Scott Fitzgerald -
Added lines 98-104:
!!!!See also
*[[/Reference/MouseBegin | Mouse.begin]]()
*[[/Reference/MouseClick | Mouse.click]]()
*[[/Reference/MouseEnd | Mouse.end]]()
*[[/Reference/MousePress | Mouse.press]]()
*[[/Reference/MouseRelease | Mouse.release]]()
*[[/Reference/MouseIsPressed | Mouse.isPressed]]()
March 28, 2012, at 08:31 PM by Scott Fitzgerald -
Changed lines 7-8 from:
Moves the cursor on a connected computer. The motion onscreen is always relative to the cursor's current location.
to:
Moves the cursor on a connected computer. The motion onscreen is always relative to the cursor's current location. Before using Mouse.move() you must call [[/Reference/MouseBegin | Mouse.begin]]()
Changed lines 27-33 from:
// set pin numbers for switch, joystick axes, and LED:
const int switchPin = 6; // switch to turn on and off mouse control
const int xAxis = A1; // joystick X axis
const int yAxis = A2; // joystick Y axis
const int ledPin = 5; // Mouse control LED

// parameters for reading the joystick:
to:
const int xAxis = A1; //analog sensor for X axis
const int yAxis = A2; // analog sensor for Y axis
Changed lines 42-44 from:
boolean mouseIsActive = false; // whether or not to control the mouse
int lastSwitchState = LOW; // previous switch state
to:
Changed lines 44-45 from:
pinMode(switchPin, INPUT); // the switch pin
pinMode(ledPin, OUTPUT); // the LED pin
to:
Mouse.begin();
Changed lines 48-60 from:
// read the switch:
int switchState = digitalRead(switchPin);
// if it's changed and it's high, toggle the mouse state:
if (switchState != lastSwitchState) {
if (switchState == HIGH) {
mouseIsActive = !mouseIsActive;
// turn on LED to indicate mouse state:
digitalWrite(ledPin, mouseIsActive);
}
}
// save switch state for next comparison:
lastSwitchState = switchState;
to:
Changed lines 53-54 from:
// if the mouse control state is active, move the mouse:
if (mouseIsActive) {
to:
// move the mouse:
Changed lines 55-56 from:
}
delay(responseDelay);
to:
delay(responseDelay);
Deleted line 97:
March 28, 2012, at 01:06 AM by Scott Fitzgerald -
Changed lines 7-8 from:
Moves the cursor on a connected computer. The motion onscreen is always relative
to:
Moves the cursor on a connected computer. The motion onscreen is always relative to the cursor's current location.
December 07, 2011, at 01:28 AM by Scott Fitzgerald -
Deleted lines 119-123:
!!!!See also
\\


[[Reference.HomePage | Reference Home]]
November 30, 2011, at 05:39 AM by Scott Fitzgerald -
Changed lines 16-19 from:
xVal: amount to move along the x-axis - ''int''
yVal: amount to move along the y-axis - ''int''
wheel: amount to move scroll wheel - ''int''
to:
xVal: amount to move along the x-axis - ''int''\\
yVal: amount to move along the y-axis - ''int''\\
wheel: amount to move scroll wheel - ''int''\\
November 30, 2011, at 03:38 AM by Scott Fitzgerald -
Changed lines 1-2 from:
[[Reference/MouseKeyboard]]
to:
[[Reference/MouseKeyboard | Mouse]]
November 30, 2011, at 03:38 AM by Scott Fitzgerald -
Changed lines 12-13 from:
Mouse.move(xVal, yPos, time);
to:
Mouse.move(xVal, yPos, wheel);
Changed lines 18-19 from:
time: amount of time in milliseconds to move to new location - ''int''
to:
wheel: amount to move scroll wheel - ''int''
Added lines 27-48:
// set pin numbers for switch, joystick axes, and LED:
const int switchPin = 6; // switch to turn on and off mouse control
const int xAxis = A1; // joystick X axis
const int yAxis = A2; // joystick Y axis
const int ledPin = 5; // Mouse control LED

// parameters for reading the joystick:
int range = 12; // output range of X or Y movement
int responseDelay = 2; // response delay of the mouse, in ms
int threshold = range/4; // resting threshold
int center = range/2; // resting position value
int minima[] = {
1023, 1023}; // actual analogRead minima for {x, y}
int maxima[] = {
0,0}; // actual analogRead maxima for {x, y}
int axis[] = {
xAxis, yAxis}; // pin numbers for {x, y}
int mouseReading[2]; // final mouse readings for {x, y}

boolean mouseIsActive = false; // whether or not to control the mouse
int lastSwitchState = LOW; // previous switch state
Changed lines 50-51 from:
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
to:
pinMode(switchPin, INPUT); // the switch pin
pinMode(ledPin, OUTPUT); // the LED pin
Changed lines 54-73 from:
void loop() {}
(:sourceend:)

'''Arduino Mega example:'''

(:source lang=arduino tabwidth=4:)
// Arduino Mega using all four of its Serial ports
// (Serial, Serial1, Serial2, Serial3),
// with different baud rates:

void setup(){
Serial.begin(9600);
Serial1.begin(38400);
Serial2.begin(19200);
Serial3.begin(4800);

Serial.println("Hello Computer");
Serial1.println("Hello Serial 1");
Serial2.println("Hello Serial 2");
Serial3.println("Hello Serial 3");
to:
void loop() {
// read the switch:
int switchState = digitalRead(switchPin);
// if it's changed and it's high, toggle the mouse state:
if (switchState != lastSwitchState) {
if (switchState == HIGH) {
mouseIsActive = !mouseIsActive;
// turn on LED to indicate mouse state:
digitalWrite(ledPin, mouseIsActive);
}
}
// save switch state for next comparison:
lastSwitchState = switchState;

// read and scale the two axes:
int xReading = readAxis(0);
int yReading = readAxis(1);

// if the mouse control state is active, move the mouse:
if (mouseIsActive) {
Mouse.move(xReading, yReading, 0);
}
delay(responseDelay);
Changed lines 79-116 from:
void loop() {}
to:
/*
reads an axis (0 or 1 for x or y) and scales the
analog input range to a range from 0 to <range>
*/

int readAxis(int axisNumber) {
int distance = 0; // distance from center of the output range

// read the analog input:
int reading = analogRead(axis[axisNumber]);

// of the current reading exceeds the max or min for this axis,
// reset the max or min:
if (reading < minima[axisNumber]) {
minima[axisNumber] = reading;
}
if (reading > maxima[axisNumber]) {
maxima[axisNumber] = reading;
}

// map the reading from the analog input range to the output range:
reading = map(reading, minima[axisNumber], maxima[axisNumber], 0, range);

// if the output reading is outside from the
// rest position threshold, use it:
if (abs(reading - center) > threshold) {
distance = (reading - center);
}

// the Y axis needs to be inverted in order to
// map the movemment correctly:
if (axisNumber == 1) {
distance = -distance;
}

// return the distance for this axis:
return distance;
}
Changed lines 119-120 from:
''Thanks to Jeff Gray for the mega example''
to:
November 30, 2011, at 03:32 AM by Scott Fitzgerald -
Changed lines 59-62 from:
* [[Serial.end]]()


to:
\\

November 30, 2011, at 03:16 AM by Scott Fitzgerald -
Added lines 1-63:
[[Reference/MouseKeyboard]]

!!Mouse.move()

!!!!Description

Moves the cursor on a connected computer. The motion onscreen is always relative

WARNING: When you use the Mouse.move() command, the Arduino takes over your mouse! Make sure you have control before you use the command. A pushbutton to toggle the mouse control state is effective.

!!!!Syntax
Mouse.move(xVal, yPos, time);

!!!!Parameters

xVal: amount to move along the x-axis - ''int''
yVal: amount to move along the y-axis - ''int''
time: amount of time in milliseconds to move to new location - ''int''

!!!!Returns

nothing

!!!Example:

(:source lang=arduino tabwidth=4:)
void setup() {
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
}

void loop() {}
(:sourceend:)

'''Arduino Mega example:'''

(:source lang=arduino tabwidth=4:)
// Arduino Mega using all four of its Serial ports
// (Serial, Serial1, Serial2, Serial3),
// with different baud rates:

void setup(){
Serial.begin(9600);
Serial1.begin(38400);
Serial2.begin(19200);
Serial3.begin(4800);

Serial.println("Hello Computer");
Serial1.println("Hello Serial 1");
Serial2.println("Hello Serial 2");
Serial3.println("Hello Serial 3");
}

void loop() {}
(:sourceend:)

''Thanks to Jeff Gray for the mega example''

!!!!See also
* [[Serial.end]]()



[[Reference.HomePage | Reference Home]]

Share