Omg it was really that simple!! I change two int's to long's [the ones that I set to millis() to] and it couldn't have worked more perfectly. Thank you so much for your help. Can't believe I didn't think of this 6 months ago when I gave up on it for a while. I even had to do this in another part of my code not long before I gave up them 6 months ago. It seems to be the simple things I always overlook.
Yes, simple! Please learn however you do just why your fix was a fix.
Now decide that the playTimeLapse "if" statement should be a "while" statement. I think so.
There are other things that may come up soon… the code was not written with any expectation that it would need to be debugged or enhanced. If you do get it all working the way you want, I suggest using it only as a demonstration partial functional specification for any enhanced version.
You may have noticed what a PITA it is to test something designed to play out over several minutes - it takes several minutes! A better design would allow testing at a faster rate. At least first blush testing. Of course full testing of any real time system will sooner later take real time.
When you put print statements inside while loops, thousands of "Bob" and "Nancy" go tumbling by, scrolling other messages off screen where you miss them. In several places I did this:
while((millis() - startMoveTime) <= 2000)
{
movexMotor();
if (printBobOnce) {
Serial.println(" bob");
printBobOnce = 0;
}
}
printBobOnce = 1;
where printBobOnce is just a global unsigned char used as a flag to make just one announcement for the entire while loop. It can be modified slightly to print the message from within the loop a few times rather than just once.
Lastly, I do hope you are reading this carefully, please be sure that this
int exposureDelay = (seconds * 1000);
Does what and all you want. From a cursory examination of your code, it looks like you expect this to set up a tracking style relationship. Like if you change the value of seconds during a run, exposureDelay will follow along obediently. It will not.
exposureDelay is created and initialised by that line and takes on its value depending on the value of seconds. This occurs at compile time. Since there are no other assignments to exposureDelay, its value will not change at any point during run time.
This may be what you intended. I mention it only because it is a mistake pattern I see all the time.
Sry if you know all this. I don't know who wrote the code or where they were coming from, but this project could def benefit from a ground-up rewrite both for debugging convenience and ease of making enhancements, while making possible a less brain-dead control panel, which as you may have noticed kinda goes dark and ignorant during long sequences of your machinery doing its thing.
We'll be here or over in programming when this and a few other kinds of things start to really get old! Look forward to "fixing" things like this, even if it they dont seem broken:
void shutter()
{
digitalWrite(shutterPIN, HIGH);
delay(500);
digitalWrite(shutterPIN, LOW);
}
I appreciate you may be more interested in getting this project finished and never looking back; if you want to go further into this kind of thing the strategy needs to be a modern one if you want to remain with all your hair not pulled out.
Thanks for the lib zip, I did manage finally without it but I will set it aside for that day which may come.
a7
Ah yes I know the code is poorly written because I wrote it myself and when I started I had very little knowledge on how to actually code properly but I can definitely say I have learnt a few things on the way. The code is working how I need it to now and once I put it into its application, there probably, well hopefully won't be any changes or additions to it. I even designed the case for the electronics without an easy way to connect the USB cable to the arduino to put me off changing anything as I would need to take all the electronics out. I do hope that one day I do come back to it after I have learnt a lot more about coding so that I can re-write the whole code a lot better. Also by the way this is like the 3rd time I have written this code because as I got to the end of writing it I would want to add something to it but not this time!! To tell you the truth my first code for this project was a lot simpler but ended up being like 2000 lines long because of how poorly it was written so I can definitely say I have gotten i bit better as this more complicated code has only turned out to be a 4th as long. Thanks for all your help
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.