Mouse code for the MacroRat

Dependencies:   ITG3200 QEI

Committer:
sahilmgandhi
Date:
Fri May 05 00:08:59 2017 +0000
Revision:
7:6f5cb6377bd4
Parent:
6:3d68fedd6fd9
Child:
8:a0760acdc59e
Added some stuff for motor + encoders

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sahilmgandhi 0:a03c771ab78e 1 #include "mbed.h"
kyleliangus 4:b5b7836ca2b0 2
kyleliangus 6:3d68fedd6fd9 3 #include "irpair.h"
kyleliangus 4:b5b7836ca2b0 4 #include "main.h"
kyleliangus 4:b5b7836ca2b0 5 #include "motor.h"
kyleliangus 4:b5b7836ca2b0 6
sahilmgandhi 0:a03c771ab78e 7 #include <stdlib.h>
sahilmgandhi 1:8a4b2f573923 8 #include "ITG3200.h"
sahilmgandhi 7:6f5cb6377bd4 9 #include "QEI.h"
sahilmgandhi 0:a03c771ab78e 10
kyleliangus 4:b5b7836ca2b0 11 // PID
kyleliangus 4:b5b7836ca2b0 12 #define P_CONSTANT 0.0025
kyleliangus 4:b5b7836ca2b0 13 #define I_CONSTANT 0.0000025
kyleliangus 4:b5b7836ca2b0 14 #define D_CONSTANT 0.25
sahilmgandhi 0:a03c771ab78e 15
christine222 3:880f15be8c72 16
sahilmgandhi 0:a03c771ab78e 17 int main()
sahilmgandhi 0:a03c771ab78e 18 {
sahilmgandhi 7:6f5cb6377bd4 19 enableMotors();
christine222 3:880f15be8c72 20 //Set highest bandwidth.
sahilmgandhi 1:8a4b2f573923 21 gyro.setLpBandwidth(LPFBW_42HZ);
christine222 3:880f15be8c72 22 serial.baud(9600);
sahilmgandhi 7:6f5cb6377bd4 23 serial.printf("The gyro's address is %s", gyro.getWhoAmI());
sahilmgandhi 7:6f5cb6377bd4 24
sahilmgandhi 1:8a4b2f573923 25 wait (0.1);
sahilmgandhi 7:6f5cb6377bd4 26
christine222 3:880f15be8c72 27 // IR_1.write(1);
sahilmgandhi 2:771db996cee0 28 // IR_2.write(1);
sahilmgandhi 2:771db996cee0 29 // IR_3.write(1);
sahilmgandhi 2:771db996cee0 30 // IR_4.write(1);
christine222 3:880f15be8c72 31
sahilmgandhi 2:771db996cee0 32 redLed.write(1);
sahilmgandhi 2:771db996cee0 33 greenLed.write(0);
sahilmgandhi 2:771db996cee0 34 blueLed.write(1);
sahilmgandhi 1:8a4b2f573923 35
sahilmgandhi 7:6f5cb6377bd4 36 rightWheelForward(0.1);
sahilmgandhi 7:6f5cb6377bd4 37 leftWheelForward(0.1);
sahilmgandhi 7:6f5cb6377bd4 38
christine222 3:880f15be8c72 39 while (1) {
sahilmgandhi 7:6f5cb6377bd4 40
sahilmgandhi 7:6f5cb6377bd4 41 wait(0.1);
christine222 3:880f15be8c72 42 serial.printf("%i, %i, %i\n", gyro.getGyroX(), gyro.getGyroY(), gyro.getGyroZ());
sahilmgandhi 7:6f5cb6377bd4 43
christine222 3:880f15be8c72 44 //reading = Rec_4.read();
christine222 3:880f15be8c72 45 // serial.printf("reading: %f\n", reading);
sahilmgandhi 1:8a4b2f573923 46 // redLed.write(0);
sahilmgandhi 1:8a4b2f573923 47 // wait_ms(1000);
sahilmgandhi 1:8a4b2f573923 48 // redLed.write(1);
sahilmgandhi 1:8a4b2f573923 49 // greenLed.write(0);
sahilmgandhi 1:8a4b2f573923 50 // wait_ms(1000);
sahilmgandhi 1:8a4b2f573923 51 // greenLed.write(1);
sahilmgandhi 1:8a4b2f573923 52 // blueLed.write(0);
sahilmgandhi 1:8a4b2f573923 53 // wait_ms(1000);
sahilmgandhi 1:8a4b2f573923 54 // blueLed.write(1);
christine222 3:880f15be8c72 55 }
sahilmgandhi 0:a03c771ab78e 56 }