Colin Johnson's Kent University Lecture 2 Demo 2

Dependencies:   MMA7660 USBDevice mbed

Fork of USBKeyboard_HelloWorld by Samuel Mokrani

Files at this revision

API Documentation at this revision

Comitter:
colingj
Date:
Wed Oct 28 03:32:05 2015 +0000
Parent:
6:17871da2a7e4
Commit message:
final for lecture;

Changed in this revision

MMA7660.lib Show annotated file Show diff for this revision Revisions of this file
USBDevice.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 17871da2a7e4 -r 23de08e003ec MMA7660.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MMA7660.lib	Wed Oct 28 03:32:05 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/Sissors/code/MMA7660/#36a163511e34
diff -r 17871da2a7e4 -r 23de08e003ec USBDevice.lib
--- a/USBDevice.lib	Fri Mar 01 13:23:58 2013 +0000
+++ b/USBDevice.lib	Wed Oct 28 03:32:05 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/USBDevice/#335f2506f422
+http://mbed.org/users/mbed_official/code/USBDevice/#2af474687369
diff -r 17871da2a7e4 -r 23de08e003ec main.cpp
--- a/main.cpp	Fri Mar 01 13:23:58 2013 +0000
+++ b/main.cpp	Wed Oct 28 03:32:05 2015 +0000
@@ -1,21 +1,24 @@
 #include "mbed.h"
 #include "USBKeyboard.h"
- 
-//LED1: NUM_LOCK
-//LED2: CAPS_LOCK
-//LED3: SCROLL_LOCK
-BusOut leds(LED1, LED2, LED3);
- 
-//USBKeyboard
+#include "MMA7660.h" /* for the accelerometer */
+
 USBKeyboard keyboard;
- 
-int main(void) {
+MMA7660 MMA(D14, D15); /* accelerometer */
+
+int main(void)
+{
+    float x,y,countdown;
+    countdown = 0.0;
     while (1) {
-        keyboard.mediaControl(KEY_VOLUME_DOWN);
-        keyboard.printf("Hello World from Mbed\r\n");
-        keyboard.keyCode('s', KEY_CTRL);
-        keyboard.keyCode(KEY_CAPS_LOCK);
-        wait(1);
-        leds = keyboard.lockStatus();
+        x = MMA.x();
+        y = MMA.y();
+        if (y>0.6f) { keyboard.mediaControl(KEY_VOLUME_DOWN); }
+        if (y<-0.6f) { keyboard.mediaControl(KEY_VOLUME_UP); }
+        if ((abs(x)>0.6f)&&(countdown<=0.0f)) {
+            keyboard.mediaControl(KEY_PLAY_PAUSE); 
+            countdown = 10.0f;
+            }
+        countdown -= 1.0f;
+        wait (0.1);
     }
 }
\ No newline at end of file
diff -r 17871da2a7e4 -r 23de08e003ec mbed.bld
--- a/mbed.bld	Fri Mar 01 13:23:58 2013 +0000
+++ b/mbed.bld	Wed Oct 28 03:32:05 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/3d0ef94e36ec
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/34e6b704fe68
\ No newline at end of file