Mobile Security System - Revision 1.0

Dependencies:   FXOS8700Q N5110 SDFileSystem SRF02 mbed

Committer:
el14dg
Date:
Fri Mar 04 12:42:18 2016 +0000
Revision:
1:3ae4192d0c25
Parent:
0:12ae42019e9f
Child:
2:e504a3cfe113
Set-up Oxygen comments

Who changed what in which revision?

UserRevisionLine numberNew contents of line
el14dg 0:12ae42019e9f 1 /* ELEC2645 Project
el14dg 0:12ae42019e9f 2
el14dg 1:3ae4192d0c25 3 Week 19 - Take distance readings from the sensor and set-up Doxygen comments
el14dg 0:12ae42019e9f 4 Week 20 -
el14dg 0:12ae42019e9f 5 Week 21 -
el14dg 0:12ae42019e9f 6 Week Easter -
el14dg 0:12ae42019e9f 7 Week 22 -
el14dg 0:12ae42019e9f 8 Week 23 -
el14dg 0:12ae42019e9f 9 Week 24 -
el14dg 0:12ae42019e9f 10
el14dg 0:12ae42019e9f 11 */
el14dg 0:12ae42019e9f 12
el14dg 1:3ae4192d0c25 13 #include "main.h"
el14dg 0:12ae42019e9f 14
el14dg 0:12ae42019e9f 15 int main()
el14dg 0:12ae42019e9f 16 {
el14dg 0:12ae42019e9f 17 // initialise the board and serial port
el14dg 0:12ae42019e9f 18 init_K64F();
el14dg 0:12ae42019e9f 19 init_serial();
el14dg 0:12ae42019e9f 20
el14dg 0:12ae42019e9f 21 while (1) {
el14dg 0:12ae42019e9f 22
el14dg 0:12ae42019e9f 23 for (int i = 1; i < 11; i++) {
el14dg 0:12ae42019e9f 24 // read sensor and accelerometer
el14dg 0:12ae42019e9f 25 distance = srf02.getDistanceCm();
el14dg 0:12ae42019e9f 26 }
el14dg 0:12ae42019e9f 27
el14dg 0:12ae42019e9f 28 // print over serial port
el14dg 0:12ae42019e9f 29 pc.printf("Distance = %d cm\n",distance);
el14dg 0:12ae42019e9f 30
el14dg 0:12ae42019e9f 31 // short delay before next measurement
el14dg 0:12ae42019e9f 32 wait(0.5);
el14dg 1:3ae4192d0c25 33
el14dg 0:12ae42019e9f 34 }
el14dg 0:12ae42019e9f 35 }
el14dg 0:12ae42019e9f 36
el14dg 0:12ae42019e9f 37 void init_serial()
el14dg 0:12ae42019e9f 38 {
el14dg 0:12ae42019e9f 39 // set to highest baud - ensure terminal software matches
el14dg 0:12ae42019e9f 40 pc.baud(115200);
el14dg 0:12ae42019e9f 41 }
el14dg 0:12ae42019e9f 42
el14dg 0:12ae42019e9f 43 void init_K64F()
el14dg 0:12ae42019e9f 44 {
el14dg 0:12ae42019e9f 45 // on-board LEDs are active-low, so set pin high to turn them off.
el14dg 0:12ae42019e9f 46 r_led = 1;
el14dg 0:12ae42019e9f 47 g_led = 1;
el14dg 0:12ae42019e9f 48 b_led = 1;
el14dg 0:12ae42019e9f 49
el14dg 0:12ae42019e9f 50 // since the on-board switches have external pull-ups, we should disable the internal pull-down
el14dg 0:12ae42019e9f 51 // resistors that are enabled by default using InterruptIn
el14dg 0:12ae42019e9f 52 sw2.mode(PullNone);
el14dg 0:12ae42019e9f 53 sw3.mode(PullNone);
el14dg 0:12ae42019e9f 54
el14dg 0:12ae42019e9f 55 }