lol

Dependencies:   MMA8451Q

Fork of Application by Mateusz Kowalik

Committer:
danix
Date:
Sun Jan 21 22:28:30 2018 +0000
Revision:
12:3a30cdffa27c
Parent:
11:b3f2a8bdac4d
Working acelerometer and mouse

Who changed what in which revision?

UserRevisionLine numberNew contents of line
samux 7:5e693654d5b4 1 #include "mbed.h"
danix 12:3a30cdffa27c 2 #include "USBMouse.h"
samux 7:5e693654d5b4 3 #include "USBSerial.h"
danix 12:3a30cdffa27c 4 #include "MMA8451Q.h"
Zaitsev 10:41552d038a69 5
Zaitsev 10:41552d038a69 6 DigitalOut myled(LED1);
danix 12:3a30cdffa27c 7 USBMouse mouse;
danix 12:3a30cdffa27c 8 //USBSerial serial;
danix 12:3a30cdffa27c 9 #define MMA8451_I2C_ADDRESS (0x1d<<1)
danix 12:3a30cdffa27c 10
Zaitsev 10:41552d038a69 11 int main() {
danix 12:3a30cdffa27c 12 //USBSerial usbSerial;
danix 12:3a30cdffa27c 13 MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS);
danix 12:3a30cdffa27c 14 float x, y, z;
danix 12:3a30cdffa27c 15
danix 12:3a30cdffa27c 16 while (1) {
danix 12:3a30cdffa27c 17 x = (acc.getAccX()*10);
danix 12:3a30cdffa27c 18 y = (acc.getAccY()*10);
danix 12:3a30cdffa27c 19 z = (acc.getAccZ()*10);
danix 12:3a30cdffa27c 20 printf("X: %1.2f, Y: %1.2f, Z: %1.2f\n", x, y, z);
danix 12:3a30cdffa27c 21 mouse.move(x, y);
danix 12:3a30cdffa27c 22 wait(0.01);
samux 7:5e693654d5b4 23 }
samux 7:5e693654d5b4 24 }