![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Get readings from memsic dual axis accelerometer
Revision 0:8a820339d650, committed 2015-04-29
- Comitter:
- vk5653
- Date:
- Wed Apr 29 14:51:09 2015 +0000
- Commit message:
- Initial memsic code
Changed in this revision
diff -r 000000000000 -r 8a820339d650 Pulse.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Pulse.lib Wed Apr 29 14:51:09 2015 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/NickRyder/code/Pulse/#fb79a4637a64
diff -r 000000000000 -r 8a820339d650 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Apr 29 14:51:09 2015 +0000 @@ -0,0 +1,36 @@ +#include "mbed.h" +#include "Pulse.h" + +DigitalIn y(p10); +Serial pc(USBTX, USBRX); +Serial device (p9,p10); +PulseInOut pingX = PulseInOut(p9); + +int main() { + device.baud(9600); + Timer tmr; + + while(1){ + double durationX = pingX.read_high_us(); + + double accX = ((durationX / 10) - 500) * 8; + pc.printf("%d",accX); + } + /*int pulseX = x; + int pulseY = y; + // variables to contain the resulting accelerations + int accX, accY; + + + // convert the pulse width into acceleration + // accelerationX and accelerationY are in milli-g's: + // earth's gravity is 1000 milli-g's, or 1g. + accX = ((pulseX / 10) - 500) * 8; + accY = ((pulseY / 10) - 500) * 8; + + // print the acceleration + pc.printf("%d",accX); + // print a tab character: + pc.printf("\t"); + pc.printf("%d",accY);*/ +} \ No newline at end of file
diff -r 000000000000 -r 8a820339d650 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Apr 29 14:51:09 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/433970e64889 \ No newline at end of file