Buggy bois / Mbed 2 deprecated HEATS_1

Dependencies:   mbed

Committer:
mazdo25
Date:
Mon Mar 25 22:42:31 2019 +0000
Revision:
5:f1613df66ceb
Parent:
4:208f5279143a
Child:
6:477382219bcf
LATEST WORKING VERSION;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mazdo25 1:813f4b17ae65 1 #define PI 3.141
mazdo25 1:813f4b17ae65 2
mazdo25 1:813f4b17ae65 3 #include "math.h"
mazdo25 0:f45212966fb1 4 #include "mbed.h"
mazdo25 0:f45212966fb1 5 #include "Encoder.h"
mazdo25 3:01b5e80d842d 6 #include "lineSensor.h"
mazdo25 5:f1613df66ceb 7 #include "PID2.h"
mazdo25 4:208f5279143a 8 #include "PID.h"
mazdo25 5:f1613df66ceb 9 #include "Wheel.h"
mazdo25 1:813f4b17ae65 10 #include "Robot.h"
mazdo25 1:813f4b17ae65 11
mazdo25 0:f45212966fb1 12
mazdo25 0:f45212966fb1 13 //blue D8
mazdo25 0:f45212966fb1 14 //Green D9
mazdo25 0:f45212966fb1 15 //Red D5
mazdo25 3:01b5e80d842d 16 int main() {
mazdo25 3:01b5e80d842d 17 Serial pc(USBTX, USBRX);
mazdo25 1:813f4b17ae65 18
mazdo25 3:01b5e80d842d 19 DigitalOut enable(PA_13);
mazdo25 3:01b5e80d842d 20 enable.write(1);
mazdo25 3:01b5e80d842d 21
mazdo25 1:813f4b17ae65 22 Encoder* RE = new Encoder(PB_3,PB_5);
mazdo25 3:01b5e80d842d 23 Encoder* LE = new Encoder(PB_10,PB_4);
mazdo25 5:f1613df66ceb 24 Wheel* leftWheel = new Wheel(LE,PC_8,PA_9, PA_14);
mazdo25 5:f1613df66ceb 25 Wheel* rightWheel = new Wheel(RE,PC_6,PA_8, PA_7);
mazdo25 0:f45212966fb1 26
mazdo25 4:208f5279143a 27 //an array of lineSensor pointers params: lineSensor(PinName emitter Pin, PinName reciever Pin, make sure it is from LEFT TO RIGHT
mazdo25 4:208f5279143a 28 lineSensor* sensorArray[6] = {new lineSensor(PB_9,A0),new lineSensor(PC_11,A1),new lineSensor(PD_2,A2),new lineSensor(PC_10,A3),new lineSensor(PB_8,A4),new lineSensor(PC_12,A5)};
mazdo25 4:208f5279143a 29
mazdo25 5:f1613df66ceb 30 leftWheel->init(1);
mazdo25 0:f45212966fb1 31
mazdo25 4:208f5279143a 32 while(leftWheel->returnAngularVelocity()!= 0)
mazdo25 4:208f5279143a 33 {
mazdo25 4:208f5279143a 34 pc.printf("Stage 1, speed %f\r\n",leftWheel->returnAngularVelocity());
mazdo25 4:208f5279143a 35 }
mazdo25 4:208f5279143a 36
mazdo25 4:208f5279143a 37 rightWheel->init(1);
mazdo25 3:01b5e80d842d 38 while(rightWheel->returnAngularVelocity() != 0)
mazdo25 1:813f4b17ae65 39 {
mazdo25 3:01b5e80d842d 40 pc.printf("Stage 2, speed %f\r\n",rightWheel->returnAngularVelocity());
mazdo25 3:01b5e80d842d 41 }
mazdo25 5:f1613df66ceb 42 pc.printf("L , speedM%f\r\n",leftWheel->returnMaxAngularVel());
mazdo25 4:208f5279143a 43 pc.printf("R , speedM %f\r\n",rightWheel->returnMaxAngularVel());
mazdo25 5:f1613df66ceb 44
mazdo25 5:f1613df66ceb 45 Robot rbt(leftWheel, rightWheel, sensorArray);
mazdo25 3:01b5e80d842d 46 while(1)
mazdo25 3:01b5e80d842d 47 {
mazdo25 3:01b5e80d842d 48 }
mazdo25 4:208f5279143a 49
mazdo25 3:01b5e80d842d 50 }