Pages: [1]   Go Down
Author Topic: Bringing dinosaurs back to life  (Read 861 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Now that I've got your attention smiley-wink

Ok so I'm gonna have a go at my 2nd arduino project, wish me luck smiley-razz

What I want to do is hack a keyboard and use mousekeys to gain control over my computers crusor. What I need to do is move the crusor down the vertical axis for a random (X) amount of time then right along the horizontal axis for a random (Y) amount of time and then click the button and move Y in the opposite direction (left) and X up. Then I need it to start again, with different random numbers

I know how to make the circuits and the basics of arduino control. I'm just not sure how to introduce multiple random numbers that will allow me to return to my original position.

That's probably not very clear so I drew an equally bad diagram smiley Basically the top one is a graphical demostration of what I tried to say. And the bottom one is of my computer screen smiley-grin The aim of the project is to start at A, move to a random location in the B box, click, move back to A, then move to a random location in C box and click. Finally returning back to A.

Thanks for ANY help smiley


* Photo on 2011-08-15 at 16.23.jpg (50.76 KB, 626x411 - viewed 29 times.)
« Last Edit: August 15, 2011, 02:15:46 pm by acm01 » Logged

0
Offline Offline
Sr. Member
****
Karma: 2
Posts: 360
I'm 15. I like making things. I like breaking things better.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Can there be a program running on the computer in the background? If so, an arduino really is not necessary. See the robots class in java. A simple program using this could move the cursor however you like, no hardware necessary.

What are you trying to accomplish?
Logged

Alice asked the Chesire Cat, who was sitting in a tree, "What road do I take?"
The cat asked, "Where do you want to go?"
"I don't know," Ali

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 212
Posts: 13531
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Ok so I'm gonna have a go at my 2nd arduino project, wish me luck
good luck!

Quote
I'm just not sure how to introduce multiple random numbers that will allow me to return to my original position.

Idea: You have to add up all your delta's and subtract them from the end position to get to the original point.

This will fail when you hit the border, e.g. x=1000;  x = x + random(e.g 59) = 1059 is rounded to 1024 =>  oops! 35 pixels off.


In fact only WIndows knows where the mouse pointer is, a mouse has no clue at all. Those special haptic mouses with feedback are controlled from within windows. So in short There is no silver bullet for this problem. Best solution imho is to set the mousecursor to somewhere in the middle, probably the user will be flabbergasted and will not recall the original position.


Legal note: in some countries these kinds of jokes/gadgets are not appreciated legally

Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Em well I don't think I can use another program, it's for an online game that I've been trying to beat smiley-razz And they are very good at catching 'bots', using the random factor allows me to trick the game into thinking it's a real person, as they detect bots by seeing patterns in the areas clicked on. Using the arduino has worked in the past so I figure try using it again! And also, if I know the speed the crusor moves then surely I can put constraints on the random number generator built into the arduino so I can select the rough area of the screen it ends up on. I've done it before, I had a button be clicked down for a random time between 1 second and 3.5 seconds. Well I'm going to do the same thing again, using mouse keys, only problem is, I don't know how to make the arduino remember the first random number so that I can get back to the start position.... is that clearer? :s I always have problems explaining myself on this :'(
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 212
Posts: 13531
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

As said you can use an internal variables that sums all the random delta X's and the delta Y's so you constantly know the offset you made. This info helps you to keep you on screen.

pesudoCode()
Code:
for (int i=0; i< 100; i++)
{
  dx = random();  dy = random();
  sumx += dx;  sumy + dy;
  moveMouse(dx,dy);
}
moveMouse(-sumX, -sumY);
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Oh sorry rob, get you now. Thanks for your help!
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 212
Posts: 13531
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Repeating is part of communication smiley
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

0
Offline Offline
Sr. Member
****
Karma: 2
Posts: 360
I'm 15. I like making things. I like breaking things better.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I think you are missing my point. You can accomplish this the exact same way from software alone. If you can use mousekeys, you can use a java or Processing program to simulate mouse moves. No arduino necessary. Same result accomplished, except easier cheaper and faster.
Logged

Alice asked the Chesire Cat, who was sitting in a tree, "What road do I take?"
The cat asked, "Where do you want to go?"
"I don't know," Ali

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 212
Posts: 13531
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yep, missed your point, sorry .
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

0
Offline Offline
Sr. Member
****
Karma: 2
Posts: 360
I'm 15. I like making things. I like breaking things better.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Haha sorry I was referring to the OP, because he seemed to think that a software and hardware solution would produce different results. Im all for arduino, but when something simpler would suffice, its only logical.
Logged

Alice asked the Chesire Cat, who was sitting in a tree, "What road do I take?"
The cat asked, "Where do you want to go?"
"I don't know," Ali

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok well the software option seems a good idea then! Is it capable of putting random movements within certain areas. Because if not I've thought of a simple solution using the arduino (which I already own) If I just make the mousekeys move the crusor to a corner of the screen each time (by pressing the movement button for a long period of time), then I've a garuntteed start point each time. But I'd like to look into the software idea. Thanks for all your help guys
Logged

0
Offline Offline
Sr. Member
****
Karma: 2
Posts: 360
I'm 15. I like making things. I like breaking things better.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Its capable of doing whatever you program it to do. Basically, there is a class in Java called the Robot class http://download.oracle.com/javase/1.3/docs/api/java/awt/Robot.html , which has a function called mouseMove() which sends the cursor to a specific pair of coordinates. This class can be used in standard Java, or Processing if it is easier for you.
Logged

Alice asked the Chesire Cat, who was sitting in a tree, "What road do I take?"
The cat asked, "Where do you want to go?"
"I don't know," Ali

Pages: [1]   Go Up
Jump to: