]> git.piffa.net Git - sketchbook_andrea/blob - motors/stepper/cdrom_stepper/cdrom_stepper.ino
step motors
[sketchbook_andrea] / motors / stepper / cdrom_stepper / cdrom_stepper.ino
1
2 /*
3  CDROM stepper
4  
5  Pilotare lo step di un lettore CDROM mediante 
6  il motor shield.
7  
8  - http://wiki.piffa.net/index.php/CNC_ROM
9
10 Pin on top, plastica sotto
11
12     1  2    2 5 1 3   1 e' il piu' vicino al capacitor
13     3  4   
14     
15 */
16
17 #include <AFMotor.h>
18
19 // Connect a stepper motor with 48 steps per revolution (7.5 degree)
20 // to motor port #2 (M3 and M4)
21 AF_Stepper motor(200, 2); //Motor with 200 steps per rev (1.8 degree)
22
23 void setup() {
24   Serial.begin(9600);           // set up Serial library at 9600 bps
25   Serial.println("Stepper test!");
26
27   motor.setSpeed(20);  // max 400 
28 }
29
30 void loop() {
31
32   //motor.step(340, FORWARD, MICROSTEP); 
33   //motor.step(340, BACKWARD, MICROSTEP); 
34   
35   for (int lenght = 340; lenght > 40; lenght -= 40)
36   {
37     motor.step(lenght, FORWARD, MICROSTEP);
38     motor.step(lenght - 20, BACKWARD, MICROSTEP);
39   }
40   motor.step(150, BACKWARD, MICROSTEP);
41 }