View unanswered posts | View active topics It is currently Fri Nov 21, 2014 8:18 pm






Reply to topic  [ 1 post ] 
my pet robot 
Author Message
Rookie

Joined: Mon Nov 16, 2009 1:05 pm
Posts: 1
Post my pet robot
This robot is supposed to be a pet. It drives forward until it hears a loud noise and starts to turn around in circles. When it senses a person in front of it, it starts to drive forward again. The cycle continues.

Program:
#pragma config(Sensor, S1, sonarSensor, sensorSONAR)
#pragma config(Sensor, S3, soundSensor, sensorSoundDB)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

task turnaround();

task main()

{
while(true)
{
wait1Msec(500);
while(SensorValue(soundSensor) < 60) // while it's quiet, drive forward until a loud noise
{

motor[motorC] = 40;

motor[motorA] = 40;
wait1Msec(500);
PlaySound(soundShortBlip);

}
while(SensorValue(sonarSensor) > 20)// as long as nothing is close, turn around
{
StartTask(turnaround);
}
motor[motorC] = 40; // when it sees a person, go forward again with different sound
motor[motorA] = 40;
wait1Msec(100);
PlaySound(soundBlip);
}
}
task turnaround()
{
motor[motorC] = 50;
motor[motorA] = -50;
wait1Msec(1000);
}

Video:

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


Picture:

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


Wed Dec 09, 2009 3:09 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.