Hello,
I am using 10rpm dc motor.i want to rotate the motor by some angle in upward direction and downward direction when i press two switches respectively.it means i want to rotate a dc motor in yaxis direction by using yplus and yminus switches.
I am using ARDUINO MEGA 2560 and L298 H-Bridge.
Please help me.
my code is as follow
How accurate you want to be - the movement won't be precise or fully
repeatable without some form of position feeback, but using duration to
control rotation with a large reduction gear train like this is roughly going
to work (if the load is even).
Have you looked at the BlinkWithoutDelay example yet?
hello,
When i will press yplus switch,mototo should move in yplus direction(say by 30 or 45 degrres).If I press Yminus switch.then motor should rotate in negative yaxis direction.and motor should ON only when i will press the switch
Have you got any feedback from the motor so you know how far it's turned? I see only 2 wires to the motor so seems there's no encoder of any sort, as MarkT has suggested you need. Don't see anything in the code that would read an encoder. I'm pretty sure the merest "blip of the throttle" so to speak, will send your motor off to do a few revs.
Is there a compelling reason to use a plain old DC motor for this?- might be better to consider a servo or a stepper.
hello,
i am using ardunio mega 2560,L298 H-bridge along with 12volt dc power supply to power up the dc motors.i want motor to rotate by 180 degree in automatic and manual mode..
I am using four switches,xauto,xmanual,xplus and xminus to rotate the dc motor in respective direction..xplus and xminus switches will be used for manual mode..
please help me out in writing a code.
vinsan:
code is executing but not entering into the loop
Not entering into loop() do you mean? I doubt it, and anyway how do you know?
I'd suggest you use serial prints in your code, in the various ifs and elses so you have evidence of the route the logic is taking through the code. Have it print simple text so you know where it is.
(In future it's muuuuuch easier if you put the code in your post in code tags: otherwise we have to bugger around with the IDE making folders and stuff. Much easier to just read the code in the post, and copy the code from the screen into the ide to compile if necessary.)
Making the motor move is one thing. There must be hundreds of Forum Threads about L298s.
Knowing when it has rotated 180 degrees is an altogether different matter. You will need some for of external sensor to detect the orientation of the shaft - probably a rotary encoder.
Robin2:
Knowing when it has rotated 180 degrees is an altogether different matter. You will need some for of external sensor to detect the orientation of the shaft - probably a rotary encoder.
And that's exactly the advice you were given in your other thread on the exact same subject, here, and which you didn't seem to like very much.