Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: MMA8451QASD USBDeviceASD mbed
Fork of FTF2014_lab3_part2 by
main.cpp
- Committer:
- palheart
- Date:
- 2014-08-07
- Revision:
- 4:7ec5c7e1e80f
- Parent:
- 0:61fed686b4a2
- Child:
- 5:303bc488a04a
File content as of revision 4:7ec5c7e1e80f:
#include "MMA8451Q.h"
#include "mbed.h"
#include "USBMouseKeyboard.h"
#define MMA8451_I2C_ADDRESS (0x1d<<1)
MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS);
USBMouse joystick;
AnalogIn ainX(PTB0);
AnalogIn ainY(PTB1);
int main(void) {
int x, y;
while (true) {
// IF you are using the built-in acceleration sensor of the FRDM-KL25Z, uncomment this part
/*
x = (acc.getAccXX() + 4096)/32;
y = (acc.getAccYY() + 4096)/32;
x = x + 128;
y = y + 128;
*/
// IF you are using the analog input of the FRDM-KL25Z, uncomment this part
x = ainX.read() * 256;
y = ainY.read() * 256;
x = x + 128;
y = y + 128;
joystick.move(x, y);
wait(0.1);
}
}
