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: mbed
main.cpp
- Committer:
- henriquer
- Date:
- 2020-05-12
- Revision:
- 0:c93bfd3fdede
File content as of revision 0:c93bfd3fdede:
#include "mbed.h" DigitalOut IN1(D6); DigitalOut IN2(D7); DigitalOut IN3(D8); DigitalOut IN4(D9); #define steprevo 4096 #define us 70000000 //*****************Rotina Cálculo rpm*****************\\ void set_rpm (int rpm) { wait_us(us/steprevo/rpm); // 70us/4096 ---> 18 rev/min valor máximo } //*****************Rotina Half Drive*****************\\ void stepper_half (int step) { switch(step) { case 0: IN1 = 1; IN2 = 0; IN3 = 0; IN4 = 0; break; case 1: IN1 = 1; IN2 = 1; IN3 = 0; IN4 = 0; break; case 2: IN1 = 0; IN2 = 1; IN3 = 0; IN4 = 0; break; case 3: IN1 = 0; IN2 = 1; IN3 = 1; IN4 = 0; break; case 4: IN1 = 0; IN2 = 0; IN3 = 1; IN4 = 0; break; case 5: IN1 = 0; IN2 = 0; IN3 = 1; IN4 = 1; break; case 6: IN1 = 0; IN2 = 0; IN3 = 0; IN4 = 1; break; case 7: IN1 = 1; IN2 = 0; IN3 = 0; IN4 = 1;break; } } int main() { while(1) { for(int i=0; i<512; i++) { for(int i=0; i<8; i++) { stepper_half(i); set_rpm(18); } } } }