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.
main.cpp
00001 // 28BYJ-48 stepper motor example 00002 // showing how to control a unipolar stepper motor by mbed digital output ports. 00003 // Tested on the Nucleo F103RB Board 00004 // Based on http://www.geeetech.com/wiki/index.php/Stepper_Motor_5V_4-Phase_5-Wire_%26_ULN2003_Driver_Board_for_Arduino 00005 // Using the ULN2003A Driver. 00006 00007 #include "mbed.h" 00008 00009 BusOut motor_out(PC_0, PC_1, PC_2, PC_3); // blue - pink - yellow - orange 00010 00011 int step = 0; 00012 int dir = 1; // direction 00013 00014 int main() 00015 { 00016 while(1) 00017 { 00018 switch(step) 00019 { 00020 case 0: motor_out = 0x1; break; // 0001 00021 case 1: motor_out = 0x3; break; // 0011 00022 case 2: motor_out = 0x2; break; // 0010 00023 case 3: motor_out = 0x6; break; // 0110 00024 case 4: motor_out = 0x4; break; // 0100 00025 case 5: motor_out = 0xC; break; // 1100 00026 case 6: motor_out = 0x8; break; // 1000 00027 case 7: motor_out = 0x9; break; // 1001 00028 00029 default: motor_out = 0x0; break; // 0000 00030 } 00031 00032 if(dir) step++; else step--; 00033 if(step>7)step=0; 00034 if(step<0)step=7; 00035 wait(0.015); // speed 00036 } 00037 } 00038
Generated on Wed Jul 13 2022 11:07:20 by
1.7.2