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

motor.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 <config.h>
00017 #if defined(CONF_DMOTOR)
00018 
00019 #include <c++/Motor.H>
00020 #include <c++/Sound.H>
00021 #include <conio.h>
00022 #include <unistd.h>
00023 
00024 // This is a simple example of using a single motor, which runs forward
00025 // at the fastest speed for 1 second, then goes in reverse at 1/2 speed
00026 // for 1 second, and then runs a minimum speed for 1 second.
00027 
00028 int 
00029 main(int argc, 
00030      char **argv) 
00031 {
00032   Motor m(Motor::A);
00033 
00034   m.forward();
00035   cputs ("Fast");
00036   m.speed(m.max);
00037   sleep(1);
00038   cputs ("Med");
00039   m.speed((m.max + m.min) / 2);
00040   m.reverse();
00041 #ifdef CONF_DSOUND
00042   Sound::beep();
00043 #endif // CONF_DSOUND
00044   sleep(1);
00045   cputs ("Slow");
00046   m.speed(m.min);
00047   sleep(1);
00048   cls();
00049   
00050   return 0;
00051 }
00052 
00053 #else // CONF_DMOTOR
00054 #warning motor.C requires CONF_DMOTOR
00055 #warning motor demo will do nothing
00056 int
00057 main(int argc,
00058      char **argv)
00059 {
00060   return 0;
00061 }
00062 #endif // CONF_DMOTOR

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