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: stepping_moter.cpp
- Revision:
- 0:110462dc43d1
diff -r 000000000000 -r 110462dc43d1 stepping_moter.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/stepping_moter.cpp Tue May 15 03:45:15 2012 +0000
@@ -0,0 +1,43 @@
+#include"mbed.h"
+#include"stepping_moter.h"
+
+ stepping_moter::stepping_moter(PinName p1,PinName p2,PinName p3,PinName p4) : _d(p1,p2,p3,p4){
+ _d=0;
+ }
+
+void stepping_moter::step_moter(int deg_set,double wait_time){
+ unsigned int end=1;
+ static int deg_m=0,i;
+while(end){
+ if(deg_m<deg_set){
+ if (i==3) i=0;
+ else i+=1;
+ deg_m+=1;
+ }//if
+ else if(deg_m>deg_set){
+ if (i==0) i=3;
+ else i-=1;
+ deg_m-=1;
+ }
+ else if(deg_m==deg_set){
+ end=0;
+ }
+
+ switch(i){
+ case 0:
+ _d=9;
+ break;
+ case 1:
+ _d=3;
+ break;
+ case 2:
+ _d=6;
+ break;
+ case 3:
+ _d=12;
+ break;
+ }//switch
+
+ wait(wait_time);
+ }//while
+ }//step_moter
\ No newline at end of file