miniblip USB piano example

Dependencies:   USBDevice mbed

Fork of Fruit_Piano by Seeed

Files at this revision

API Documentation at this revision

Comitter:
pighixxx
Date:
Thu Nov 26 09:27:00 2015 +0000
Parent:
1:93bbcf91f356
Commit message:
miniblip USB piano

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 93bbcf91f356 -r 1cb69f19f49c main.cpp
--- a/main.cpp	Mon Aug 18 01:58:34 2014 +0000
+++ b/main.cpp	Thu Nov 26 09:27:00 2015 +0000
@@ -1,17 +1,16 @@
+// miniblip play sound - capacitative + keyboard out
+
 #include "mbed.h"
-#include "USBKeyboard.h"
-
-#define LOG(args...)        // printf(args)
+#include "USBKeyboard.h"      
 
 #define THRESHOLD   2
-#define TOUCH_N     6
+#define TOUCH_N     5
 
-BusOut leds(LED1, LED2, LED3, LED4);
 Ticker tick;
 USBKeyboard keyboard;
 
 uint8_t       key_map[] = {'a', 'f', 'd', 'g', 'd', 'h', 'j', 'k', 'l', ';', '\'', '\n'};
-PinName       touch_pin[] = {A0, A3, A2, A4, A1, A5};
+PinName       touch_pin[] = {P0_15, P0_14, P0_13, P0_12, P0_11};
 DigitalInOut *p_touch_io[TOUCH_N];
 
 uint16_t touch_data[TOUCH_N] = {0, };
@@ -34,13 +33,9 @@
         touch_io->output();
         touch_io->write(1);
         
-        if (0x01 == touch_data[i]) {            // a measurement is about the threshold, get a touch
-            leds = 1 << i;
+        if (0x01 == touch_data[i]) {            // Threshold, get a touch
             keyboard.putc(key_map[i]);
-            LOG("No %d key is touched\r\n", i);
-        } else if (0x80 == touch_data[i]) {     // last 7 measurement is under the threshold, touch is released
-            leds = 0x00;
-            LOG("No %d key is released\r\n", i);
+        } else if (0x80 == touch_data[i]) {     // Last 7 measurement is under the threshold, touch is released
         }
     }
 }
@@ -48,6 +43,11 @@
 int main()
 {
     // setup
+    
+    // Turn off miniblip buzzer
+    PwmOut speaker(P0_8);
+    speaker=0.0;
+    
     for (int i = 0; i < TOUCH_N; i++) {
         p_touch_io[i] = new DigitalInOut(touch_pin[i]);
         p_touch_io[i]->mode(PullDown);