Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

rover.C

Go to the documentation of this file.
00001 //
00002 // The contents of this file are subject to the Mozilla Public License
00003 // Version 1.0 (the "License"); you may not use this file except in
00004 // compliance with the License. You may obtain a copy of the License
00005 // at http://www.mozilla.org/MPL/
00006 // 
00007 // Software distributed under the License is distributed on an "AS IS"
00008 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
00009 // the License for the specific language governing rights and
00010 // limitations under the License.
00011 //
00012 // This software was developed as part of the legOS project.
00013 //
00014 // Contributor: Pat Welch (legOS@mousebrains.com)
00015 
00016 #include <c++/MotorPair.H>
00017 #include <c++/Sound.H>
00018 #include <conio.h>
00019 #include <unistd.h>
00020 #include <tm.h>
00021 
00022 //
00023 // This is a simple example of a two motor rover which moves forward for
00024 // 5 seconds, then goes in reverse for 5 seconds.  It does this cycle
00025 // 5 times.
00026 //
00027 
00028 #if defined(CONF_DMOTOR)
00029 
00030 int 
00031 main(int argc, 
00032      char **argv) 
00033 {
00034   MotorPair m(Motor::A, Motor::C);
00035 
00036   for (int i = 0; i < 10 && !shutdown_requested(); ++i) {
00037     if (i % 2) {
00038       m.forward();
00039 #ifdef CONF_DSOUND
00040       Sound::beep();
00041 #endif // CONF_DSOUND
00042       cputs ("FWD");
00043     } else {
00044       m.reverse();
00045       cputs ("REV");
00046     }
00047     m.speed(m.max);
00048     sleep(5);
00049   }
00050   m.off();
00051   cls();
00052   
00053   return 0;
00054 }
00055 #else
00056 #warning rover.C requires CONF_DMOTOR
00057 #warning rover demo will do nothing
00058 int main(int argc, char *argv[]) {
00059   return 0;
00060 }
00061 #endif // CONF_DMOTOR

Generated on Fri Feb 25 08:02:35 2005 for brickos by  doxygen 1.3.9.1