Crude navigation

Dependencies:   GPS L3GD20 LSM303DLHC mbed PID

Committer:
Spilly
Date:
Tue Mar 17 01:13:17 2015 +0000
Revision:
4:a397b44a0fe8
Parent:
0:e79311aae7ed
Accel and magn offsets

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Spilly 0:e79311aae7ed 1 //L298n connections
Spilly 0:e79311aae7ed 2 DigitalOut pinI1(D5);
Spilly 0:e79311aae7ed 3 DigitalOut pinI2(D6);
Spilly 0:e79311aae7ed 4 DigitalOut pinI3(D10);
Spilly 0:e79311aae7ed 5 DigitalOut pinI4(D11);
Spilly 0:e79311aae7ed 6 PwmOut ENA(D12); //Left
Spilly 0:e79311aae7ed 7 PwmOut ENB(D13); //Right
Spilly 0:e79311aae7ed 8
Spilly 0:e79311aae7ed 9 void goStop(float valueOne, float valueTwo)
Spilly 0:e79311aae7ed 10 {
Spilly 0:e79311aae7ed 11 pinI1 = 0;
Spilly 0:e79311aae7ed 12 pinI2 = 0;
Spilly 0:e79311aae7ed 13 pinI3 = 0;
Spilly 0:e79311aae7ed 14 pinI4 = 0;
Spilly 0:e79311aae7ed 15 ENA = valueOne;
Spilly 0:e79311aae7ed 16 ENB = valueTwo;
Spilly 0:e79311aae7ed 17 }
Spilly 0:e79311aae7ed 18
Spilly 0:e79311aae7ed 19 void goForward(float valueOne, float valueTwo)
Spilly 0:e79311aae7ed 20 {
Spilly 0:e79311aae7ed 21 pinI1 = 1;
Spilly 0:e79311aae7ed 22 pinI2 = 0;
Spilly 0:e79311aae7ed 23 pinI3 = 0;
Spilly 0:e79311aae7ed 24 pinI4 = 1;
Spilly 0:e79311aae7ed 25 ENA = valueOne;
Spilly 0:e79311aae7ed 26 ENB = valueTwo;
Spilly 0:e79311aae7ed 27 }
Spilly 0:e79311aae7ed 28
Spilly 0:e79311aae7ed 29 void goBackward(float valueOne, float valueTwo)
Spilly 0:e79311aae7ed 30 {
Spilly 0:e79311aae7ed 31 pinI1 = 0;
Spilly 0:e79311aae7ed 32 pinI2 = 1;
Spilly 0:e79311aae7ed 33 pinI3 = 1;
Spilly 0:e79311aae7ed 34 pinI4 = 0;
Spilly 0:e79311aae7ed 35 ENA = valueOne;
Spilly 0:e79311aae7ed 36 ENB = valueTwo;
Spilly 0:e79311aae7ed 37 }
Spilly 0:e79311aae7ed 38
Spilly 0:e79311aae7ed 39 void goLeft(float valueOne, float valueTwo)
Spilly 0:e79311aae7ed 40 {
Spilly 0:e79311aae7ed 41 pinI1 = 0;
Spilly 0:e79311aae7ed 42 pinI2 = 1;
Spilly 0:e79311aae7ed 43 pinI3 = 0;
Spilly 0:e79311aae7ed 44 pinI4 = 1;
Spilly 0:e79311aae7ed 45 ENA = valueOne;
Spilly 0:e79311aae7ed 46 ENB = valueTwo;
Spilly 0:e79311aae7ed 47 }
Spilly 0:e79311aae7ed 48
Spilly 0:e79311aae7ed 49 void goRight(float valueOne, float valueTwo)
Spilly 0:e79311aae7ed 50 {
Spilly 0:e79311aae7ed 51 pinI1 = 1;
Spilly 0:e79311aae7ed 52 pinI2 = 0;
Spilly 0:e79311aae7ed 53 pinI3 = 1;
Spilly 0:e79311aae7ed 54 pinI4 = 0;
Spilly 0:e79311aae7ed 55 ENA = valueOne;
Spilly 0:e79311aae7ed 56 ENB = valueTwo;
Spilly 0:e79311aae7ed 57 }