Society of Robots
     | Robot Forum | Robot Tutorials | Robot FAQ |
Welcome, Guest. Please login or register.
Did you miss your activation email?
November 20, 2009, 08:45:54 PM

Login with username, password and session length
Search:     Advanced search
Sept 30th - New Price - Axon is now $94

Robot Forum
72,665 Posts in 9,267 Topics by 5,290 Members
Latest Member: robertelson
* Home Help Help Login Register
0 Members and 1 Guest are viewing this topic.
Pages: [1] Print
Author Topic: Robotic cat toy  (Read 3315 times)
AfromanTopic starter
Expert Roboticist
Jr. Member
*****

Helpful? 0
Offline Offline

Posts: 29


View Profile WWW
« on: August 02, 2008, 08:44:59 PM »

Just got done building this using SOR's Axon.

http://afrotechmods.com/cheap/cat_toy/cat_toy.htm

There's some code in there that you might find useful, dealing with random number generation


   srandom(42);//sets the random seed to a random number I pulled out of my ass
   pulse_length=467;
         //a value of 467 cycles gives a 1ms pulse which puts the servo at -60 degrees
         //a value of 700 cycles gives a 1.5ms pulse which puts the servo at 0 degrees
         //a value of 933 cycles gives a 2ms pulse which puts the servo at +60 degrees

   while(1)
      {
         i = rand(); //rand() returns a random number between 0 and 32767
         i=i>>6; //divide the random number by 64 to get it between 0 and 512
         pulse_length=i+467; //add on the minimum pulse length to get a random pulse length between
                        //467 and 979 cycles which corresponds to roughly 1 to 2ms         
         
         delay_time = rand() >> 6; //makes the delay random number of servo cycles
                             //between 0 and 512
         
         for(i=0; i< delay_time;i++)
         {
            servo(PORTA,7,pulse_length); //outputs a servo pulse on PORT A, pin 7
            delay_ms(20); //servos usually expect a 20ms delay between each servo pulse
         }

      }
Logged
Admin
Administrator
Supreme Robot
*****

Helpful? 62
Offline Offline

Posts: 8,610



View Profile WWW
« Reply #1 on: August 03, 2008, 07:13:44 AM »

lol

Im imagining the laser high up in the air, and using 2 servos (for x and y motion).

I'm linking this over to the main Axon page Smiley
Logged

pomprocker
Supreme Robot
*****

Helpful? 15
Offline Offline

Posts: 1,411


Sorry miss, I was giving myself an oil-job.


View Profile WWW
« Reply #2 on: August 04, 2008, 09:20:29 AM »

cat named pikachu, robots named pikachu  Cheesy
Logged

Pages: [1] Print 
Jump to:  


Related Topics
Subject Started by Replies Views Last post
robotic arm
Mechanics and Construction
junior000 18 2289 Last post August 27, 2009, 04:23:14 PM
by wil.hamilton
Robotic Evolution
Misc
nanobit 3 694 Last post January 07, 2009, 03:01:06 PM
by nanobit
need a project on robotic arm
Misc
macksharma 3 464 Last post August 26, 2009, 01:37:25 PM
by Canabots
Programming a robotic hindbrain
Software
disconnector 1 184 Last post September 10, 2009, 09:10:55 PM
by Ro-Bot-X
Powered by MySQL Powered by PHP Powered by SMF 1.1.10 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!


Advertise on this Forum