Owen Roseborough / Mbed 2 deprecated BeverageRoverV1

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 // main.cpp -----------------------------------------
00002 #include "mbed.h"
00003 #include "motorControl.h"
00004 
00005 DigitalIn Motor1A(p10);
00006 DigitalIn Motor1B(p25);
00007 
00008 DigitalIn Motor2A(p13);
00009 DigitalIn Motor2B(p23);
00010 
00011 DigitalIn Motor3A(p12);
00012 DigitalIn Motor3B(p24);
00013 
00014 DigitalIn Motor4A(p11);
00015 DigitalIn Motor4B(p26);
00016 
00017 DigitalOut led3(LED3);
00018 DigitalOut led4(LED4);
00019 
00020 #define MTR1A 0
00021 #define MTR1B 1
00022 #define MTR2A 2
00023 #define MTR2B 3
00024 #define MTR3A 4
00025 #define MTR3B 5
00026 #define MTR4A 6
00027 #define MTR4B 7
00028 
00029 int mtrCounts[4];
00030 
00031 int flagMotor1A = 0;
00032 int flagMotor2A = 0;
00033 int flagMotor3A = 0;
00034 int flagMotor4A = 0;
00035 
00036 int warmUpNeeded = 0;
00037 int repeatFlag = 1;
00038 
00039 Timer timer1;
00040 Timer timer2;
00041 
00042 int main() 
00043 {   /*
00044     stopMotors();
00045     wait(10);
00046     */
00047     while(1){
00048     stopMotors1();
00049     }/*
00050         if(warmUpNeeded < 4 && repeatFlag == 1){
00051             warmUpNeeded = warmUpNeeded + warmupStart();
00052             timer1.start();
00053             repeatFlag = 0;
00054         }
00055         if(0.95 < timer1.read() && timer1.read() < 1.05){
00056             stopMotors();
00057             wait(1);
00058             timer1.reset();
00059             timer1.start();
00060             recordMotorCounts(&mtrCounts[0]);
00061             repeatFlag = 1;
00062         }
00063         if(warmUpNeeded == 4 && repeatFlag == 1){
00064             exponentialAccAndDecCurves(); 
00065             warmUpNeeded = 10000;
00066         }
00067     
00068         if(Motor1A == 0 && flagMotor1A == 1){
00069             mtrCounts[0]++;
00070             flagMotor1A = 0;
00071         }
00072         if(Motor1A == 1 && flagMotor1A == 0){ 
00073             mtrCounts[0]++;
00074             flagMotor1A = 1;
00075         }
00076     
00077         if(Motor2A == 0 && flagMotor2A == 1){
00078             mtrCounts[1]++;
00079             flagMotor2A = 0;
00080         }
00081         if(Motor2A == 1 && flagMotor2A == 0){ 
00082             mtrCounts[1]++;
00083             flagMotor2A = 1;
00084         }
00085     
00086         if(Motor3A == 0 && flagMotor3A == 1){
00087             mtrCounts[2]++;
00088             flagMotor3A = 0;
00089         }
00090         if(Motor3A == 1 && flagMotor3A == 0){ 
00091             mtrCounts[2]++;
00092             flagMotor3A = 1;
00093         }
00094     
00095         if(Motor4A == 0 && flagMotor4A == 1){
00096             mtrCounts[3]++;
00097             flagMotor4A = 0;
00098         }
00099         if(Motor4A == 1 && flagMotor4A == 0){ 
00100             mtrCounts[3]++;
00101             flagMotor4A = 1;
00102         }
00103     } */
00104 }
00105         
00106 
00107 
00108 
00109 
00110 
00111 
00112 
00113