View unanswered posts | View active topics It is currently Tue Sep 30, 2014 11:54 am






Reply to topic  [ 1 post ] 
My first project--a "puppy" 
Author Message
Rookie

Joined: Wed Nov 11, 2009 2:36 pm
Posts: 1
Post 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/


Wed Dec 09, 2009 2:42 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 1 post ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.