Society of Robots - Robot Forum

General Misc => Robot Videos => Topic started by: Afroman on August 02, 2008, 09:44:59 PM

Title: Robotic cat toy
Post by: Afroman on August 02, 2008, 09:44:59 PM
Just got done building this using SOR's Axon.

http://afrotechmods.com/cheap/cat_toy/cat_toy.htm (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
         }

      }
Title: Re: Robotic cat toy
Post by: Admin on August 03, 2008, 08: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 :)
Title: Re: Robotic cat toy
Post by: pomprocker on August 04, 2008, 10:20:29 AM
cat named pikachu, robots named pikachu  :D