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.
Fork of moter_titech by
Diff: main.cpp
- Revision:
- 9:56d571c1cb9f
- Parent:
- 8:3eb58ae94a93
- Child:
- 10:808032cf71b0
--- a/main.cpp Thu Jan 23 05:39:20 2014 +0000
+++ b/main.cpp Fri Jan 24 02:24:50 2014 +0000
@@ -15,6 +15,7 @@
int zen2=0;
int go2=0;
int dou1=0;
+int dou2=0;
void HANTEI(void const *argument) {
while(true){
@@ -24,45 +25,51 @@
case'g':
zen1=1;
c=0;
- pc.printf("go\n");
+ pc.printf("go\r\n");
break;
case'n':
zen1=0;
go1=0;
c=0;
- pc.printf("stop\n");
+ pc.printf("stop\r\n");
break;
case'z':
go1=1;
c=0;
- pc.printf("zen\n");
+ pc.printf("zen\r\n");
break;
case'c':
zen2=1;
c=0;
- pc.printf("go\n");
+ pc.printf("go\r\n");
break;
case'p':
zen2=0;
go2=0;
c=0;
- pc.printf("stop\n");
+ pc.printf("stop\r\n");
break;
case'x':
go2=1;
c=0;
- pc.printf("zen\n");
+ pc.printf("zen\r\n");
break;
case'd':
dou1=1;
c=0;
- pc.printf("dou\n");
+ pc.printf("dou\r\n");
+ break;
+
+ case'l':
+ dou2=1;
+ c=0;
+ pc.printf("dou_2gouki\r\n");
break;
}
}
@@ -101,7 +108,8 @@
}
void DOU1(void const *argument) {
- Dou1.period(0.00001);
+ Dou1.period(0.00001);
+ Dou1.pulsewidth(0.000005f);
int i=1;
int d=1;
while(true){
@@ -115,10 +123,10 @@
break;
case 2:
- Dou1.pulsewidth(0.000006f);
+ Dou1.pulsewidth(0.000005f);
i=i--;
wait(0.02);
- if(i>2){
+ if(i<2){
d=1;
dou1=0;
}
@@ -127,15 +135,44 @@
}
}
}
-
+
+void DOU2(void const *argument) {
+ Dou2.period(0.00001);
+ Dou2.pulsewidth(0.000005f);
+ int j=1;
+ int l=1;
+ while(true){
+ if(dou2==1){
+ switch(l){
+ case 1:
+ Dou2.pulsewidth(0.000004f);
+ j=j++;
+ wait(0.02);
+ if(j>50)l=2;
+ break;
+
+ case 2:
+ Dou2.pulsewidth(0.000005f);
+ j=j--;
+ wait(0.02);
+ if(j<2){
+ l=1;
+ dou2=0;
+ }
+ break;
+ }
+ }
+ }
+}
int main() {
Thread t1(HANTEI);
Thread t2(ZENGO1);
Thread t3(ZENGO2);
Thread t4(DOU1);
+ Thread t5(DOU2);
- pc.printf("start\n");
+ pc.printf("start\r\n");
while(1);
}
\ No newline at end of file
