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: MMA7660 USBDevice mbed
main.cpp
- Committer:
- cohenr
- Date:
- 2016-03-24
- Revision:
- 0:af4531cbeb8b
File content as of revision 0:af4531cbeb8b:
// USB Device demo - control mouse pointer with buttons
#include "mbed.h"
#include "USBMouse.h"
#include "MMA7660.h"
MMA7660 MMA(p28, p27);
// USB Mouse object
USBMouse mouse;
DigitalOut myled(LED1);
int main() {
if (MMA.testConnection())myled = 1;
int x = 0;
int y = 0;
while (1) {
// Move mouse
if (MMA.x()>0.3) x = 1;
else if (MMA.x()<-0.3) x = -1;
else x = 0;
if (MMA.y()>0.3) y = 1;
else if (MMA.y()<-0.3) y = -1;
else y = 0;
mouse.move(x, y);
// Wait for next cycle
wait(0.001);
}
}