00001 /******************************************************************************* 00002 * 00003 * File Name: LineDemo.c 00004 * Project : Demo 00005 * 00006 * Description: This file contains LineDemo features 00007 * 00008 * Ver. Date Author Comments 00009 * ------- ---------- -------------- ------------------------------ 00010 * 1.00 14.08.2003 Jan Grewe build 00011 * 2.00 22.10.2003 Jan Grewe angepasst auf asuro.c Ver.2.10 00012 * 00013 * Copyright (c) 2003 DLR Robotics & Mechatronics 00014 *****************************************************************************/ 00015 /*************************************************************************** 00016 * * 00017 * This program is free software; you can redistribute it and/or modify * 00018 * it under the terms of the GNU General Public License as published by * 00019 * the Free Software Foundation; either version 2 of the License, or * 00020 * any later version. * 00021 ***************************************************************************/ 00022 #include "asuro.h" 00023 00024 #define SPEED 0x8F 00025 00026 int speedLeft,speedRight; 00027 unsigned int lineData[2]; 00028 int ADOffset; 00029 00030 void LineLeft (void) 00031 { 00032 speedLeft += 1; 00033 if (speedLeft > 0xFE) speedLeft = 0xFF; 00034 } 00035 00036 void LineRight (void) 00037 { 00038 speedRight += 1; 00039 if (speedRight > 0xFE) speedRight = 0xFF; 00040 } 00041 00042 void LineDemo(void) 00043 { 00044 int i; 00045 unsigned char j; 00046 00047 Init(); 00048 00049 SerPrint("LineDemo\r\n"); 00050 FrontLED(ON); 00051 for (j = 0; j < 0xFF; j++) LineData(lineData); 00052 LineData(lineData); 00053 ADOffset = lineData[0] - lineData[1]; 00054 speedLeft = speedRight = SPEED; 00055 for (;;) 00056 { 00057 LineData(lineData); 00058 i = (lineData[0] - lineData[1]) - ADOffset; 00059 if ( i > 4) 00060 { 00061 StatusLED(GREEN); 00062 LineLeft(); 00063 } 00064 else if ( i < -4) 00065 { 00066 StatusLED(RED); 00067 LineRight(); 00068 } 00069 else 00070 { 00071 StatusLED(OFF); 00072 speedLeft = speedRight = SPEED; 00073 } 00074 MotorSpeed(speedLeft,speedRight); 00075 if (PollSwitch()) 00076 return; 00077 } 00078 } 00079 00080 #ifdef STAND_ALONE 00081 int main(void) 00082 { 00083 Init(); 00084 while(1) 00085 { 00086 LineDemo(); 00087 } 00088 return 0; 00089 } 00090 #endif 00091