Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
main.cpp
- Committer:
- mazdo25
- Date:
- 2019-03-25
- Revision:
- 5:f1613df66ceb
- Parent:
- 4:208f5279143a
- Child:
- 6:477382219bcf
File content as of revision 5:f1613df66ceb:
#define PI 3.141
#include "math.h"
#include "mbed.h"
#include "Encoder.h"
#include "lineSensor.h"
#include "PID2.h"
#include "PID.h"
#include "Wheel.h"
#include "Robot.h"
//blue D8
//Green D9
//Red D5
int main() {
Serial pc(USBTX, USBRX);
DigitalOut enable(PA_13);
enable.write(1);
Encoder* RE = new Encoder(PB_3,PB_5);
Encoder* LE = new Encoder(PB_10,PB_4);
Wheel* leftWheel = new Wheel(LE,PC_8,PA_9, PA_14);
Wheel* rightWheel = new Wheel(RE,PC_6,PA_8, PA_7);
//an array of lineSensor pointers params: lineSensor(PinName emitter Pin, PinName reciever Pin, make sure it is from LEFT TO RIGHT
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)};
leftWheel->init(1);
while(leftWheel->returnAngularVelocity()!= 0)
{
pc.printf("Stage 1, speed %f\r\n",leftWheel->returnAngularVelocity());
}
rightWheel->init(1);
while(rightWheel->returnAngularVelocity() != 0)
{
pc.printf("Stage 2, speed %f\r\n",rightWheel->returnAngularVelocity());
}
pc.printf("L , speedM%f\r\n",leftWheel->returnMaxAngularVel());
pc.printf("R , speedM %f\r\n",rightWheel->returnMaxAngularVel());
Robot rbt(leftWheel, rightWheel, sensorArray);
while(1)
{
}
}