This is my first program on mbed.org. A Small program for KL25Z that'll act as a Volume Control, thanks to samux for his code with USB keyboard support (https://mbed.org/users/samux/code/USBKeyboard_HelloWorld/) Just added functionality to let the user use the Touch Slider on the KL25Z board to control system volume.

Dependencies:   mbed TSI MMA8451Q USBDevice

Fork of USBKeyboard_HelloWorld by Samuel Mokrani

Revision:
8:84597c4309a9
Parent:
7:ec6f541a0636
Child:
9:0b6c84d01c5d
--- a/main.cpp	Sat Nov 30 12:51:15 2013 +0000
+++ b/main.cpp	Sat Nov 30 14:49:17 2013 +0000
@@ -14,33 +14,38 @@
 
 #define MMA8451_I2C_ADDRESS (0x1d<<1)
 
-//USB Keyboard interface:
-USBKeyboard keyboard;
-//Touch Slider:
-TSISensor tsi;
-
 int main(void) {
+    ///get leds, and set def. values
+    PwmOut bled(LED_BLUE);
+    bled=0.8;
+    PwmOut rled(LED_RED);
+    rled=1;
+    PwmOut gled(LED_GREEN);
+    gled=1;
     ///initializing the accelerometer
     MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS);
-    ///get leds
-    PwmOut rled(LED_RED);
-    PwmOut gled(LED_GREEN);
-    PwmOut bled(LED_BLUE);
+    bled=0.6;
+    //USB Keyboard interface:
+    USBKeyboard keyboard;
+    bled=0.4;
+    //Touch Slider:
+    TSISensor tsi;
+    bled=0.2;
 
-    ///switch on blue led and switch off others
-    bled=0;
-    rled=1;
-    gled=1;
-    wait(2);
+    ///switch on blue led
+    bled=0.9;
     ///Wait until keyboard is configured
     while (!keyboard.configured()) {
+        bled=0.1;
+        wait(1);
+        bled=0.9;
+        wait(1);
     }
     bled=1;
 
     float current=-1; //< Current state of Slider
     float newRead; //< New readings of the slider
 
-
     while (true) {
         newRead=tsi.readPercentage();
         gled=1.0 - newRead;