palheart@mailinator.com palheart@mailinator.com / Mbed 2 deprecated ActiveGamesWeek1

Dependencies:   MMA8451QASD USBDeviceASD mbed

Fork of FTF2014_lab3_part2 by Freescale

Committer:
palheart
Date:
Thu Aug 07 08:37:32 2014 +0000
Revision:
4:7ec5c7e1e80f
Parent:
0:61fed686b4a2
Child:
5:303bc488a04a
Renamed the whole thing in order to prevent messing up with the real library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
palheart 4:7ec5c7e1e80f 1 #include "MMA8451Q.h"
Kojto 0:61fed686b4a2 2 #include "mbed.h"
Kojto 0:61fed686b4a2 3 #include "USBMouseKeyboard.h"
Kojto 0:61fed686b4a2 4
palheart 4:7ec5c7e1e80f 5 #define MMA8451_I2C_ADDRESS (0x1d<<1)
palheart 4:7ec5c7e1e80f 6
palheart 4:7ec5c7e1e80f 7 MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS);
palheart 4:7ec5c7e1e80f 8 USBMouse joystick;
palheart 4:7ec5c7e1e80f 9 AnalogIn ainX(PTB0);
palheart 4:7ec5c7e1e80f 10 AnalogIn ainY(PTB1);
Kojto 0:61fed686b4a2 11
Kojto 0:61fed686b4a2 12 int main(void) {
palheart 4:7ec5c7e1e80f 13 int x, y;
palheart 4:7ec5c7e1e80f 14
Kojto 0:61fed686b4a2 15 while (true) {
palheart 4:7ec5c7e1e80f 16
palheart 4:7ec5c7e1e80f 17 // IF you are using the built-in acceleration sensor of the FRDM-KL25Z, uncomment this part
palheart 4:7ec5c7e1e80f 18 /*
palheart 4:7ec5c7e1e80f 19 x = (acc.getAccXX() + 4096)/32;
palheart 4:7ec5c7e1e80f 20 y = (acc.getAccYY() + 4096)/32;
palheart 4:7ec5c7e1e80f 21 x = x + 128;
palheart 4:7ec5c7e1e80f 22 y = y + 128;
palheart 4:7ec5c7e1e80f 23 */
palheart 4:7ec5c7e1e80f 24
palheart 4:7ec5c7e1e80f 25 // IF you are using the analog input of the FRDM-KL25Z, uncomment this part
palheart 4:7ec5c7e1e80f 26 x = ainX.read() * 256;
palheart 4:7ec5c7e1e80f 27 y = ainY.read() * 256;
palheart 4:7ec5c7e1e80f 28 x = x + 128;
palheart 4:7ec5c7e1e80f 29 y = y + 128;
palheart 4:7ec5c7e1e80f 30
palheart 4:7ec5c7e1e80f 31 joystick.move(x, y);
palheart 4:7ec5c7e1e80f 32 wait(0.1);
Kojto 0:61fed686b4a2 33 }
Kojto 0:61fed686b4a2 34 }