Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Revision:
- 0:b2827cba92a6
--- /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