Vasily Kushakov
/
memsic2125
Get readings from memsic dual axis accelerometer
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "mbed.h" 00002 #include "Pulse.h" 00003 00004 DigitalIn y(p10); 00005 Serial pc(USBTX, USBRX); 00006 Serial device (p9,p10); 00007 PulseInOut pingX = PulseInOut(p9); 00008 00009 int main() { 00010 device.baud(9600); 00011 Timer tmr; 00012 00013 while(1){ 00014 double durationX = pingX.read_high_us(); 00015 00016 double accX = ((durationX / 10) - 500) * 8; 00017 pc.printf("%d",accX); 00018 } 00019 /*int pulseX = x; 00020 int pulseY = y; 00021 // variables to contain the resulting accelerations 00022 int accX, accY; 00023 00024 00025 // convert the pulse width into acceleration 00026 // accelerationX and accelerationY are in milli-g's: 00027 // earth's gravity is 1000 milli-g's, or 1g. 00028 accX = ((pulseX / 10) - 500) * 8; 00029 accY = ((pulseY / 10) - 500) * 8; 00030 00031 // print the acceleration 00032 pc.printf("%d",accX); 00033 // print a tab character: 00034 pc.printf("\t"); 00035 pc.printf("%d",accY);*/ 00036 }
Generated on Tue Jul 26 2022 03:00:16 by 1.7.2