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

my pet robot
http://www.robotc.net/forums/viewtopic.php?f=15&t=2029
Page 1 of 1

Author:  jring [ Wed Dec 09, 2009 3:09 pm ]
Post subject:  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/

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