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.
Dependencies: StepperMotorUni mbed
main.cpp
00001 // "Hello" program for StepperMotorUni class library 00002 00003 00004 #include "mbed.h" 00005 #include "StepperMotorUni.h" 00006 00007 StepperMotorUni motor( PTB0, PTB1, PTB2, PTB3); 00008 00009 DigitalIn sw0(PTD1); // Switch selected as input 00010 DigitalIn sw1(PTD3); 00011 DigitalIn sw2(PTD2); 00012 DigitalIn sw3(PTD0); 00013 00014 int main() 00015 { motor.set_pps( 200 ); 00016 while (1) 00017 { 00018 if (sw0==0 && sw1==0 && sw2==0 && sw3==0) 00019 { 00020 motor.move_steps(150); 00021 } 00022 else if (sw0==0 && sw1==0 && sw2==0 && sw3==1) 00023 { 00024 motor.move_steps(140); 00025 wait(5); 00026 } 00027 else if (sw0==0 && sw1==0 && sw2==1 && sw3==0) 00028 { 00029 motor.move_steps(130); 00030 wait(5); 00031 } 00032 else if (sw0==0 && sw1==0 && sw2==1 && sw3==1) 00033 { 00034 motor.move_steps(120); 00035 wait(5); 00036 } 00037 else if (sw0==0 && sw1==1 && sw2==0 && sw3==0) 00038 { 00039 motor.move_steps(110); 00040 wait(5); 00041 } 00042 else if (sw0==0 && sw1==1 && sw2==0 && sw3==1) 00043 { 00044 motor.move_steps(100); 00045 wait(5); 00046 } 00047 else if (sw0==0 && sw1==1 && sw2==1 && sw3==0) 00048 { 00049 motor.move_steps(90); 00050 wait(5); 00051 } 00052 else if (sw0==0 && sw1==1 && sw2==1 && sw3==1) 00053 { 00054 motor.move_steps(80); 00055 wait(5); 00056 } 00057 else if (sw0==1 && sw1==0 && sw2==0 && sw3==0) 00058 { 00059 motor.move_steps(70); 00060 wait(5); 00061 } 00062 else if (sw0==1 && sw1==0 && sw2==0 && sw3==1) 00063 { 00064 motor.move_steps(60); 00065 wait(5); 00066 } 00067 else if (sw0==1 && sw1==0 && sw2==1 && sw3==0) 00068 { 00069 motor.move_steps(50); 00070 wait(5); 00071 } 00072 else if (sw0==1 && sw1==0 && sw2==1 && sw3==1) 00073 { 00074 motor.move_steps(40); 00075 wait(5); 00076 } 00077 else if (sw0==1 && sw1==1 && sw2==0 && sw3==0) 00078 { 00079 motor.move_steps(30); 00080 wait(5); 00081 } 00082 else if (sw0==1 && sw1==1 && sw2==0 && sw3==1) 00083 { 00084 motor.move_steps(20); 00085 wait(5); 00086 } 00087 else if (sw0==1 && sw1==1 && sw2==1 && sw3==0) 00088 { 00089 motor.move_steps(10); 00090 wait(5); 00091 } 00092 else if (sw0==1 && sw1==1 && sw2==1 && sw3==1) 00093 { 00094 motor.move_steps(00); 00095 wait(5); 00096 } 00097 else 00098 { 00099 motor.move_steps(0); 00100 } 00101 } 00102 }
Generated on Mon Jul 18 2022 19:16:20 by
1.7.2