shashidhar dastari
/
Acc_Control_Car
Accelerometer Controlled Car
Revision 0:4f41abe16b42, committed 2018-04-27
- Comitter:
- kirathekiller
- Date:
- Fri Apr 27 06:33:51 2018 +0000
- Commit message:
- Accelerometer Controlled Car
Changed in this revision
diff -r 000000000000 -r 4f41abe16b42 FXOS8700Q.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/FXOS8700Q.lib Fri Apr 27 06:33:51 2018 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/teams/Freescale/code/FXOS8700Q/#aee7dea904e2
diff -r 000000000000 -r 4f41abe16b42 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Apr 27 06:33:51 2018 +0000 @@ -0,0 +1,148 @@ +/* FXOS8700Q Example Program + * Copyright (c) 2014-2015 ARM Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "mbed.h" +#include "FXOS8700Q.h" + +Serial pc(USBTX, USBRX); +I2C i2c(PTE25, PTE24); +FXOS8700QAccelerometer acc(i2c, FXOS8700CQ_SLAVE_ADDR1); // Configured for the FRDM-K64F with onboard sensors +DigitalOut blue(LED3); +DigitalOut red(LED1); +DigitalOut green(LED2); +DigitalOut m1f(PTC2); +DigitalOut m1r(PTC3); +DigitalOut m2f(PTC4); +DigitalOut m2r(PTC12); + +//DigitalOut en1(PTA2); +//DigitalOut en2(PTD0); + +int main(void) +{ + motion_data_units_t acc_data, mag_data; + motion_data_counts_t acc_raw, mag_raw; + float faX, faY, faZ, fmX, fmY, fmZ, tmp_float; + int16_t raX, raY, raZ, rmX, rmY, rmZ, tmp_int; + + acc.enable(); + printf("FXOS8700QAccelerometer Who Am I= %X\r\n", acc.whoAmI()); + while (true) { + acc.getAxis(acc_raw); + acc.getX(raX); + acc.getY(raY); + acc.getZ(raZ); + printf("ACC: X=%06d Y=%06d Z=%06d \t MAG: X=%06d Y=%06d Z=%06d\r\n", acc.getX(tmp_int), acc.getY(tmp_int), acc.getZ(tmp_int)); + + red =1; + green =1; + blue =1; + + if(raZ>3500) + { + red=0; + //en1=0; + //en2=0; + m1f = 0; + m2f = 0; + m1r = 0; + m2r = 0; + + } + else + { + red =1; + //en1=0; + //en2=0; + m1f = 0; + m2f = 0; + m1r = 0; + m2r = 0; + } + if(raY > 2500 || raY <-2500) + { + if(raY > 2500) + { + green = 0; + //en1=1; + //en2=1; + m1f = 1; + m2f = 1; + m1r = 0; + m2r = 0; + } + else if(raY < -2500) + { + green =0; + //en1=1; + //en2=1; + m1f = 0; + m2f = 0; + m1r = 1; + m2r = 1; + } + else + { + green =1; + //en1=0; + //en2=0; + m1f = 0; + m2f = 0; + m1r = 0; + m2r = 0; + } + } + if(raX > 2500 || raX <-2500) + { + if(raX > 2500) + { + blue = 0; + //en1=1; + //en2=0; + m1f = 1; + m2f = 0; + m1r = 0; + m2r = 0; + } + else if(raX < -2500) + { + + blue =0; + // en1=0; + // en2=1; + m1f = 0; + m2f = 1; + m1r = 0; + m2r = 0; + } + else + { + blue =1; + //en1=0; + //en2=0; + m1f = 0; + m2f = 0; + m1r = 0; + m2r = 0; + } + } + + acc.getAxis(acc_data); + puts(""); + wait(1.0f); + } + +} \ No newline at end of file
diff -r 000000000000 -r 4f41abe16b42 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Apr 27 06:33:51 2018 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/5aab5a7997ee \ No newline at end of file