So!
Now I have the code attached here. ![]()
So a short description of...
... WHAT IT CAN DO AS RIGHT NOW:
It has a motor with a rotary encoder. Its connected via a H-bridge.
The motor can run UP and DOWN when pressing button 1 or button 2.
Button 3 can save an position from the rotary encoder, so that when passing by it pauses/stops there when passing by.
Button 4 removes this position.
Button 5 and 6, plays a little melody. No function really, and just for test.
It has also a couple of IR sensors connected that stops the motor from going too far up or down, and one third sensor that can be placed anywhere one want to.
I have a I2C 2x16 LCD display connected to it, so I can view the pulses from the rotary encoder, and se short messages like "Going up" or "Saving position".
... AND WHAT I WANT IT MORE TO DO:
Right now, if I restart the machine it forgets where the motor is positioned last time. It starts at 0 (zero) everytime even though I turned it off at positionpulse for example 560. So the saved self-pause-position then is useless. And I have to re-save a new position everytime I have restarted the machine. I would want this machine to remember where the motor was when restarted. Ill guess I'll have to have some code that save the position everytime I press Up or Down button. But problem here is that I dont know how to create a "second" part in the memory where I can save this position. How to do? :o
Another annoying problem (and the cause for this threadstart) is that when I do save the position that I can save, it keeps looping at this part of the code. So it says "Users stop" and keep on adding the 1.5 sec delay. I can go out of this by keep Up or Down button pressed in for at least 1.5 sec, but it takes some time and is not very user friendly.
I would like this message, and the delay, only to be executed Once when pressing "Save position" and when its at the position where the position was saved.
I am a newbie, so pls forgive the codes eventual rudeness.
Test_61_-_Skicka.ino (16 KB)