How to add simple Servo code from a Tutorial?

I'm done! GIF of my project below. Many thanks to Chris and the community for help here. I'm glad to join the Arduino world.

If any Arduino-veterans here would like to share info on the power questions, please do:

  • Is the power out of a PIN also 5v, and if so, why use the 5v slot?
  • Is 220 Ohms enough resistance for a given circuit, or do you really need 250?
  • Does the recommended max current through a port of 20mA (or 40 mA, as suggested in some threads) apply only to the PIN slots or to the 5v port as well?

In any case, here's an image of where I finished. It's not R2-D2, but it's a first step in to a larger world.

dangerous art box2

1 Like

Your Uno will provide 5V on digital output pins, but they can't manage much current- they're for controlling things, not powering them.

The 5V pin can provide a bit more power, but not much. As soon as your project involves motors or servos, you need an external power supply.

Sadly, you will find many many tutorials that try to power things from the Arduino. It's a sign that you should close that browser tab.

1 Like

Yes, you can place the appropriate resistors to reduce the volume.
But, the place of connecting the resistors in the image is incorrect.
Must be placed in series with the speakers.
It can also be adjusted using a potentiometer.
However, it must require lower current flow that can be passed safe as described above.

It is better to think of what is output from the PIN as a "signal" rather than a "power".
"Power" is output from 5V, but it is not very powerful either.
Please think the power output of the 5V pin is;
About 400mA when connected to a USB port
About 100mA when connected to a barrel jack

Calculated from Ohm's law, if the resistance of the circuit is 220Ω, the current is limited to about 23mA, so not a problem.
The 20mA I mentioned earlier is due to the value including the safety margin.

Applies to PIN. For 5V, follow the conditions described above.
But, there is one misunderstanding.
Current limiting means passing, not output.
In other words, if 100mA is output from the 5V pin to the load and the wiring on the opposite side of the load is a PIN, so 100mA will pass through the PIN.
This is not output 100mA from the PIN, but it is passing 100mA and destroys the internal circuitry of the PIN.


Exactly.

1 Like

The Mimic got life from you, and dragged-in you into the world of Arduino as his first job. :wink:

1 Like

Ok, got it, along with the other points about resistance and signal/power. Thanks.

That makes sense. I'm assuming the power draw of LEDs (and small speakers?) is low enough to be an exception - is that right?

It is a Mimic, and you saw that before I did!

I had no idea! Sounds like I should keep an eye out for a simple project using external power for a motor while using an Arduino for control. I'll see what I can find.

For any other beginners coming here, here's the condensed version of what I learned from this thread and this project:

  • User-made Libraries can have compatibility problems with other Libraries. See Posts 10 and 34.
  • Documentation for user Libraries isn't in the 'Read Me' file but rather in the '.h' file, which can give info about the various definitions used. See Posts 4 and 16.
  • Be careful following old Arduino projects as models. Newer ones can contain errors, too, but some old code is now obviated. See Posts 21, 24, and 34.
  • Other people's Arduino projects can contain errors not just in the code, but even in the circuitry. I figured anyone who drew a schematic or a Tinkercard diagram must know what they're doing, but that's not necessarily so.
  • Writing your own instructions in C++ is fun and not nearly as hard as I feared.
  • You can go through all the Tutorials in the Arduino Starter Kit and still have a lot to learn about even basic projects. It's a big open-source world out there.
2 Likes

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.