Laser Harp Project

Hello community,
I have recently started my first arduino project, took this as a main guidline:

It's all working and everything is cool, but the rotation of the motor is not wide enough to create enough space between the laser beams. It creates 9 beams across a range of 15cm approx. and I want it to spread over at least a meter. That means that the shaft of the motor should rotate more "forward" before it starts going backwards over again.

I couldn't find any line on the script regards the rotation of the shaft, and I would like to get some help over here,

Thanks in advance!

What is the steps per revolution of your stepper motor? In the sketch he advances the motor 1 step for each beam. To widen the "fan" of beams you need more than 1 step between each beam.

That sketch could be rewritten to use the stepper library to make it easier to customize.

groundFungus:
What is the steps per revolution of your stepper motor? In the sketch he advances the motor 1 step for each beam. To widen the "fan" of beams you need more than 1 step between each beam.

That sketch could be rewritten to use the stepper library to make it easier to customize.

How can I check the steps per revolution of my motor? Is it written in the manual or is it defined in the script?

If that information is not on a name plate on the motor, you will need to find a data sheet for the motor. Do you have a part number? Can you post a photo of the nameplate?

Thats the datasheet.

The data sheet says "stride angle 7.5 degrees" so 48 steps per revolution (360 / 7.5).

groundFungus:
The data sheet says "stride angle 7.5 degrees" so 48 steps per revolution (360 / 7.5).

Oh, peobably missed it, thanks!
So how can I change the steps number the code works by?

This is the part that moves the motor.

digitalWrite(motorPin1, HIGH);             
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, LOW);

if you will notice, the HIGH moves down one position for each beam.
The next move is

digitalWrite(motorPin1, LOW);            
digitalWrite(motorPin2, HIGH);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, LOW);

And the next move:

digitalWrite(motorPin1, LOW);            
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, HIGH);
digitalWrite(motorPin4, LOW);

And so on. The HIGH moves down and after motor4 is HIGH it goes to the top to start over again.

So do you see what you have to do to do 2 steps? You need to move the HIGH twice with a small delay between calls to move to give the motor time to move. Probably have to experiment to find the delay that works.

Like I said, rewriting the code to use the stepper library could reduce all of that to

stepper.step(2):

for each beam.

groundFungus:
This is the part that moves the motor.

digitalWrite(motorPin1, HIGH);             

digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, LOW);



if you will notice, the HIGH moves down one position for each beam.
The next move is


digitalWrite(motorPin1, LOW);           
digitalWrite(motorPin2, HIGH);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, LOW);



And the next move:


digitalWrite(motorPin1, LOW);           
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, HIGH);
digitalWrite(motorPin4, LOW);




And so on. The HIGH moves down and after motor4 is HIGH it goes to the top to start over again.

So do you see what you have to do to do 2 steps? You need to move the HIGH twice with a small delay between calls to move to give the motor time to move. Probably have to experiment to find the delay that works.

Like I said, rewriting the code to use the stepper library could reduce all of that to 


stepper.step(2):



for each beam.

First, thank you very much man, you're helping me a lot here!

So, if I got it correctly, I need to add this line first:
Stepper myStepper = Stepper(48, 8, 9, 10, 11)

And that helps the arduino recognize the stepper motor I have, with how many spr, and on which pins it connected, right?

After I have it recognized, I can replace the digitalWrite(motorpin1,2..) in every beam with this?
stepper.step(2):

Do I need to set a nominal rotation speed or something?

Thanks again!!!

So, if I got it correctly, I need to add this line first:
Stepper myStepper = Stepper(48, 8, 9, 10, 11)

Yes, except the syntax is:

Stepper myStepper(48, 8, 9, 10, 11);

And that helps the arduino recognize the stepper motor I have, with how many spr, and on which pins it connected, right?

Yes.

After I have it recognized, I can replace the digitalWrite(motorpin1,2..) in every beam with this?
stepper.step(2):

Each one of these:

digitalWrite(motorPin1, LOW);           
digitalWrite(motorPin2, HIGH);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, LOW);

takes one step, so yes, to take 2 steps replace the above with myStepper.step(2).

Do I need to set a nominal rotation speed or something?

Yes.

There are some example sketches that come with the Stepper library. The Stepper library is built in to the IDE. I suggest that you play with the examples till you understand how the library works.