Craft Club / MasterSword

Dependencies:   TextLCD mbed

Fork of MIYABI_Drive by Nin_PTD_Mecha

Files at this revision

API Documentation at this revision

Comitter:
iwaki
Date:
Thu Jul 27 11:31:52 2017 +0000
Parent:
1:03c191369089
Child:
3:3707e3934185
Commit message:
MIYABI?

Changed in this revision

Text_LCD_Hello/TextLCD.lib Show annotated file Show diff for this revision Revisions of this file
Text_LCD_Hello/mbed.bld 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 diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Text_LCD_Hello/TextLCD.lib	Thu Jul 27 11:31:52 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/simon/code/TextLCD/#44f34c09bd37
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Text_LCD_Hello/mbed.bld	Thu Jul 27 11:31:52 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/10b9abbe79a6
\ No newline at end of file
--- a/main.cpp	Sun Jan 01 20:57:57 2012 +0000
+++ b/main.cpp	Thu Jul 27 11:31:52 2017 +0000
@@ -1,12 +1,76 @@
 #include "mbed.h"
+#include "TextLCD.h"
 
-DigitalOut myled(LED1);
+PwmOut led1(LED1);
+PwmOut led2(LED2);
+PwmOut led3(LED3);
+PwmOut led4(LED4);
+
+PwmOut moter1(p21);
+PwmOut moter2(p22);
+DigitalIn sw1(p23);
+
+TextLCD lcd(p24, p26, p27, p28, p29, p30);      // rs, e, d0-d3
 
 int main() {
+    
+    int i;
+    int s;
+    int n;
+    
+    i = 0;
+    s = 0;
+    n = 100;
+    
+    sw1.mode( PullUp );
+    moter1 = 0.0;
+    moter2 = 0.0;
+    
+    //離れての表示と、動作待ちの5秒待機
+    lcd.cls();
+    lcd.locate(0,0);
+    lcd.printf("Ready to start");
+    lcd.locate(0,1);
+    lcd.printf("Don't touch me");
+    wait(5);
+    
+    //モータ出力ON
+    moter1 = 0.1;
+    moter2 = 0.1;
+    
     while(1) {
-        myled = 1;
-        wait(0.2);
-        myled = 0;
-        wait(0.2);
+        
+        //クリック回数のカウント
+        //チャタリング防止のためタイマ有り
+        //一度OFFになったことを検知するステータスフラグあり
+        if(sw1 == 0 and s == 0) {
+            s = 1;
+            i++;
+            wait(0.0001);
+        }
+        else if(sw1 == 1) {
+            s = 0;
+        }   
+        
+        //LCDへの回数の記載
+        lcd.cls();
+        lcd.locate(0,0);
+        lcd.printf("%d",i);
+        
+        //テスト中か、終了したかのLCDへの記載
+        if( n > i ) {
+            lcd.locate(0,1);
+            lcd.printf("testing");
+        }
+        else {
+            lcd.locate(0,1);
+            lcd.printf("End");
+            
+            moter1 = 0;
+            moter2 = 0;
+        }
+        
+        //LCDへの記載を安定させるための待機
+        wait(0.05);
     }
 }
--- a/mbed.bld	Sun Jan 01 20:57:57 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/078e4b97a13e