Mouse code for the MacroRat
main.cpp@1:8a4b2f573923, 2017-04-26 (annotated)
- Committer:
- sahilmgandhi
- Date:
- Wed Apr 26 01:43:35 2017 +0000
- Revision:
- 1:8a4b2f573923
- Parent:
- 0:a03c771ab78e
- Child:
- 2:771db996cee0
Some working code;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sahilmgandhi | 0:a03c771ab78e | 1 | #include "mbed.h" |
sahilmgandhi | 0:a03c771ab78e | 2 | #include <stdlib.h> |
sahilmgandhi | 1:8a4b2f573923 | 3 | #include "ITG3200.h" |
sahilmgandhi | 0:a03c771ab78e | 4 | |
sahilmgandhi | 0:a03c771ab78e | 5 | DigitalOut redLed(PC_0); |
sahilmgandhi | 0:a03c771ab78e | 6 | DigitalOut blueLed(PC_1); |
sahilmgandhi | 0:a03c771ab78e | 7 | DigitalOut greenLed(PC_2); |
sahilmgandhi | 0:a03c771ab78e | 8 | |
sahilmgandhi | 1:8a4b2f573923 | 9 | DigitalOut IR_1(PB_13); |
sahilmgandhi | 0:a03c771ab78e | 10 | DigitalOut IR_2(PB_1); |
sahilmgandhi | 1:8a4b2f573923 | 11 | DigitalOut IR_3(PB_0); |
sahilmgandhi | 0:a03c771ab78e | 12 | DigitalOut IR_4(PB_14); |
sahilmgandhi | 0:a03c771ab78e | 13 | |
sahilmgandhi | 1:8a4b2f573923 | 14 | AnalogIn Rec_1(PC_5); |
sahilmgandhi | 1:8a4b2f573923 | 15 | AnalogIn Rec_2(PC_4); |
sahilmgandhi | 1:8a4b2f573923 | 16 | AnalogIn Rec_3(PA_6); |
sahilmgandhi | 1:8a4b2f573923 | 17 | AnalogIn Rec_4(PA_7); |
sahilmgandhi | 1:8a4b2f573923 | 18 | |
sahilmgandhi | 1:8a4b2f573923 | 19 | Serial serial(PC_6, PC_7); |
sahilmgandhi | 1:8a4b2f573923 | 20 | |
sahilmgandhi | 1:8a4b2f573923 | 21 | ITG3200 gyro(PC_9, PA_8); |
sahilmgandhi | 0:a03c771ab78e | 22 | |
sahilmgandhi | 0:a03c771ab78e | 23 | int main() |
sahilmgandhi | 0:a03c771ab78e | 24 | { |
sahilmgandhi | 1:8a4b2f573923 | 25 | gyro.setLpBandwidth(LPFBW_42HZ); |
sahilmgandhi | 1:8a4b2f573923 | 26 | |
sahilmgandhi | 1:8a4b2f573923 | 27 | wait (0.1); |
sahilmgandhi | 1:8a4b2f573923 | 28 | serial.printf("%i, %i, %i\n", gyro.getGyroX(), gyro.getGyroY(), gyro.getGyroZ()); |
sahilmgandhi | 1:8a4b2f573923 | 29 | |
sahilmgandhi | 1:8a4b2f573923 | 30 | IR_1.write(1); |
sahilmgandhi | 1:8a4b2f573923 | 31 | IR_2.write(1); |
sahilmgandhi | 1:8a4b2f573923 | 32 | IR_3.write(1); |
sahilmgandhi | 1:8a4b2f573923 | 33 | IR_4.write(1); |
sahilmgandhi | 1:8a4b2f573923 | 34 | |
sahilmgandhi | 1:8a4b2f573923 | 35 | //while (1) { |
sahilmgandhi | 1:8a4b2f573923 | 36 | // redLed.write(0); |
sahilmgandhi | 1:8a4b2f573923 | 37 | // wait_ms(1000); |
sahilmgandhi | 1:8a4b2f573923 | 38 | // redLed.write(1); |
sahilmgandhi | 1:8a4b2f573923 | 39 | // greenLed.write(0); |
sahilmgandhi | 1:8a4b2f573923 | 40 | // wait_ms(1000); |
sahilmgandhi | 1:8a4b2f573923 | 41 | // greenLed.write(1); |
sahilmgandhi | 1:8a4b2f573923 | 42 | // blueLed.write(0); |
sahilmgandhi | 1:8a4b2f573923 | 43 | // wait_ms(1000); |
sahilmgandhi | 1:8a4b2f573923 | 44 | // blueLed.write(1); |
sahilmgandhi | 1:8a4b2f573923 | 45 | // } |
sahilmgandhi | 0:a03c771ab78e | 46 | } |