UT CS Bootcamp code for creating a secret knock

Dependencies:   MMA8451Q mbed tsi_sensor

Fork of UTCSBootcamp by Clare Coleman

Committer:
parnell
Date:
Fri Aug 22 19:52:08 2014 +0000
Revision:
11:0ac08d8a296f
Parent:
10:351ba1920e42
Revised with touch sensor;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
parnell 9:0ba1973c3bd3 1 #include "mbed.h" // mbed
parnell 11:0ac08d8a296f 2 //#include <stdarg.h>
parnell 9:0ba1973c3bd3 3 #include <MMA8451Q.h> // accelerometer
parnell 9:0ba1973c3bd3 4 #include <stdlib.h> // abs
parnell 9:0ba1973c3bd3 5 #include <math.h> // sqrt
parnell 9:0ba1973c3bd3 6 #include "KnockAPI.h" // our api
parnell 9:0ba1973c3bd3 7
parnell 11:0ac08d8a296f 8 #define ELEC0 9
parnell 11:0ac08d8a296f 9 #define ELEC1 10
parnell 11:0ac08d8a296f 10 /** Get the TouchSensor object
parnell 11:0ac08d8a296f 11 Code for the touch sensor can be found in tsi_sensor.h
parnell 11:0ac08d8a296f 12 important functions
parnell 11:0ac08d8a296f 13 readPercentage(); //returns where the "touch" is,
parnell 11:0ac08d8a296f 14 the touch is a value between [0 ... 1]
parnell 11:0ac08d8a296f 15 0 represents no touch, greater than 0 to 1 from left to right
parnell 11:0ac08d8a296f 16 */
parnell 11:0ac08d8a296f 17 TSIAnalogSlider ts(ELEC0, ELEC1, 40);
parnell 11:0ac08d8a296f 18
parnell 11:0ac08d8a296f 19 int main(void) {
parnell 11:0ac08d8a296f 20 init(); /// call the base inits
parnell 10:351ba1920e42 21 /* uncomment to see print traces from all API functions
parnell 10:351ba1920e42 22 (you will need to use your serial port for this) */
parnell 10:351ba1920e42 23 // setDebug(true);
ccoleman 0:2010bcffbae0 24
parnell 9:0ba1973c3bd3 25 /**
parnell 9:0ba1973c3bd3 26 Code for the accelerometer can be found in MMA8451Q.h
parnell 9:0ba1973c3bd3 27 important functions
parnell 9:0ba1973c3bd3 28 accelerometer.getAccX();
parnell 9:0ba1973c3bd3 29 accelerometer.getAccY();
parnell 9:0ba1973c3bd3 30 accelerometer.getAccZ();
parnell 9:0ba1973c3bd3 31 */
parnell 9:0ba1973c3bd3 32 Accelerometer accelerometer = getAccelerometer();
parnell 10:351ba1920e42 33 /// Your code begins here
parnell 10:351ba1920e42 34 while(true) { /* <-- you can change this loop as well */
parnell 9:0ba1973c3bd3 35 /* your code here */
parnell 9:0ba1973c3bd3 36 }
parnell 9:0ba1973c3bd3 37
parnell 9:0ba1973c3bd3 38 finish(); /// call the base finish
parnell 11:0ac08d8a296f 39 }