I havea drok motor controller, a 4x triple a battery holder and an Arduino nano clone compatible with Arduino. last time I asked for help I was given sone very not helpful answers and hope to remedy that by not being as clear about what I want to do and hope that helps. firstly I understand how to wire things up. but only outside of Arduino. ive never messed with Arduino before and I'm taking on a project centered on it. I need help figuring out how to control a motor, to make it go forward. stop once it detects light on a photoresistor and if possible go in reverse if it a motor gets caught in a bind or is under too much pressure(current spikes maybe) any helpis appreciated. please do not ask me to build or do the hardware first or for a schematic to understand the hardware. I need to understand how to do this before I can design the rest.
and hope to remedy that by not being as clear about what I want to do and hope that helps.
Having fuzzy requirements is NOT how to get help.
I need help figuring out how to control a motor
The Arduino can not control a motor. What it CAN do is control a motor driver board/chip/circuit. Without knowing what shield/board.chip/circuit you are using, we can't help with the code.
and if possible go in reverse if it a motor gets caught in a bind or is under too much pressure(current spikes maybe)
What is your shield/board/chip/circuit able to tell the Arduino about the amount of current being used?
I need to understand how to do this before I can design the rest.
No, you don't.
I understand the need for an h bridge capable motor controller, I understand overloading the pin with the higher draw current. And your not realizing I'm not asking how to build my project. I'm asking for help understanding how to use arduino as I'm completely new to it, and yes I do need to understand this first. My project Is very limited in size, so I need to understand this before I go any further into designing it. i understand the needbfor pwm, and im fuzzy on what it is exactly and even fuzzier on how it works. And I'm going to be vague about what my ultimate goal is because everyone last time went way out in left field when I tried to be specific
https://www.amazon.com/dp/B00CAG6GX2/ref=cm_sw_r_other_awd_2NxexbNF1Z396 this is my motor controller. And Paul I see you have over 60k posts, And you deal with clueless people quite a bit, but I'm fairly certain I posted this in a programming section of the forum and not a help me build my project section
im fuzzy on what it is exactly
It is a process for turning a pin on and off, rapidly, so that it appears, to some devices, like motors, that the pin is outputting less than 5V.
and even fuzzier on how it works.
Fortunately, you don't need to understand how it works to observe that it does, indeed, work. Do you know how your television works?
I understand more how my television works than I do how to use arduino or pwm. I jumped to arduino because I'm fairly knowledgeable and an electrician and I like to learn new things but I can't learn it by myself which is why I came here asking for help
I don't understand what exactly you want help with. What is the actual question? Is it how does PWM work? Paul just tried to explain that. Google it. It's covered in depth in numerous tutorials much better than someone could write in one forum post.
This adafruit tutorial on photocells may help.
Then have a look at this one, which uses a pot to fade an LED. Mentally replace the pot with your photocell, and the LED with the control line to your motor controller.
This pic shows PWM output from an Uno. Check here for details, and you'll see various pins use diferent PWM frequencies but that doesn't matter right now. Point is, that PWM is as explained above, a rapid switching between 0V and 5V to give the illusion of say 2V or 3V or 4V or whatever, depending on the relative on-time. Both those traces are with a duty cycle of 128/255, so 50%, thus a notional voltage of 2.5.
these posts might be great if I understood Arduino. what I'm saying is I need help, point me in the right direction. it may seem like common knowledge of how to write for Arduino, but for me itt is not. I came to the forum because I was told it was the best place. but so far either I'm not making it clear or nobody is reading the first post. I have this motor controller. I'm familiar with the parts of circuits, ive been into electronics for years, I'm also into computers. I know how motors work, I'm familiar with how photoresistors work(but your link was nice and gave me a good reference page for a few things I didn't know. I understand the need of pwm. what I don't know is how Arduino can control it, or rather how to do it. I don't know how to connect my motor controller to Arduino, I don't know how to command the motor controller, though I do know that it has to be connected to a pwm capable pin. I don't understand the difference in digital and analog pins on the board. I don't know how to start my own code, I have played with the blinking code several times. have tried manipulating it actually. ive ran basic servo sweep out of the library? and toyed with that code a little. but I still feel way over my head.
so far either I'm not making it clear or nobody is reading the first post.
You can be certain that it is you not making "it" clear.
The analogWrite() function is super-simple to use. TRY IT!
If it is still too complicated, look at the examples. Though I can not see why you would need to.
I don't know how to connect my motor controller to Arduino
Duct tape. Since you have refused to tell us what motor controller you are using, and since you claim to be an expert, it should be a no-brainer for you to connect it properly.
though I do know that it has to be connected to a pwm capable pin
The speed control pin does. The direction control pin does not. The power pin does not. The ground pin does not.
I don't understand the difference in digital and analog pins on the board.
Analog pins are input. If you want to measure an analog signal, use an analog pin.
Digital pins are input or output, and are used to read or create digital signals.
I get that you feel in over your head. We can't tell you everything about arduino all at once in a forum post. If you have a specific question then ask it. If you just need a better understanding of arduino then use google and find one of the thousands of great tutorials. But we can't help you understand anything if all you do is bitch about how you don't understand but never say exactly what you don't understand or what you want to know.
i actually did link to my motor controller, but i was on a mobile phone at the time and looking back i can see it didn't post.
thank you paul for your smart ass. though i never claimed to be an expert, i really appreciate you clarifying that the pwm needs to be hooked up to the speed control. and i really appreciate that i now know your either just unnecessarily sarcastic and rude, or your just being an ass to me, either way thank you. as for your duct tape suggestion, that was completely pointless and not helpful at all but i hope it made you feel better.
delta, thank you for seeming to actually understand i feel overwhelmed, the thing is i have a slight add that makes it difficult to transfer what i read in what ive been told are great books i have and the google search results. which is why i was asking for human help. what I'm asking for though is probably basic knowledge to you. i have a motor, i figured out how to hook it up and manipulate a sketch i found online to change the speed using a different value on the pwm pin.
1.)how do i go about using the photocell to control it?
2.)can the pwm go over 255?
3.)is it better to change both pins to high or to low in order to stop the motor
4.)will i need to set up 3 pins on board for every motor i have or can i combine the pwm signals to make all motors operate at the same speed?
5.) are there any differences in the analog pins as there are the digital pins?
6.) would it be easier to use a switch instead of a photocell? (i read somewhere that interference can be a problem, and in my experience smaller leads are more succeptable to it.)
7.) would two 18650 li-ion batteries wired in series be too much for the nano or is it able to adjust as the uno can?
i really am trying to relay what I'm having trouble with but like i said earlier my add sometimes gets in the way especially with new things and this is really my first forum to join.
by the way thi motor shield i have is a DROK L298N Arduino Motor Shield Controller, i was toldit was a goodone at a wallet friendly price and i wasn't very likely to burn out anything with it.
and i apologize if i sounded like i was "bitch"ing but i didn't know how to explain or understand what i didn't understand. but i do thank you for any help.
OK, Now that you have questions you can get answers.
- Check out reply #7 and the links in it.
- No
- I don't think it matters
- If all motors will run the same speed then you should be able to use the same PWM signal for them.
- What do you mean? The analog pins are for reading analog signals and the digital pins are for digital signals. Google those two terms if you don't know what they mean, the definitions are pretty straight forward. The analog input pins on Arduino can also be used as digital input / output pins the same as any other pin. The analog function is like an extra add-on for those pins.
- I don't understand the question. Can you expand? What do you want it to do?
- I don't know about those batteries. As long as they are putting out a voltage that is acceptable to Arduino then they are fine.
Ok so let's go from there
6.) This project may occasionally be put into a metal pipe.And I've been told interference can be a problem,and started to experience it a little when trying out the knob control servo sketch. When my hand would get close to the leads Between the pot and the board it started to behave erratically while still trying yup follow the pot
And
7.) The 18650 is a li-on cell rated Sat 3.6-3.7 volts usually. It's very common in laptop batteries And power tool batteries, also I believe was popular among the "vapes" that people have been using
So it might get some interference in a pipe? I have absolutely ZERO idea what the thing is, what you want the photocell to do, how it is to be controlled, or anything else about this project other than the fact that you feel like you're in over your head. So there's not much advice I can give you on that.
I would recommend taking smaller bites. That usually helps you build understanding. Get a motor hooked up and make it run. Learn how that works until you figure out how you can make a motor do whatever you want. Get your photo resistor hooked up by itself and see if you can get readings from it. Think about how you might use those numbers in the motor program. For every complex project I've ever done that had multiple parts I've had ten or twenty little sub projects that came first that didn't do anything useful at all aside from acting as a test bed to learn how to use one piece or another.
Alright then I will play with it here in a bit, and see if I can figure out what I'm still puzzled about thanks delta