Subject:
|
Simon Says Robot
|
Newsgroups:
|
lugnet.org.us.smart
|
Date:
|
Tue, 3 Sep 2002 02:44:13 GMT
|
Viewed:
|
1109 times
|
| |
| |
I appologize for not getting this out sooner. Here are the 'official' specs
for the Simon Says robot. I've written them as a NQC program so that anyone
can use it, even if they haven't done much programming. But feel free to
modify the way the program works, as long as the end result is pretty much
the same.
Originally there was some discussion about having a 'return to front' type
of command, but after discussion with Gus, we decided that this would be too
complicated to make sure it works right. So for this version, we'll leave
that out. If we can figure out a good way to do it 'properly', we'll add it
back in later as message 36. But probably not until next year.
Also, I've increased the time per command to 2 seconds, because someone
noted that some of the commands might not be able to be completed in 1 1/2
seconds. I hope that this will be enough time. Perhaps an alternate solution
would be to have varying times for various commands, but that adds
complexity that I'd prefer to avoid if possible. If we do go that route,
though, what commands should be allowed longer times? Turning multiples of
90 degrees? Moving multiples of an inch? If we make those variable, can we
cut down the time for the other commands to 1 second?
The program below should be put in program slot #2. This way all the robots
can be started simultaneously with a remote. Make sure you put the program
in the right place! Also, the 'commanding' program, if your robot gets
chosen to be Simon, should be place in program slot #1. Have some fun, be
creative with the kinds of commands you call out. Just make sure you give
enough time between calling them out.
I hope everyone has fun building this robot, and that you'll be able to not
only bring it to the SMART meeting on the 28th, but also the NWBrickCon at
the Seattle Center the first weekend of October! The more robots there are,
the better it will look!
--
David Schilling
/
// Participant program -- place in Program slot #2
//
#define __NOTETIME 10
#define __WAITTIME 12
//#define DEBUG // remove comment at beginning of this line
// if you want to use your remote to test the robot
int m;
void MoveForward( int distance )
{
//... insert code to move your robot forward the desired distance ...
// (note: you need to be able to move 6 inches in under 2 seconds)
}
void MoveBackward( int distance )
{
//... insert code to move your robot backward the desired distance ...
// (note: you need to be able to move 6 inches in under 2 seconds)
}
task main()
{
// Sensor and Motor initialization goes here
// -- do what ever is appropriate for your own robot
//SetSensor( SENSOR_1, SENSOR_LIGHT );
//SetPower( OUT_A, OUT_FULL );
SetSleepTime( 5 ); // power down after 5 minutes of dancing
while( true )
{
ClearMessage();
m = Message();
while( m == 0 )
m = Message();
#ifdef DEBUG
if( m == 1 ) // use the remote for testing, remap messages 1, 2, and 3
m = 12; // set this to whatever message you want to test
if( m == 2 )
m = 22; // set this to whatever message you want to test
if( m == 3 )
m = 30; // set this to whatever message you want to test
#endif
switch( m )
{
case 11: // Move forward 1 inch
MoveForward( 1 );
break;
case 12: // Move forward 2 inch
MoveForward( 2 );
break;
case 13: // Move forward 3 inch
MoveForward( 3 );
break;
case 14: // Move forward 4 inch
MoveForward( 4 );
break;
case 15: // Move forward 5 inch
MoveForward( 5 );
break;
case 16: // Move forward 6 inch
MoveForward( 6 );
break;
case 21: // Move backward 1 inch
MoveBackward( 1 );
break;
case 22: // Move backward 2 inch
MoveBackward( 2 );
break;
case 23: // Move backward 3 inch
MoveBackward( 3 );
break;
case 24: // Move backward 4 inch
MoveBackward( 4 );
break;
case 25: // Move backward 5 inch
MoveBackward( 5 );
break;
case 26: // Move backward 6 inch
MoveBackward( 6 );
break;
case 30: // Turn right (clockwise) 90 degrees
//... insert code here ...
break;
case 31: // Turn left (counterclockwise) 90 degrees
//... insert code to turn robot left 90 degrees here ...
break;
case 32: // Turn clockwise 180 degrees
//... insert code here ...
break;
case 33: // Turn counterclockwise 180 degrees
//... insert code here ...
break;
case 34: // Turn clockwise 360 degrees
//... insert code here ...
break;
case 35: // Turn counterclockwise 360 degrees
//... insert code here ...
break;
case 40: // Play a Double Beep
PlaySound( SOUND_DOUBLE_BEEP );
break;
case 41: // Play a Sound Up
PlaySound( SOUND_UP );
break;
case 42: // Play a Sound Down
PlaySound( SOUND_DOWN );
break;
case 44: // Do the hokey-pokey
//... insert code here ...
// Do something funny for one and a half seconds.
// Examples: if your robot has arms, wave them up and down
// or spin your head, flash some lights, ... whatever.
// If you don't have any special features, then
// perhaps just wiggle around a bit, or do something
// else that's creative
break;
// The rest of the commands are for playing notes. If you're program
// is too large to fit into memory, feel free to delete these commands,
// and just ignore them if you receive them.
case 50: // Play a low F
PlayTone(175,4*__NOTETIME); Wait(4*__WAITTIME);
break;
case 51: // Play a low F sharp
PlayTone(185,4*__NOTETIME); Wait(4*__WAITTIME);
break;
case 52: // Play a low G
PlayTone(196,4*__NOTETIME); Wait(4*__WAITTIME);
break;
case 53: // Play a low G sharp
PlayTone(208,4*__NOTETIME); Wait(4*__WAITTIME);
break;
case 54: // Play a low A
PlayTone(220,4*__NOTETIME); Wait(4*__WAITTIME);
break;
case 55: // Play a low A sharp
PlayTone(233,4*__NOTETIME); Wait(4*__WAITTIME);
break;
case 56: // Play a low B
PlayTone(247,4*__NOTETIME); Wait(4*__WAITTIME);
break;
case 57: // Play a C
PlayTone(262,4*__NOTETIME); Wait(4*__WAITTIME);
break;
case 58: // Play a C sharp
PlayTone(277,4*__NOTETIME); Wait(4*__WAITTIME);
break;
case 59: // Play a D
PlayTone(294,4*__NOTETIME); Wait(4*__WAITTIME);
break;
case 60: // Play a D sharp
PlayTone(311,4*__NOTETIME); Wait(4*__WAITTIME);
break;
case 61: // Play a E
PlayTone(330,4*__NOTETIME); Wait(4*__WAITTIME);
break;
case 62: // Play a F
PlayTone(349,4*__NOTETIME); Wait(4*__WAITTIME);
break;
case 63: // Play a F sharp
PlayTone(370,4*__NOTETIME); Wait(4*__WAITTIME);
break;
case 64: // Play a G
PlayTone(392,4*__NOTETIME); Wait(4*__WAITTIME);
break;
case 65: // Play a G sharp
PlayTone(415,4*__NOTETIME); Wait(4*__WAITTIME);
break;
case 66: // Play a A
PlayTone(440,4*__NOTETIME); Wait(4*__WAITTIME);
break;
case 67: // Play a A sharp
PlayTone(466,4*__NOTETIME); Wait(4*__WAITTIME);
break;
case 68: // Play a B
PlayTone(494,4*__NOTETIME); Wait(4*__WAITTIME);
break;
case 69: // Play a high C
PlayTone(523,4*__NOTETIME); Wait(4*__WAITTIME);
break;
case 70: // Play a high C sharp
PlayTone(554,4*__NOTETIME); Wait(4*__WAITTIME);
break;
case 71: // Play a high D
PlayTone(587,4*__NOTETIME); Wait(4*__WAITTIME);
break;
case 72: // Play a high D sharp
PlayTone(622,4*__NOTETIME); Wait(4*__WAITTIME);
break;
case 73: // Play a high E
PlayTone(659,4*__NOTETIME); Wait(4*__WAITTIME);
break;
case 74: // Play a rest
Wait(8*__WAITTIME);
break;
}
}
}
|
|
Message has 1 Reply: | | Re: Simon Says Robot
|
| One detail I forgot to mention about the Simon Says robots - the IR window of the RCX should be facing the "front" of the robot. Also, since the 'caller' robot will be placed on a slightly elevated platform, in order to receive calls when you happen (...) (22 years ago, 4-Sep-02, to lugnet.org.us.smart)
|
2 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|