【背景】 「(右手が忙しいので,)足でEnterキーを入力したい.」という依頼があり,製作した.これ以上詳しく理由を聞くことはなかった・・・(お察し下さい). 【ハードウェア】 レーシングゲーム用コントローラのペダルに,マイクロスイッチを取り付けた.アクセルペダルやブレーキペダルを踏むと,それぞれのマイクロスイッチが押される.マイクロスイッチはプルアップで接続されている. 【動作】 アクセルペダルを踏むとEnterが入力され,ブレーキペダルを踏むと下にスクロールする.

Dependencies:   USBDevice TextLCD mbed

Files at this revision

API Documentation at this revision

Comitter:
_muki
Date:
Tue Jun 12 05:06:30 2012 +0000
Commit message:
ver.1.0

Changed in this revision

TextLCD.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 000000000000 -r 7fda85a1ff8e TextLCD.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TextLCD.lib	Tue Jun 12 05:06:30 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/davervw/code/TextLCD/#c5318c74f1a9
diff -r 000000000000 -r 7fda85a1ff8e USBDevice.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDevice.lib	Tue Jun 12 05:06:30 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/samux/code/USBDevice/#140cdf8e2d60
diff -r 000000000000 -r 7fda85a1ff8e main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Jun 12 05:06:30 2012 +0000
@@ -0,0 +1,112 @@
+#include "mbed.h"
+#include "USBMouseKeyboard.h"
+#include "TextLCD.h"
+
+USBMouseKeyboard pedal;
+
+TextLCD lcd(p24, p26, p27, p28, p29, p30); // rs, e, d0-d3 
+
+DigitalOut a_led(LED1);
+DigitalOut b_led(LED2);
+
+DigitalOut powerA(p13);
+DigitalOut powerB(p14);
+
+/*
+InterruptIn Accel(p12);
+InterruptIn Brake(p29);
+*/
+
+DigitalIn Accel(p9);
+DigitalIn Brake(p18);
+
+int accel_flag; // push?
+int brake_flag; // push?
+
+/*
+void Afall(){
+    accel_flag = 0;
+    wait(0.1);
+}
+void Arise(){
+    accel_flag++;
+    wait(0.1);
+}
+void Bfall(){
+    brake_flag = 0;
+    wait(0.1);
+
+}
+void Brise(){
+    brake_flag++;
+    wait(0.1);
+}
+*/
+
+
+int main(void) {
+    int i=0;
+
+    /* debug */
+    a_led = 1;
+    b_led = 1;
+    lcd.printf("hello\n");
+    
+
+    /* Initialize */
+    powerA = 1;
+    powerB = 1;
+
+    accel_flag = 0;
+    brake_flag = 0;
+
+
+    /* main Loop */
+    while (1) {
+        /* debug */
+        a_led = accel_flag;
+        b_led = brake_flag;
+
+
+        /* sensing */    
+        if(Accel > 0.5){
+            accel_flag = 1;
+        }else{
+            accel_flag = 0;
+        }
+        if(Brake > 0.5){
+            brake_flag = 1;
+        }else{
+            brake_flag = 0;
+        }
+   
+
+        /* keyboard input */        
+        if(i > 10){
+            lcd.cls();
+            if(accel_flag > 0){
+                lcd.locate(0,0); lcd.printf("A:%d",accel_flag);
+                pedal.printf("\n");
+            }
+
+            if(brake_flag > 0){
+                //pedal.keyCode('', KEY_CTRL);
+                lcd.locate(0,1); lcd.printf("B:%d",brake_flag);
+                pedal.scroll(127); // -128 ~ 127
+            }
+            i = 0;
+        }
+    
+        i++;
+        wait(0.1);
+    }
+
+    return 0;
+/*    Accel.fall(&Afall);
+    Accel.rise(&Arise);
+    Brake.fall(&Bfall);
+    Brake.rise(&Brise);
+*/
+
+
+}
diff -r 000000000000 -r 7fda85a1ff8e mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Jun 12 05:06:30 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/737756e0b479