Mouse code for the MacroRat
main.cpp@6:3d68fedd6fd9, 2017-05-04 (annotated)
- Committer:
- kyleliangus
- Date:
- Thu May 04 21:38:20 2017 +0000
- Revision:
- 6:3d68fedd6fd9
- Parent:
- 4:b5b7836ca2b0
- Child:
- 7:6f5cb6377bd4
Fixed stuff
Who changed what in which revision?
User | Revision | Line number | New 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 | 0:a03c771ab78e | 9 | |
kyleliangus | 4:b5b7836ca2b0 | 10 | // PID |
kyleliangus | 4:b5b7836ca2b0 | 11 | #define P_CONSTANT 0.0025 |
kyleliangus | 4:b5b7836ca2b0 | 12 | #define I_CONSTANT 0.0000025 |
kyleliangus | 4:b5b7836ca2b0 | 13 | #define D_CONSTANT 0.25 |
sahilmgandhi | 0:a03c771ab78e | 14 | |
christine222 | 3:880f15be8c72 | 15 | |
sahilmgandhi | 0:a03c771ab78e | 16 | int main() |
sahilmgandhi | 0:a03c771ab78e | 17 | { |
christine222 | 3:880f15be8c72 | 18 | //Set highest bandwidth. |
sahilmgandhi | 1:8a4b2f573923 | 19 | gyro.setLpBandwidth(LPFBW_42HZ); |
christine222 | 3:880f15be8c72 | 20 | serial.baud(9600); |
christine222 | 3:880f15be8c72 | 21 | |
sahilmgandhi | 1:8a4b2f573923 | 22 | wait (0.1); |
christine222 | 3:880f15be8c72 | 23 | |
christine222 | 3:880f15be8c72 | 24 | // IR_1.write(1); |
sahilmgandhi | 2:771db996cee0 | 25 | // IR_2.write(1); |
sahilmgandhi | 2:771db996cee0 | 26 | // IR_3.write(1); |
sahilmgandhi | 2:771db996cee0 | 27 | // IR_4.write(1); |
christine222 | 3:880f15be8c72 | 28 | |
sahilmgandhi | 2:771db996cee0 | 29 | redLed.write(1); |
sahilmgandhi | 2:771db996cee0 | 30 | greenLed.write(0); |
sahilmgandhi | 2:771db996cee0 | 31 | blueLed.write(1); |
sahilmgandhi | 1:8a4b2f573923 | 32 | |
christine222 | 3:880f15be8c72 | 33 | while (1) { |
christine222 | 3:880f15be8c72 | 34 | |
christine222 | 3:880f15be8c72 | 35 | wait(0.1); |
christine222 | 3:880f15be8c72 | 36 | serial.printf("%i, %i, %i\n", gyro.getGyroX(), gyro.getGyroY(), gyro.getGyroZ()); |
christine222 | 3:880f15be8c72 | 37 | |
christine222 | 3:880f15be8c72 | 38 | //reading = Rec_4.read(); |
christine222 | 3:880f15be8c72 | 39 | // serial.printf("reading: %f\n", reading); |
sahilmgandhi | 1:8a4b2f573923 | 40 | // redLed.write(0); |
sahilmgandhi | 1:8a4b2f573923 | 41 | // wait_ms(1000); |
sahilmgandhi | 1:8a4b2f573923 | 42 | // redLed.write(1); |
sahilmgandhi | 1:8a4b2f573923 | 43 | // greenLed.write(0); |
sahilmgandhi | 1:8a4b2f573923 | 44 | // wait_ms(1000); |
sahilmgandhi | 1:8a4b2f573923 | 45 | // greenLed.write(1); |
sahilmgandhi | 1:8a4b2f573923 | 46 | // blueLed.write(0); |
sahilmgandhi | 1:8a4b2f573923 | 47 | // wait_ms(1000); |
sahilmgandhi | 1:8a4b2f573923 | 48 | // blueLed.write(1); |
christine222 | 3:880f15be8c72 | 49 | } |
sahilmgandhi | 0:a03c771ab78e | 50 | } |