Drum Project beginner

I've been learning the basics of electricity and ardiuno all week and at this point I need to just try something to see how it works.
Basically I want to try and program a 20 kg servo so that when I press a button it will begin a timed sequence of drum or cymbol hits. I've got a carbon fibre shaft hooked up to the servo and I bought a cheap bench power supply. The servo draws up to 6.8 volts I think so after pondering a number of options I figured the cheapest and easiest option was to just by a cheap supply.

Im not trying to program the Arduino to listen to a song and hit a drum based on rules or anything. I just want to pick out a queue in the song where I will press the button and that will begin the sequence that I've pre-programmed. For instance it will wait 3000 milliseconds and then hit. Then wait another 3000 and hit, then rest for 20,000 milliseconds and hit. If I press the button a half second too late then everything will be a half second off etc.

I can already imagine a number of ways this will suck. Like the motor not performing at a reliable speed every time or the recoil of the arm and drumstick causing problems.
I still have to locate past tutorials to refresh my memory on how to program this. Hopefully the timing can be done in a way where each drum hit is timed from the original push of the button and not relative to the previous hit because I can see that getting more and more out of whack as time goes by.

First I just want to know if my innitial plan to hook up my power supply and servo is ok or if I'm missing something. This seems like it's too simply to be right and I don't want to ruin my ardiuno right out of the gate. lol

Your schematic looks right.

The connections are logically fine but I really wouldn't try to run the power to that big servo through a breadboard. Breadboards cannot take the high currents involved and will burn out. You need a more solid connection.

Steve

Hi;
You might need to look deeply at servo specs.
You need it to beat the drum, quick down and very fast rebound to let the drum resonate.

Most servos are not noted for speed but strength.
High strength does not necessarily mean high and responsive action.

You may need to use a solenoid driven device to beat the drum.
Have you written any code?

Tom... :slight_smile:

With the code I would start with the timer. Look at how you time things without delays. Just store a value in millis val =millis(); (This will be for when you push the button) then you need to work out all the timings in millis since this that you will want to activate the servo. Stick a serial.print in each if loop and it will print out at each time the drum is supposed to hit. Then code a function for activating the servo and put that into each loop in place of serial print. Look at buttons tutorials and add that for a complete sketch

Thanks, I haven't written any code yet other then to gather a few bits and pieces I think I might need.
I was going to keep it slow for now and only do beats that are at least a couple seconds apart.
These motors are fairly cheap and probably not very consistent so I'm not expecting great results but we'll see .
The specs are below. If the breadboard can't handle it should I solder it on a board?

I think I get what your saying about storing the milli values. Hopefully I can cobble together some code today.

Electrical Specification:
Idle current(at stopped):4mA(5V)/5mA(6.8V)
Operating speed (at no load):0.16 sec/60°(5V)/0.14sec/60°(6.8V)
Stall torque (at locked):18 kg-cm(5V)/21.5 kg-cm(6.8V)
Stall current (at locked):1.8A(5V)/2.2A(6.8V)

Control Specification:
Control System:PWM(Pulse width modification)
Pulse width range:500~2500μsec
Neutral position:1500μsec
Running degree:180°or 270°(when 500~2500μsec)
Dead band width:3 μsec
Operating frequency:50-330Hz
Rotating direction:Counterclockwise(when 500~2500 μsec)

You can use proper servo connectors or solder wires to a bit of perfboard/Veroboard or use any 0.1" pitch headers. Plenty of options, just not a breadboard for something that may draw up to 2A.

Steve

I went to the only store in town I figured would have perfboard and they were out. I picked up some terminal blocks but Im not sure if that'll work.

Not ideal as they're intended for much bigger wires. But they should do the job if you're careful with the connections. Where you need two wires connected twist them together and put the twisted wires in one side of a connector. That will probably give you the best chance of getting the screw to hold them tight enough. If not you'll just have to solder the wires together.

Steve

I got a little busy with other things but I'm back at it. I just wanted to clarify something.
If I wire my servo without the breadboard as suggested I can still use the breadboard for the switch or button right?
The button gets connected to the Arduino but it's only the ground that gets connected to the power supply ?

I keep forgetting about the button and can't seem to find a tutorial where someone is trying to code a servo to begin a routine at the push of a button and also using an external power supply.

That’s fine. The point is the button is not connected to the servo it is just an input to the arduino. Most buttons are connected with internal pull-ups activated and a connection to ground on the breadboard. Look at any button tutorial and in particular debounce tutorials without using delay. You don’t need tutorials for your exact situation. Each component stands alone. You have a button, and a servo and an arduino. Attach button to arduino and use tutorial to make the led at pin 13 do what you want. Change pin 13 for servoControlPin.

I find problem solving with LEDs much less stressful! Since everything is simply combos of I/O LEDs give a very good indication of what your code does

tbone23:
I keep forgetting about the button and can't seem to find a tutorial where someone is trying to code a servo to begin a routine at the push of a button and also using an external power supply.

This will be a good start.

https://create.arduino.cc/projecthub/akshayjoseph666/control-servo-motor-with-arduino-uno-and-pushbutton-18613f

google uno button servo

Tom... :slight_smile:

Thanks. I was actually wondering if LEDs could serve as test subjects for something like a servo.
Also I was wondering if I could use the state of the LED as the signal to the servo to run rather then the button. Press the button and the LED turns on. If the LED is on then the servo does its thing.

If I understand the code correctly in the link above it puts the servo arm to 0 and if you press the button it goes to 180 and then returns when you take your finger off? So it would be like a kick drum with a button instead of a pedal?

If that's correct then I just need to change it with code for using a pushbutton as a toggle switch as in this tutorial.

tbone23:
Thanks. I was actually wondering if LEDs could serve as test subjects for something like a servo.
Also I was wondering if I could use the state of the LED as the signal to the servo to run rather then the button. Press the button and the LED turns on. If the LED is on then the servo does its thing.

What do you think is the distinction here? The LED doesn't go on without the button being pressed so there's no practical difference between the LED being on and the button being pressed...is there?

OTOH if you just mean can the button both switch the LED on and cause the servo to move at the same time then yes it can. digitalWrite() to the LED and servo.write() to the servo.

It really would be a good idea to start trying some of this stuff by writing some code or at least modifying some you've found. It's a lot easier to help with code to look rather than just theoretical discussions.

Steve

I was just curious if it could be run that way since I probably don't want the servo to move right away. If I have some sort of a delay in the beginning at least I'll have a visual queue that it's running. The buttons that came with my Arduino are practically microscopic.

I was in the middle of wiring everything this morning when lightning storms started blowing so I've been waiting that out.

Learn with the button and led. The more complicated functions come later. Code the button and the led. Use millis rather than delays. Get it working. Once you have the arduino accepting an input (button) and creating code in response to the input (turning led on off) you can tack on anything you like. If you want a delay to start the servo just code the same way as you did for the button with millis. If you understand state machines after coding the button then the same can apply to the servo also. You just look up tutorials on servos, understand the operation and coding to control them, write a function for your servo and activate it in the same way as your led example. Complex stuff is just lots of simple stuff.