intentomotorpasoapaso

Dependencies:   mbed

Fork of 00_LAB_STEPMOTOR by ferney alberto beltran molina

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "stepmotor.h"
00003 
00004 #define NSXC 4096
00005 stepmotor smotor1(D9,D10,D11,D12);
00006 Serial pc(USBTX,USBRX);
00007 int main() {
00008     
00009     //definir posicion central del servo
00010     
00011     
00012     
00013     uint32_t speed=1500;
00014     bool cw=true;
00015     
00016     while(1)
00017     {
00018         smotor1.set_speed(speed);
00019        
00020 
00021         pc.printf("velocidad del motor:  %i, %f rpm, CW=%d  \n",smotor1.get_speed(), (60/((smotor1.get_speed()*4.096)/1000))cw);
00022         
00023         smotor1.step(cu*NSXC,sent);
00024         
00025        
00026         speed=speed+1000;
00027         if (speed > 9600)speed =1500;
00028         cw=!cw;
00029         wait(1);
00030     }
00031 }