Hello, everyone! This forum has been extremely interesting, so much that I finally decided to get my Arduino and start learning. After creating some very basic projects, I now want to tackle a larger one, and I’d like some help understand some concepts and best approaches.
I’m building a model that will have some electronic components. These components can be grouped into 4 “circuits”:
- 30 orange LEDs.
- 30 blue LEDs.
- 4 motors.
- 1 servomotor that needs to be able to rotate 90 degrees clockwise or 90 degrees counterclockwise from a starting position.
I’ve hooked each of these components independently and written the code, and everything works as I expect, but now I have no clue on how to consolidate them. My expected behavior for the whole thing is:
- When a master, manual switch if off, nothing happens. When it’s manually turned on:
-All orange LEDs turn on for a second, then turn off for a second.
-All blue LEDs do the same, but alternating with the orange ones (they’re on while the orange ones are off)
-The 4 motors run constantly (until the master switch is off)
-The servomotor turns 90 degrees CW, waits 3 seconds, then turns 90 degrees CCW, then repeats.
I can write the code for everything, but have a few questions (apologies if these are quite basic):
- I know each color group of LEDs needs to be connected in parallel to avoid requiring an insane amount of Volts, and I know how to calculate the resistor each LED will need. But, how do I control them from a single pin from the arduino (while keeping them powered externally from a supply with sufficient Amps to power them all) without ruining mu arduino?
- How do I connect the 4 motors (also in parallel to each other, and in parallel to the LEDs) to the same power supply? These don’t really need to be connected to the arduino as they’ll run constantly as long as the master manual switch is on.
- How do I connect the servomotor to the arduino for control while also being powered externally, from the same single power supply as the rest of things?
- Finally, is it okay to also power the arduino from the same external power supply?
The ideal end result is a single house plug adapter of some sorts that powers all the circuits and the arduino itself whenever a master switch is manually toggled on, and everything turns off when the switch is off.
Any help would be massively appreciated, and if you consider yourself an expert and are up to teaching me in details, I’d be happy to arrange for an online consultation.
Thanks, all!