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.
Diff: main.cpp
- Revision:
- 0:223f9749f19b
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Fri May 20 09:00:15 2022 +0000
@@ -0,0 +1,32 @@
+#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));
+ }
+}
\ No newline at end of file