pomocni program Sumejja Porča Almir HUsić

Dependencies:   mbed sMotor

Committer:
tim004
Date:
Mon May 19 11:53:43 2014 +0000
Revision:
0:8e21b0589b4a
Projekat - program za motor; Sumejja Porca; Almir Husic

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tim004 0:8e21b0589b4a 1
tim004 0:8e21b0589b4a 2
tim004 0:8e21b0589b4a 3 #include "mbed.h"
tim004 0:8e21b0589b4a 4 #include "sMotor.h"
tim004 0:8e21b0589b4a 5
tim004 0:8e21b0589b4a 6 sMotor motor(dp9, dp10, dp11, dp13); // creates new stepper motor: IN1, IN2, IN3, IN4
tim004 0:8e21b0589b4a 7
tim004 0:8e21b0589b4a 8 int step_speed = 1200 ; // set default motor speed
tim004 0:8e21b0589b4a 9 int numstep = 512 ; // defines full turn of 360 degree
tim004 0:8e21b0589b4a 10 int direction = 0; //0 for right, 1 for left
tim004 0:8e21b0589b4a 11
tim004 0:8e21b0589b4a 12 void screenMenu()
tim004 0:8e21b0589b4a 13 {
tim004 0:8e21b0589b4a 14 // Screen Menu
tim004 0:8e21b0589b4a 15 //pc.printf("Default Speed: %d, press: \n\r",step_speed);
tim004 0:8e21b0589b4a 16 //pc.printf("1- to choose random angle to set new motor state\n\r");
tim004 0:8e21b0589b4a 17 //pc.printf("2- to change the motor direction\n\r");
tim004 0:8e21b0589b4a 18 //pc.printf("3- to change the rotation speed\n\r");
tim004 0:8e21b0589b4a 19 //pc.printf("4- to start/stop the motor\n\r");
tim004 0:8e21b0589b4a 20 }
tim004 0:8e21b0589b4a 21 int main() {
tim004 0:8e21b0589b4a 22
tim004 0:8e21b0589b4a 23 screenMenu();
tim004 0:8e21b0589b4a 24 int angle(0);
tim004 0:8e21b0589b4a 25 while (1) {
tim004 0:8e21b0589b4a 26
tim004 0:8e21b0589b4a 27 motor.step(numstep / 360 * (angle % 360), direction, step_speed); // number of steps, direction, speed
tim004 0:8e21b0589b4a 28 angle++;
tim004 0:8e21b0589b4a 29 wait(0.1);
tim004 0:8e21b0589b4a 30 // screenMenu();
tim004 0:8e21b0589b4a 31
tim004 0:8e21b0589b4a 32 }
tim004 0:8e21b0589b4a 33 }