mbedキッズワークショップで使うプログラムです

Dependencies:   SB1602E mbed

Files at this revision

API Documentation at this revision

Comitter:
MACRUM
Date:
Sun Jul 24 01:59:07 2016 +0000
Parent:
2:58071b3466bd
Commit message:
Fix key delay

Changed in this revision

kids_workshop.h 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
diff -r 58071b3466bd -r c9f6f084f03a kids_workshop.h
--- a/kids_workshop.h	Sun Jul 24 01:42:06 2016 +0000
+++ b/kids_workshop.h	Sun Jul 24 01:59:07 2016 +0000
@@ -30,7 +30,6 @@
 int disp_mode;
 
 const int tone_table_us[] = {
-0,
 3822,
 //3608,
 3405,
@@ -43,7 +42,8 @@
 2273,
 //2145,
 2025,
-1911
+1911,
+0
 };
 
 #endif
diff -r 58071b3466bd -r c9f6f084f03a main.cpp
--- a/main.cpp	Sun Jul 24 01:42:06 2016 +0000
+++ b/main.cpp	Sun Jul 24 01:59:07 2016 +0000
@@ -11,17 +11,12 @@
         led1 = 0;  // led1を消す
         wait(0.3); // すこしまつ
         
-        if (din == 0) {
-            key_pressed();
-            disp_mode = !disp_mode;
-        }
-
-        float ondo = ((ain * 3.23 - 0.6) / 0.01);
+        float ondo = ((ain * 3.25 - 0.6) / 0.01);
 
         if (disp_mode == 0 ) {
             lcd.printf(0, 0, "%2.2f  ", ondo);            
         } else {
-            lcd.printf(0, 0, "Hello");
+            lcd.printf(0, 0, "Hello!");
         }
 
     }
@@ -36,8 +31,9 @@
     }
     wave.period_us(tone_table_us[key]);
     key++;
+    disp_mode = !disp_mode;
 }
-    
+
 void init()
 {
     disp_mode = 1;
@@ -45,6 +41,7 @@
     lcd.contrast(0x30);
     
     din.mode(PullUp);
+    din.fall(&key_pressed);
     
     wave.write(0.5);
     wave.period_us(0);