Using Arduino to Control Motors to Create Music

We need help! My partner and I want to create music using Arduino code to control motors, which will be attached to guitar strings. Building it is easy, but we have no idea how to work the code, or even where to start with the code. Help?

We need help! My partner and I want to create music using Arduino code to control motors, which will be attached to guitar strings.


Building it is easy,

It is? I take it you already have the hardware developed and interfaced to your Arduino?

but we have no idea how to work the code, or even where to start with the code. Help?

Neither do "we", considering we don't even have a schematic or even an idea of what this instrument(s) is supposed to look like or do.

I have a strong suspicion that you are looking for someone to somehow magically create code for you out of the blue sky; you're going to be sorely disappointed.

How about this: Get your Arduino, get a kit of parts to interface and a breadboard, and take a look at the example code and the vast wealth of code here in these forums and the playground. Play around with it, get a feel for what does what, then come back to us once you have done that and built your hardware (along with a schematic of how it is connected to the Arduino).

Also - in the future, when starting a project, you might want to find out what it takes, and if the skills are outside of your skillset, study up on them, and learn them from the plethora of sources on the internet, in libraries, at school, etc. You are sounding like you want something to be handed to you pre-done; most of us here have done a lifetime or more of hacking and figuring things out for ourselves - some of us here have been around longer than the personal computer.

Lastly - read this:


No need to be rude.

Think of a rectangle, 6 motors in a line, guitar strings attached to the motors. We want to create a song by controlling when motors will turn on or off. We're using a breadboard and motors hooked up to several transistor circuits. We are lost with the code, hence the question of help. This is for a college project, and we have been working all semester with these materials.

Please, reconsider responding if you are only going to insult us.

Yet you still refuse to post a schematic?

For instance, I could write all kinds of code to control a motor hooked up to an Arduino, but without knowing which pins are to be connected, whether PWM control is needed, etc - I would be shooting in the dark.

Please - post your schematic, and any code you have already written. You are insulting our intelligence if you think you'll get an answer otherwise...

BTW - you’re also telling us that you’ve googled “Arduino”, “microcontroller”, “motor”, “control”, “transistor”, “interface”, etc - those terms and others, yet have not found any examples or ideas to try? Seriously? Given the tons of other similar applications, robotics, CNC machines, etc - driven by the Arduino and other microcontrollers - I find that very difficult to believe…

Tip 1: upload a photo of the hardware, so we got an idea what you are talking about

Tip 2: do you have specs of the motors used; Arduino can control them but you probably need additional power.

Tip 3: Search this forum for other "motor"questions to learn from them, other peoples problems are often quite similar. Motor, Motorshield or servo are good keywords to start with.

Tip 4: I think crOsh did not (mean to) insult you, he tried to explain that coding an Arduino is best learned by doing, experimenting, and if you are unfamiliar with Arduino or electronics, start with simple experiments see That will take some time, but itis time well spend. If you're stuck, questions here will provide answers

Hopes this helps, Rob

code to control motors, which will be attached to guitar strings

If the motors are attached to the strings, are the motors going to stretch the strings? or just strum them? Can you post a photo?

First thing to do is state the type of motors you have and how you need them to operate. Several different types of motors get discussed in the forum.

One word. Pictures. They are worth a thousand. Words that is. Just to be clear.

I think the OP has gone away, the sensitive soul.

I think the OP has gone away, the sensitive soul.

Can't understand why he would be upset being the center of the usual forum newbe feeding frenzy and beat down. ;)

Ya, I was going to mention something last night about what a "tight ship" some of the established members run around here but decided not to. Guess I have one too many drinks in me tonight though. :p

I helped found a forum that went through some growing pangs like this but eventually grew out of it. It's tough when you're answering the same question for the 1027th time and the person a) didn't search first and b) didn't provide all the info you need. But you have to remember everyone has to start off somewhere and learn. This includes not only what they are researching but also how to communicate on a forum.

didn't provide all the info you need.

It's not that, we can always ask, and we do; it is the hopelessly vague ambiguous requests like this one that attracts some derisive comments. Genuine beginners get treated with respect, it is just those that come across as chancres, no hopers, stupidly over ambitious, or people trying to get you to do their assignments that attracts the ire.

fair enough. I think I understand.

Just to chime in... (Am I tossing another log on this fire?)

where to start with the code

This a basic problem that the Arduino "solution" itself creates. One might research or talk to a friend who says... " the Arduino would be great for that!" and then the "uninitiated" wants to just jump in and work on their SUPER project right away... without learning how the Arduino works and how sketches are written.

I've seen this same issue countless times and it is not limited to Arduino by any means. For example, I taught myself how to create 3D Models for simulators a few years back and it was hard work. I did try to create ultimate project right away... but quickly learned I didn't know enough. I had to try a lot of small projects before I was able to create the 3D Model I really wanted to see created.

This same thing applies to Arduino. There is also a good chance that nobody has some off the shelf code ready to pass out to someone who says "hey I need a...".

My advice... Look at all of the information on the Arduino web site. references.. playground, etc. Create some small projects and learn some basic concepts. Then the "not knowing where to start" problem will be replaced by "I bet I could add something cool to my project like an LCD or midi interface".

You don't build a skyscraper by starting with the restaurant at the top.

You don't build a skyscraper by starting with the restaurant at the top.

Something tells me that a lot skyscrapers start this way, though...


Yes this does help.

However it brings a whole host of questions. The first in my mind is that if the string is rotating there is a need for a gimbal at one end and that the thrust loading on the motor's bearings is going to be incredibly high.

Yes blink without delay is the way to go. You need an array that holds the state of each motor at each step time and you just cycle through that starting and stopping the motors as directed by the array.

How would you propose we hold the motors down? Will hot glue be enough?

I'd think you'd need something stronger than that. Best would be some type of bracket or motor mount made for the job. But I'm guessing you're using some random motors you found. Quick and dirty I'd go with plumbers tape. (Actually not tape at all. It's metal strip with holes in it.) Comes in very handy sometimes.

Or maybe a piece of wood with a pocket routed out that would fit the housing and a hole in the middle where the shaft would stick through.