The built-in Arduino Stepper class method setSpeed takes the RPM as it's argument. I think 800 RPM is too high so you should scale that down to something much lower for a BYJ motor.
Maybe 10 (as it is set in the main sketch) would be a better choice. Also, re-testing at speed 5 RPM would be a useful test of the BYJ's ability to perform reliably at 10 RPM.
Anything seems possible when you don't know what you're talking about.
I have not yet implemented the flashing LEDs while the bridge is moving (I'm not sure that's possible because I think the Stepper class blocks while it's moving).
Perhaps use a self flashing LED. Or maybe break the total number of steps into smaller group moves of say 10 turning the LED on or off between each group move. Something like this:
int LED_STATE = 1; // move 100 steps // turn on LED on entry for (int i=0; i<10; i++{ stepMot.step(10); LED_STATE = - LED_STATE; // toggle LED_STATE if (LED_STATE == 1 then){ // turn on LED }else{ // turn off LED } } // turn off LED on exit
I have not yet implemented the flashing LEDs while the bridge is moving (I'm not sure that's possible because I think the Stepper class blocks while it's moving).
Perhaps use a self flashing LED. Or maybe break the total number of steps into smaller group moves of say 10 turning the LED on or off between each group move. Something like this:
Yes, I was prototyping a system where the blink length was changed to 100 ms (from 500 ms) and then back calculated the number of steps which could be performed in that interval. I then break down the total stepCount into 100 ms step lets and switch the LED state every time that stepping is done.
I asked kobusven95 if it was OK to change the blink timing but never got an answer. If it's too short the LEDs will look silly and if it's too long they'll only blink once (if that). At 100 ms and the currently set speed of the stepper, it comes to about 34 steps per blink (that's 68 steps for a blink on and off).
Quite a conundrum:)
Anything seems possible when you don't know what you're talking about.
I tested the motor, and it is definitely 2048 for a full rotation. I have seen somewhere else a person talked about the rotation be 2038, and tested that as well, but then the rotation is off. I have also played around with several other values (256, 512, 768, 1024 as well as the negative numbers of these, and the motor stops exactly where it should.
Regarding the LED's "to change the blink timing but never got an answer" sorry. missed that one. Yes, that is in order.
Regarding the LED's "to change the blink timing but never got an answer" sorry. missed that one. Yes, that is in order.
There's a couple of ways to do it. One is to use a shorter blink (say 100 ms for each on and each off cycle) or picking a number of blinks per movement.
The first will give a fast, but constant speed blink for all but the last bit of the rotation. The second will result in very slow pulses for long moves and very fast pulses for short moves.
Another option is, as robotBuilder suggests, to use self-blinking LEDs instead of normal ones, you'd just need to power them on when the move starts and power them off when it ends. I don't know if they all blink at the same rate though, but it may not matter for short 'on' times.
Anything seems possible when you don't know what you're talking about.