Hirotaka Yoneda / Mbed 2 deprecated junirobo_sample001

Dependencies:   beep_sound mbed

Files at this revision

API Documentation at this revision

Comitter:
RBH
Date:
Sat Sep 10 13:22:39 2016 +0000
Commit message:
first

Changed in this revision

beep_sound.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 b2827cba92a6 beep_sound.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/beep_sound.lib	Sat Sep 10 13:22:39 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/RBH/code/beep_sound/#a64e653b0ce1
diff -r 000000000000 -r b2827cba92a6 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Sep 10 13:22:39 2016 +0000
@@ -0,0 +1,61 @@
+/////////////////////////////////////////////////////
+//プログラムをスタートさせるにはスイッチSW1を押してください.//
+//////////スピーカーをソケットE3に挿してください.//////////
+/////////////////////////////////////////////////////
+
+#include "mbed.h"
+#include "beep_sound.h"
+
+beep_sound bs(D10);
+DigitalOut R1(PC_8);
+DigitalOut R2(PC_9);
+DigitalOut L1(PA_11);
+DigitalOut L2(PC_6);
+DigitalIn sw1(D4);
+
+void buzzer_low(void){
+    bs.onpu(1,0,0.2);
+    bs.onpu(1,2,0.2);
+    bs.onpu(1,4,0.2);
+    wait(0.2);
+}
+void buzzer_high(void){
+    bs.onpu(2,0,0.2);
+    bs.onpu(2,2,0.2);
+    bs.onpu(2,4,0.2);
+    wait(0.2);
+}
+/* 前進 */
+void accel(){
+    R1 = 0;
+    R2 = 1;
+    L1 = 0;
+    L2 = 1;
+}
+/* バック */
+void back(){
+    R1 = 1;
+    R2 = 0;
+    L1 = 1;
+    L2 = 0;
+}
+/* ブレーキ */
+void brake(){
+    R1 = 1;
+    R2 = 1;
+    L1 = 1;
+    L2 = 1;
+}
+
+int main(){
+    while(1){if(sw1==1)break;}   // スイッチsw1を押すとスタート
+    
+    accel();
+    wait(1.5);
+    brake();
+    buzzer_low();
+    back();
+    wait(1.5);
+    brake();
+    buzzer_high();
+}
\ No newline at end of file
diff -r 000000000000 -r b2827cba92a6 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Sep 10 13:22:39 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/2e9cc70d1897
\ No newline at end of file