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.
main.cpp
- Committer:
- zatharv
- Date:
- 2022-05-20
- Revision:
- 0:223f9749f19b
File content as of revision 0:223f9749f19b:
#include "mbed.h"
#include "MMA8451Q.h"
#include "USBMouse.h"
#include "TSISensor.h"
#define MMA8451_I2C_ADDRESS (0x1d<<1)
USBMouse mouse;
MMA8451Q acc(PTE25, PTE24,MMA8451_I2C_ADDRESS);
TSISensor tsi;
int main(void) {
while (1) {
if (tsi.readPercentage())
{
if (tsi.readDistance() >= 20)
{
mouse.press(MOUSE_LEFT);
}
else
{
mouse.press(MOUSE_RIGHT);
}
}
else
{
mouse.release(MOUSE_LEFT);
mouse.release(MOUSE_RIGHT);
}
mouse.move(acc.getAccY()*(-5), acc.getAccX()*(-5));
}
}