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; /* links mehr Gas geben */ 00033 if (speedLeft > 0xFE) speedLeft = 0xFF; 00034 } 00035 00036 void LineRight (void) 00037 { 00038 speedRight += 1; /* rechts mehr Gas geben */ 00039 if (speedRight > 0xFE) speedRight = 0xFF; 00040 } 00041 00042 int main(void) 00043 { 00044 int i; 00045 unsigned char j; 00046 00047 Init(); 00048 00049 FrontLED(ON); 00050 for (j = 0; j < 0xFF; j++) LineData(lineData); 00051 LineData(lineData); 00052 ADOffset = lineData[LEFT] - lineData[RIGHT]; 00053 speedLeft = speedRight = SPEED; 00054 for (;;) 00055 { 00056 LineData(lineData); 00057 i = (lineData[LEFT] - lineData[RIGHT]) - ADOffset; 00058 if ( i > 4) 00059 { 00060 StatusLED(GREEN); 00061 LineLeft(); 00062 } 00063 else if ( i < -4) 00064 { 00065 StatusLED(RED); 00066 LineRight(); 00067 } 00068 else 00069 { 00070 StatusLED(OFF); 00071 speedLeft = speedRight = SPEED; 00072 } 00073 MotorSpeed(speedLeft,speedRight); 00074 } 00075 return 0; 00076 } 00077