I am trying out a simple project as a learning tool to help me develop something more complicated in the future and have been greatly successful on my own thus far arriving at a halting point in the final stage of the prototype.
The design is quite simple: an Uno R3 and a L298n to operate a small 3v dc motor , i've programmed a servo motor to operate 245 degrees just prior to the 3v dc motor turning on, and this is all delay activated by a limit switch, so...
when the limit switch is released a 2 second delay before the servo operates, then another 2 second delay before the 3v motor engages, a 2 second delay and the dc motor shuts off and 2 seconds later the servo returns to zero degrees.
i am powering the L 298n using 8 AA batteries for 12volts, & using the arduino to power the servo thru a bread board and a 220uF capacitor.
While plugged into any AC outlet the project prototype operates exactly as desired, however when i attempt to power the arduino with a 9v battery, the servo does not respond as coded and the dc motor does not engage at all...
I would appreciate any help or feedback the group has to offer..
I am powering the L298n with the 8AA to drive the DC motor; and the 9v to power the arduino. I am using jumper wires to connect to bread board the 5v and ground respectivly to the 220uF capacitor, and then to the servo.
Ive tried powering the servo directly with 9v thru the capacitor in which case the servo spins 360 continuously
If your sketch was generated with AI like ChatGPT or by someone else tell us at the beginning of your post.
Questioners know what their hardware and software looks like but the volunteers here do not. You need to fully explain what’s not working, and how it is supposed to work.
Before asking your questions, please read all the posting guidelines, follow these guidelines when you post your questions.
Hardware
As always, show us a good schematic of your proposed circuit. Hand drawn schematics are acceptable.
We use schematics as a language to communicate hardware design.
Show us several good image views of your actual wiring.
Give WEB links to your major components.
Software
For readability, place { and } on separate lines by themselves, place each line of code on a separate line.
In the Arduino IDE, use CtrlT or CMDT to format your code, then copy the complete sketch.
Use the < CODE / > icon from the ‘posting menu’ to attach your copied sketch.
When you follow the posting guidelines, volunteers can be more effective.
When we have a schematic we can speak the schematic language in helping you.
More volunteers will help if you properly post your questions.
Then it is not a servo, you cannot control its angle only its speed and direction of rotation and powering it with 9V may well have damaged it depending on its specification
How did you do that ?
Please post your sketch, using code tags when you do
In my experience the easiest way to tidy up the code and add the code tags is as follows
Start by tidying up your code by using Tools/Auto Format in the IDE to make it easier to read. Then use Edit/Copy for Forum and paste what was copied in a new reply. Code tags will have been added to the code to make it easy to read in the forum thus making it easier to provide help.
Please note that in the schematic I am unable to use an L298n only the L293 _ Ive used the pinout on the 293 as I would have for the L298n - other than that it is exactly the diagram ive created.
I was unable to correctly show how I power the Arduino with the 9 volt battery, it is a 9v adapter that plugs into the AC power jack on the arduino board itself.
The servo is a MG90S which i understood to be a 360 servo motor;
to clarify - if i plug the arduino into the wall and power the L298nn motor driver with the 18v from the AA batteries while powering the servo motor from the breadboard that i have connected to the 5v pin on the arduino - EVERYTHING WORKS with the code ive previously attached. The servo waits , then opens 245 degrees, then the dc motor begins to spin for a few seconds before shutting off the the servo reverses from 245 degrees back to zero.
The issue is when i try to power the arduino board with a 9v and the appropriate plug , the servo operates, but does not wait, and before the dc motor turns on the servo reverses its direction.
When I try to power the servo motor in this way, upon recieving the signal it turns on and rotates continuously in one direction 360 with out stopping or reversing.