Can the ARDUINO NANO handle 64 potentiometers?

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
foreign volts.com and in my hand I am holding an Arduino Nano one of the cheapest arduinos you can get a few years ago I made a series of videos called midi for the Arduino that showed you how to hook up buttons and potentiometers to an Arduino Nano or Uno and make your own custom MIDI controller one of the questions I got asked a lot was how many controls can I hook up to this little guy and I didn't really have a good answer so in this video I am going to attempt to hook up 64 potentiometers to one little Arduino Nano now I don't know what's gonna happen but I think we'll either succeed or we will rip a hole in the fabric of space and time and the universe as we know it will come to an end either way it's going to be exciting so stay tuned all right so 64 potentiometers one Arduino Nano how we gonna do this now the first issue is just the sheer scope of this project so 64 potentiometers is a lot so if you've ever tried to breadboard with potentiometers you know it's always a little touchy you can kind of get potentiometers to fit in the breadboard but it's never perfect and then when you move them like they lose contact and you get weird glitches and you don't know whether your code is messing up or the potentiometers are loose so it's it's really hard to troubleshoot and also you got to think each potentiometer requires three wires and we're going to have 64 potentiometers so that's what 192 wires just to hook up the potentiometers I'm not even going to try to breadboard this so what we're going to do is we're going to design a custom circuit board and do this properly so here we are in kaikad and this is my design for this circuit so I called it the lotto pots because there's Lotso pots in this project and here is the schematic now the first question you may have is doesn't the Arduino Nano only have six analog inputs how are we going to connect 64 pots to six input well we're going to use a very cool chip called a multiplexer and here they are here these Yellow Boxes and you can see each multiplexer will handle 16 plots so to get all 64 I need four multiplexers I have a detailed video on multiplexers so if you want to learn more you can watch that but I'll give you the overview so here is our multiplexer chip we're using the 74hc 4067 now a multiplexer is a chip with multiple inputs and one output the output is labeled com and here are all my inputs and we have 16 in total on this chip so the basic concept with multiplexers is we have four selector pins and here they are right here and we're going to hook those to digital inputs on the Arduino Now by sending different different combinations of logic signals to these four pins I can select which of these inputs will be connected to this output so if I make them all zero then this first input will be connected to the output and if I make one of them a one then the next input and so on so our program is basically going to change these pins to cycle through all of these inputs and then all we have to do is read the output and we'll be able to read all 16 potentiometers with one Arduino input to make this chip work we need to add power so I'm adding 5 volts from the Arduino power supply I'm also connecting it to ground we also have this enable pin which is very important so if I tie this enable pin to ground it's going to enable a chip if I tie it to 5 volts it will disable the chip so all these pins will be broken out to little connectors on the edge of the board and if I jump these two pins together I will enable able to Chip and if I jump the other two pins together I will disable the pin I could also control the enabled directly if I connect it to an Arduino digital output now if you notice here this will be four pins on the edge of my board and all the multiplexers selector pins will be tied to these same four pins so that way I only need four pins on my Arduino to control all of these multiplexers if you notice with this Bank I've also included some direct outputs connected to the wiper of each potentiometer in case I want to use them without the multiplexer finally we're going to add power and ground and that's the entire circuit so here is the board I came up with notice I have grouped the pots into groups of 16 with the multiplexer right next to it and all the inputs and outputs I've tried to keep to the upper edge of the board and if we go to the 3D view we can see the board in all its Glory three and through the magic of video editing Boom the board is done and soldered here are all the potentiometers the multiplexers and the pins on the top with the little header jumpers to enable and disable the multiplexers now there is one major flaw with this board and uh I don't know if you can see it but these potentiometers are not designed to have a knob on top they are actually knurled and they have a pointer molded in but if you notice the pointers are all pointed down which is not good they should be pointed up the reason that happened is I used a similar model to this and it was designed to have a knob and when I put the knob on the knob pointed this way so I assumed that these guys would be the same so I oriented them in this way but apparently they are not they are the opposite luckily for us this won't affect the way the circuit Works in any way it's just kind of a little annoyance also notice I've got some standoffs here so when I put it on the bench it's not going to Short Circuit so here's one more thing about this board I chose 100K potentiometers for this project now if you read more most Arduino sites they will suggest you use 10K potentiometers why did I go with 100K to answer that question we have to talk about parallel resistances and how much current that this project will draw now if you take a look at our schematic notice that each potentiometer has one side connected to 5 volts and the other side connected to ground and then we have our wiper going to our multiplexer pins now if we just forget about the the wiper pin for a second basically what we have is a bunch of 100K resistors between 5 volts and ground so if I draw that out we basically have our plus 5 volts and our ground and then we have all our potentiometers connected in parallel all 64 of them so if you're brand new to electronics you may not know the difference between resistors in series and resistors in parallel so let's do a quick demonstration so here we see two resistors in series and we know they're in series because one follows the other and current has to go through both resistors now these two resistors are in parallel because the current could either go through this one or it could go through this one so there's two branches for the current to flow in now if we picture our circuit to be a highway and here's a nice two-lane Highway cars are zipping along as fast as they can go now all of a sudden a car comes along oh it's out of control going too fast it crashes boom there we go now you know what's going to happen we're blocking one of the lanes so it's going to be harder for traffic to flow and we're going to get a huge traffic back up and you're going to be late for work so this accident scene is resisting the flow of traffic and if we added another accident in series say a truck comes along and it flips over and it's filled with chickens and the chickens are running all over the highway well it's going to make it even harder so the more accidents you add in series The more resistance to traffic flow there will be now what happens if we add a resistor in parallel well what we're basically doing is we're adding a new path for traffic to flow and that's like adding a new Lane to our Highway and you can see as I add this new Lane it opens up the highway more space for traffic to flow the traffic will go faster so the basic concept receptors resistors in series add more resistance to the Circuit whereas resistors in parallel decrease the resistance in the circuit so as you can see all of our 64 resistors will be in parallel which will decrease the overall resistance so let's try to figure out how much current all these potentiometers will draw so to figure out the current draw of our circuit we're going to use Ohm's law so the formula for current draw which is I it will equal the voltage divided by the resistance so we know the voltage already it's 5 volts but we need to figure out what the resistance of all these potentiometers in parallel is now if our resistors were in series let's say they were 10K ohms each it would be very simple all you have to do is add them together so 10K plus 10K would give me equivalent of 20 K so for parallel resistors it's not that simple so how do we figure out the total of all these guys series resistors is just R1 plus R2 and so on equals our total for parallel resistors we're not going to add the resistance we're going to add the opposite of resistance we're going to add something called the conductance so to turn a resistance into a conductance all we have to do is take the inverse so we put it under 1. so to add up our conductances we'll just take our resistance value take the inverse and then we'll add the next resistor and so on and that will give us our conductance so it's kind of confusing to describe so let me just do it and you'll see how easy it is all right so let's take our handy Microsoft Windows standard calculator and let's figure out our total resistance so like I said I have 64 100K resistors in parallel so let's take 100K which is 100 000 ohms first we need to figure out the conductance value of this and all we have to do is hit this one over x button and that will take the inverse of that number and there is our conductance value now we could add that number 64 times and get our total but since it's all the same resistors let's just multiply it so I'll take my conductance and I'll multiply it by 64. and that is our total conductance of the circuit now once again I need to find out the resistance so how do I turn that conductance back into resistance well I just inverted Again by hitting 1 over X and there you go there is the total resistance of 64 100K resistors in parallel 1562.5 ohms or you could think of it as 1.5 kilo ohms so now that we know our total resistance we can do our Ohm's law and like I said current equals voltage divided by resistance so let's put that into memory now if we take our 5 volts and we divide it by our total resistance that is our current draw so .0032 amps or you could think of it as 3.2 milliamps now why is that important if you think about it if I use 10K pots for this project that would be 10 times higher current draw so instead we would get 32 milliamps of current draw so one thing to keep in mind is that the Arduino Nano's power supply can only put out 200 milliamps at maximum so 32 milliamps is quite a big chunk of that total so if we can get it down to 3.2 milliamps that's much better and that is why I went with the 100K pots for this project all right everyone we have done the science we have done the engineering we have done the hard work to get to this point and now it's time to put it to the test to find out if this project is going to work or not can you feel the excitement I sure can all right the first step is we got to get the code ready and put it on the micro controller so let's do that so this MIDI controller program is something I made many years ago and it's just kind of a configurable program that allows you to easily you know make up a combinations of buttons and potentiometers and make your own MIDI controller so the first thing to run this program you got to make sure you got three tabs at the top and you have to make sure you have the Arduino midi Library installed and if you don't have it you just need to go to manage libraries and you want to scroll down until you find midi Library by Francois Bess and make sure you just have it installed okay so once you got all your libraries installed we can configure the program so the way this works is you just have to fill in some parameters so first of all we have to tell the program how many controls we have connected so we have a few categories we have buttons pots and then a multiplexer buttons and multiplexer pots so the normal buttons are and pots are pots that are wired directly to your Arduino and the multiplexer pots and buttons are ones that are going through a multiplexer chip so we have no direct buttons no direct plots no multiplexer buttons and we have 64 multiplexer pots so make sure we change this to 64. next we have to indicate how many multiplexers we have and give a bit of information about them to define a multiplexer we just type the command mux and then we give it a name so I'm just calling them M1 M2 M3 M4 very creative next we have to tell the program what Arduino pin our mux is connected to so these are analogs so I'm connecting them to analog pins so M1 is connected to Arduino pin a0 and then A1 A2 A3 next we tell the program how many pins our multiplexers have because you can get eight pin versions and 16 pin versions so these are all 16 pin versions so I just put 16 for all of them finally we have to tell the program are we using our multiplexer as an analog or digital device if it's analog we put true if we put false here it would be treated as a button or digital device so we'll just put true for all these and there's our four multiplexer chips next we'll go down to this section where we Define our potentiometers connected to a multiplexer so we'll use the command pot we'll give each potentiometer its own name so I'm just using mp1 mp2 three four five all the way up next we have to tell it which multiplexer the ones we defined earlier that pod is connected to so these are the M ones these are the m2s M3s and m4s next we have this uh command number and that's really not used for anything right now so we'll just put zero for all of them next we will put the midi CC number that the pot will send and all these pots will be treated as midi CC so this could be any number from 0 to 127 uh what I did to make it easy to troubleshoot is I just made the CC number the exact same as the pot number so if one of them isn't working I'll know exactly which pot on the board is the culprit so you can see we've got one all the way up to 64. and the last parameter is the midi Channel and I'm just putting them all onto Channel One the final thing we have to do is we have to update this array with all the pots we just defined so to do that you put the Ampersand symbol and then the pot name that we defined here and then you put a comma and then you do the next one so you can see I've got a big group here mp0 all the way to mp064 and uh that's it we should be ready to go so here is my Arduino Nano on the breadboard and I'm going to plug it into my computer and we should get the little USB beep so I have to choose from my board menu the Arduino Nano right there next I want to make sure a port comes up so this is a port that the Arduino software is detected an Arduino on so it should show up here it's com3 in my case yours could be different one thing I sometimes have to do depending on the Arduino Nano whether it's a genuine Arduino or a knockoff you may have to use this parameter so normally we we choose at Mega 328p but if it you get errors and it doesn't compile for some reason you can try uh old bootloader version and that will usually work all right everything's programmed we just got to get this program into the board wish me luck so go up to your little upload arrow and watch for the flashing lights on the board and you can watch the program go up and there you go when you get the done uploading message you're good to go okay our Arduino Nano is programmed up and ready to go our board is sitting here looking real nice now we gotta introduce them to each other so the first thing we have to do is we're going to build a five pin midi circuit so the Arduino Nano doesn't support USB midi so we're going to have to use old school five pin midi which is not a problem it it brings me back to the good old days so I'm going to use one of these Jacks with the pins on the bottom and I like these because they actually fit into a breadboard so they're very good to experiment with if you look at the back of the Jack you'll see there's five pins the pins we're concerned with is the middle pins we're going to connect this one to ground the pin directly to the right of it we're going to connect this through a 220 Ohm resistor to our arduinos TX pin the pin directly to the left of the middle we're going to connect through a 220 Ohm resistor to the arduino's 5 volt power supply and the two outside pins we're not going to connect to anything so first of all I'll take my midi Jack and I'll put it right on the edge of the board here now we'll take a jumper wire from the middle pin of my midi Jack to the ground pin on my Arduino labeled gnd now I'll grab two 220 ohm resistors and I'll put one on my right hand pin just kind of bridge the middle of the board here and I'll put the other on my left hand pin and remember the two outside pins are not connected to anything now I'll take a jumper wire and I'll connect this right hand pin to the pin marked TX on the Arduino and that is the transmit pin next I'll take another piece of wire and I'll take this left hand pin and I'll put it to the 5 volt Supply on the Nano it's labeled 5V and there you go our midi circuit is done all right now we need to hook our Lotto pots board up to the Circuit so first I'll grab two jumper wires now I notice these ones have a male end on one side and a female end on the other and that's gonna help us deal with these header pins so I'll take the uh Power Jack Mark plus and I'll put that to the 5 volt supply pin 5V on the Arduino and I'll take the Power Pin marked minus and that will go to our ground gnd so now our entire board has power next I want to make sure I enable all my multiplexers so what I'm going to do is I'm going to take these little jumpers for the headers and you notice I've marked it on and off so I'm going to put it across the two pins labeled on all right and I've done all four multiplexers so they should all be enabled now next we'll connect our address pins so remember every multiplexer has four pins that tell it which pot to send to the output and we've routed them all to this same four pins so these four pins control all the multiplexers so the way this code works you have to use uh digital pins D2 D3 D4 and D5 for this so we take our lowest digit the S zero pin on our address and we're going to put that to Arduino digital pin 2. we'll take the next pin and we'll put it to digital pin D3 the next pin will go to D4 and the last pin will go to D5 and the last step we have to connect the output pins of our multiplexers to the analog inputs on the Arduino so if you remember back to the program the first multiplexer was connected to a0 the second multiplexer is a one this third guy is going to A2 and finally the fourth multiplexer is going to A3 and there you go we should be ready to give this thing a test so in order to get the five pin midi into my computer I'm going to use this midi man little two Port midi interface I will connect a midi cable to the input and the other end to the output of my project finally we'll power up our project with a USB cable and watch for smoke all right so far so good okay so to test this we're going to use this uh midi monitoring software called midi aux and that is going to read the data that comes into this and if everything works okay we should get some CC messages on the display oh will you look at that so that looks great we've got signal and data is coming through now we just got to test every potentiometer one at a time and make sure they all work so when you're looking at these numbers I want you to pay attention to the data one column and that is going to be the pot number and the midi CC number that is coming out of our project so let's just go through turn every pot and make sure they all work there you go 64 pots one Arduino Nano they said it couldn't be done we just proved them wrong so there you go guys 64 pots one Arduino Nano it is possible don't let anyone tell you otherwise and there's two extra analog inputs that we didn't even touch so maybe another 32 Pots if possible as always I'd like to sincerely thank my patrons on patreon for supporting me and helping me build weird stuff like this thanks again guys let's enjoy your names on the big screen and I'll see you next time [Music] thank you [Music]
Info
Channel: Notes and Volts
Views: 14,566
Rating: undefined out of 5
Keywords: Arduino, DIY, Maker, Solder, Midi, Music, Synthesizer, Circuit, Schematic, USB, Microcontroller, Interface, Adaptor, DMX, 5-Pin, 3.3V, Nano, Uno, Potentiometer, Controller
Id: NBlcFXWVSDA
Channel Id: undefined
Length: 26min 55sec (1615 seconds)
Published: Fri Mar 31 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.