ROBOTC.net forums
http://robotc.net/forums/

My first project--a "puppy"
http://robotc.net/forums/viewtopic.php?f=15&t=2028
Page 1 of 1

Author:  cneely [ Wed Dec 09, 2009 2:42 pm ]
Post subject:  My first project--a "puppy"

For my first project, I decided to try to make a puppy. The puppy is supposed to drive around in circles until you touch the touchSensor, hence petting it, and will use the sonarSensor to turn around slowly until it stops at the hand that was petting it. I also used small sound bytes to replicate barking and whining.

Here is my code I created:

Code:
#pragma config(Sensor, S1,     touchSensor,         sensorTouch)
#pragma config(Sensor, S2,     sonarSensor,         sensorSONAR)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main()
{
while (true)

{

   while(SensorValue(touchSensor) == 0)//a while loop is declared with the touchsensor's value being 0 as it true condition
    {

      motor[motorA] = 75;
      motor[motorB] = -75;
      PlaySoundFile("dog_puppy.rso");
      wait1Msec(2000);
    }

   while(SensorValue(touchSensor) == 1)
   {
     if(SensorValue(sonarSensor) > 20)
     {
      motor[motorA] = 45;
      motor[motorB] = -45;
     } else {
            PlaySoundFile("dog_whine.rso");
            wait1Msec(100);
             motor[motorA] = 0;
             motor[motorB] = 0;
            }

      }

  }
}


Also, here is a video of my "puppy" working.

http://www.flickr.com/photos/29464331@N02/4153137815/in/set-72157608737193431/

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/