Author Topic: Robotic cat toy  (Read 12829 times)

0 Members and 1 Guest are viewing this topic.

Offline AfromanTopic starter

  • Expert Roboticist
  • Full Member
  • *****
  • Posts: 50
  • Helpful? 4
    • Oscilloscope tutorial video
Robotic cat toy
« 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

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
         }

      }

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Robotic cat toy
« Reply #1 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 :)

Offline pomprocker

  • Supreme Robot
  • *****
  • Posts: 1,431
  • Helpful? 16
  • Sorry miss, I was giving myself an oil-job.
    • Nerdcore - Programming, Electronics, Mechanics
Re: Robotic cat toy
« Reply #2 on: August 04, 2008, 10:20:29 AM »
cat named pikachu, robots named pikachu  :D

 


Get Your Ad Here

data_list