lol
Fork of Application by
Diff: main.cpp
- Revision:
- 12:3a30cdffa27c
- Parent:
- 11:b3f2a8bdac4d
--- a/main.cpp Sat Dec 16 10:26:48 2017 +0000 +++ b/main.cpp Sun Jan 21 22:28:30 2018 +0000 @@ -1,28 +1,24 @@ #include "mbed.h" +#include "USBMouse.h" #include "USBSerial.h" +#include "MMA8451Q.h" DigitalOut myled(LED1); - +USBMouse mouse; +//USBSerial serial; +#define MMA8451_I2C_ADDRESS (0x1d<<1) + int main() { - //confSysClock(); //Configure system clock (72MHz HSE clock, 48MHz USB clock) - //SYSTEM CLOCK changed in stm32f4xx_hal.c - USBSerial usbSerial; - Serial serial(PTE20, PTE21); - - - while(1) { - if(serial.readable()) - { - //usbSerial.putc(serial.getc()); - } - myled = !myled; - if(usbSerial.readable()) //if there is any character to read from usbSerial - { - usbSerial.putc('c'); - usbSerial.putc('h'); - usbSerial.putc('u'); - usbSerial.putc('j'); - usbSerial.getc(); - } + //USBSerial usbSerial; +MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS); + float x, y, z; + + while (1) { + x = (acc.getAccX()*10); + y = (acc.getAccY()*10); + z = (acc.getAccZ()*10); + printf("X: %1.2f, Y: %1.2f, Z: %1.2f\n", x, y, z); + mouse.move(x, y); + wait(0.01); } } \ No newline at end of file