I searched the built-in library and Google. Everything I found is more complicated than I need. I am just trying to build the circuit to control the motor. I am also trying to understand the code. I have zero programming experience and am totally lost. Thanks for any help.
cantlearn:
I have zero programming experience and am totally lost.
Welcome...
In my opinion, before you can embark on any project (ie your motors / joystick / h-bridge) you need to start with the basics. There's a range of examples here, and the code for them is in the IDE at File > Examples.
("cantlearn" is a pretty negative forum name. Change it to "willlearn" or something positive )
I am starting with the basics. As mentioned, I already searched there. Everything I find is way beyond what I am trying to do. The built-in library does not address what I am trying to do. (or at least come close so I can interpolate something myself)
I am ok with "figuring it out myself" But examples I am finding are way beyond this basic project.
The built-in library does not address what I am trying to do. (or at least come close so I can interpolate something myself)
Not sure what you meant by "built-in library", but I suppose you mean the examples?
How about the very first one, AnalogReadSerial, which reads a potentiometer. Your joystick will almost certainly be two joysticks at right angles. So get one working like the example, then add the other one to give both values.
Then how about AnalogInOutSerial where you can extend that to control the brightness of 2 leds?
Then take the leds out and put that pwm into your h-bridge. You don't say which h-bridge you have, so if you need specifics on the connections and can't find a datasheet and/or example, ask.
I don't know what you mean..Which h-bridge do I have? None yet since I am still trying to figure this out. Is that what you meant? I am using the Uno R3 kit and am trying to use the L293D. Still not sure if I understand you.
cantlearn:
I don't know what you mean..Which h-bridge do I have? None yet since I am still trying to figure this out. Is that what you meant? I am using the Uno R3 kit and am trying to use the L293D. Still not sure if I understand you.
Well there are a zillion different h-bridges, from various manufacturers, and with various capabilitis and connections. L293 is just one of those zillion and it's pretty simple and examples abound.
But imo, put that aside for while and get your joystick (or at least one axis of your joystick) to output its value and then fade an led.
One step at a time....
I'm only marginally more advanced than you, and recently did build a motor H-bridge joystick project.
Mine is a differential drive two-wheel vehicle that was connected to a joystick via a long wire (so directly), and had an H-bridge that I made on a breadboard using very unnecessarily powerful transistors from radio-shack that cost way too much for the projects needs.
differential drive, if you don't know, (you want it I would guess), is when the robot is able to continue moving forward, and turn by changing the speed of the wheels so that one is faster than the other one. (most simple robots just turn one wheel backward and one forward, but I strongly support the desire to move straight into turning while moving).
Do the examples exactly as described at first, and then try to adopt some parts of it into your other code. actually someone else will tell you don't bother, but it is the best way to make sure you know that your hardware will actually work, and let you see it working, so that you can be sure that your trouble is in your code.
The PWM is exactly the same for fading leds and controlling motors, which is why the LED experiments are so good for so many tests. I like the adafruit examples,, also check out "How to mechatronix" , also check out educ8.cs, also definately check out any examples made by the top posters,, some of them have examples that are VERY thorough little pieces of education, even though the arduino examples are clearly designed for use by persons with engineering backgrounds, and do not address the obvious questions and examples desired by the common beginner hobbyist. (I suppose they chose to keep their pages minimal rather than follow proper complete introductions, which are actually quite difficult to produce,, in hopes that the forums and enthusiasts would be able to fill that need).
tsmspace:
The PWM is exactly the same for fading leds and controlling motors
THAT is a really good point: thanks for pointing that out.
Not only pwm-ing an LED, but simply turning it on and off are skills easily transferable to the world of motors. Most drivers, L293 included, need off/on or on/off combinations of pins for direction, and off-ing and on-ing a chip's inputs is no different from doing that to an led.
Although there are very limited number of things you can do with an Arduino pin...
- digitalWrite(pin, HIGH);
- digitalWrite(pin, LOW);
- analogWrite(pin, someValueOrOther);
- analogRead(pin);
... with those 4 capabilities you can do ..... eveything.
cantlearn:
Everything I find is way beyond what I am trying to do.
That does not really convey any useful information that can form a basis for helping you. Can you identify something that you think would be useful and then post a link to it and tell us what it is that you don't understand.
My feeling is that you need to get over the hump of "everything is too complex" in order to start making progress. And that requires working on something specific that we can help you with.
The built-in library does not address what I am trying to do. (or at least come close so I can interpolate something myself)
Again, that is not a useful comment. There are many built-in libraries. Which one do you mean?
And if (as in the first piece I quoted) you are still struggling to understand then maybe you do not appreciate that some library may be close to what you want.
To break things down to a very simple level ...
- You use a joystick to input a number to the Arduino.
- You use a number stored in the Arduino to determine the PWM duty cycle to set the motor speed.
There are examples in the Arduino IDE that illustrate both of those.
...R