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-28
- Revision:
- 7:cb07cdb35b6c
- Parent:
- 6:477382219bcf
- Child:
- 8:5ed6685f6edd
File content as of revision 7:cb07cdb35b6c:
#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 hm10(PA_11, PA_12);
hm10.baud(9600);
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->init2();
rightWheel->init2();
Robot rbt(leftWheel, rightWheel, sensorArray);
rbt.rbtInit();
while(1)
{
if(hm10.readable())
{
rbt.setState(hm10.getc());
}
}
}
/*
*/