Buttons, Pots, and Joysticks
Please Log In for full access to the web site.
Note that this link will take you to an external site (https://shimmer.mit.edu) to authenticate, and then you will be redirected back to this page.
We have a help queue active for lab! Go through the lab, answer the questions on this page, and ask for checkoffs on the queue! When you're all done with everything, you're done! If you get stuck on the way, let us know; we're happy to help!
Remember that labs are a learning experience, not a test, so please ask us questions as you're working through!
Although we do want everyone to work individually and build their own circuits, it is also more than OK to ask friends/neighbors for help, too.
Over the next couple weeks' labs, we're going to be building a video game controller, which we'll be able to trick a computer into thinking is an XBox 360 controller:

Next week, we'll be learning to solder, putting together the physical controller, making all the necessary connections, hooking it up to our computer via a microcontroller. That's going to take some time, so we'll devote all of next week's lab time to it. So that we can do that, though, we're going to take some time today to make sure we understand how the different components work. So today we'll play around with the pieces in isolation, and next week we'll put it all together.
1) Buttons
The first component we'll look at is a button (a.k.a. a momentary switch if you're feeling fancy). In a circuit schematic, we'll often draw a momentary switch like so:
While the button is pressed down, its terminals are shorted together; but when we let go of the button, its terminals are again disconnected. In a second, we're going to build the following circuit:
The red "+" and "-" tags there represent the place where we'll measure our output (which will change based on whether the button is pressed or not).
1.1) Build It
Before building, let's go ahead and turn on the scope (we'll need it in a bit) and reset it to all of its defaults by:
- Pushing the "Default Setup" button in the upper left, and
- Under the "Wave Gen" menu (accessible by pushing the button in the bottom right), click the "Settings" button (the bottom one on the screen), then click the "Default Wave Gen" button (the bottom one again) You should get a message on screen saying that things have been reset.
Grab a button from the front of the room (feel free to choose any color you like), and a 1{\rm k}\Omega resistor from the cabinet. Then go ahead and build this circuit.
One thing we're going to ask is that you build your circuit so that the resistor and the button are on far sides of the breadboard from each other with long wires connecting them, not super close together.
The buttons look like this:

The button's terminals are spaced out just right so that they fit into the breadboard. Please leave them at that spacing rather than bending the terminals. (We'll be reusing these buttons later and we don't want them to get all messed up before then).
1.2) Our New Friend, the Benchtop Power Supply
Your circuit needs power to work, and today we'll introduce a new piece of equipment that we'll use to power our circuit for today: the benchtop power supply, which looks something like this:

We'll need little plugs in the port labeled CH1. If you don't have those plugs ("banana-to-alligator" plugs), we have some more at the front of the room. Make sure red and black are in the right holes, and don't put anything in the little green hole at the bottom labeled GND.
When you turn on the supply (the button on the bottom left), you'll see something like the above on the display. While the green "V" on the right is lit up, turning the big knob will adjust the voltage; clicking the little "A" will change things to that the big knob will adjust the maximum current instead. The channel whose values you're changing can be selected by clicking "CH1" or "CH2".
For now, let's do the following:
- Make sure all of the little things labeled "On/Off" are off (not lit up)
- Make sure the "SER" and "PARA" buttons up top are also off (not lit up)
- Click the "CH1" button if it's not already lit up, and then use the "V" and "A" buttons and the knob to set it to output 10Volts with a current limit of 1.5A.
When all is said and done, it should look something like the picture above. If you are having any trouble or just want a staff member to double-check things, let us know!
Then go ahead and connect the power supply to the circuit on your breadboard (note that the red wire corresponds to the "+" side of the voltage source in the schematic, and the black wire corresponds to the "-" side).
When you're confident that you've done that correctly, you can hit the "ON/OFF" button just under "CH1" on the power supply. That button should then light up and stay lit up; while it is lit up, it is providing power. Note that when the "ON/OFF" button is lit up, the values displayed on the scope change to represent what it's actually providing, rather than the settings from before.
1.3) Testing Your Circuit
Make sure you've got channel 1 on the scope measuring the voltage drop across the button before continuing.
Now try pushing down the button and holding it for a while. Does the voltage on channel 1 of the scope change as you expected it to? Zoom in enough so that you can see the voltage clearly changing as you push the button.
Often, we're interested in shorter button presses, though. Try pressing the button down as quickly as possible (just a single, fast tap) and seeing if you can notice the voltage change. If you're lucky, you may see a brief little blip on the screen. But that blip goes away very quickly; if we wanted to measure anything about it, that would be difficult as things currently stand.
This idea, of wanting to capture and measure rare events, is one of the things that the oscilloscope is great for (as we saw in last week's lab).
Right now, using auto mode, set the vertical zoom level so that the voltages with the button pressed and released are both clearly visible, but fall at very different points on the screen (i.e., they should be far apart vertically but both visible). As you click the button, a few times, you should see the signal bouncing back and forth between those two levels.
Next, we're going to try to measure a really fast button press by setting the scope's trigger to be the kind of thing that happens when the button is pressed. Keep the triggers in Auto mode to start, to see what a button press looks like, then switch them to Normal mode (and set the threshold appropriately).
Set it back to rising edge afterwards.
1.4) Power
We'll spend a little more time with this circuit before moving on to another experiment in just a moment. In the circuit above, we saw the voltage changing between 0V and 10V as you pushed the button. But interestingly, those voltages don't depend on the particular value we chose for the resistor in the circuit.
Despite this, the particular value of resistance that we choose here can make a big difference in terms of the behavior we see from the circuit in real life. Importantly, even though the resistance value doesn't affect the voltage that we see across the button, it does affect the current flowing through the circuit (and, thus, the power dissipated by the circuit).
p =~
Now, let's imagine using a 10\Omega resistor instead.
p =~
Importantly, the resistors we're using in lab are designed to dissipate 1/4 Watt or less, so using a 10\Omega resistor puts them well above that rating.
What does this mean for our circuit? We'll, let's try it out. But we're going to be really careful. What we're about to do next isn't the most dangerous thing in the world, but it's possible to hurt yourself if you're not careful.
We'll set things up by taking the following steps, carefully and in order:
- Grab SAFETY GLASSES and put them on. You can keep them on for the whole lab if you want (they're very fashionable!), but let's keep them on at least through checkoff 1.
- Turn off the power supply by hitting the "ON/OFF" button under CH1 before you move on. The "ON/OFF" button should not be lit up at this point.
- Replace the 1{\rm k}\Omega resistor in your circuit with a 10\Omega resistor, making sure that it is on the opposite end of the breadboard from your button, and connected through a long wire.
- Double-check that things are connected properly. Feel free to ask a staff member to come and take a look before proceeding.
Now we're going to do a little experiment. Maybe it's a little bit of a spoiler alert, but we're going to go ahead and warn you that the resistor is going to get HOT when we do this experiment.
OK, let's try it. If you want some supervision, go ahead and put yourself on the queue and someone can come over to help.
Turn the power supply by on by hitting the "ON/OFF" button on the power supply. This will provide power the circuit, but because of the little button on the breadboard, nothing will happen yet.
Finally, go ahead and press down the button on your breadboard for a little while. Things will get pretty hot pretty quickly, so stop pushing the button at the first sign of smoke/fire; don't keep holding the button down if things are burning.
The resistor will stay hot for a while, so don't touch it yet; just leave it in the board.
Talk with a staff member and answer the following questions:
2) Design
Now let's try to make use of what we did in the last few experiments. Our last circuit changed the output voltage from 10V to 0V when the button was pressed. Now let's consider a slightly different circuit:
Choose values of R_1, R_2, and R_3 such that:
- When the button is not pressed, v=6{\rm V}
- When the button is pressed, v=5{\rm V}
- The total power consumed by the resistors in either case is less than 5mW.
10, 20, 5000
.
Resistance values:
Then go ahead and build your circuit to verify that things work. Note that we may not have all of the resistor values you chose above; you can either adjust those values to find ones that we have, or use what's available in the cabinet to make these resistors for yourself.
Talk through your design with a staff member, and
demonstrate your working circuit. How did you come up with these values?
3) Gateway Circuits
Next, we'll start thinking about the joysticks that will go in the controllers. But before we can get there, it's useful to think about a simpler component: a potentiometer. As we saw in the prelab, a potentiometer (or pot) is a three-terminal device whose electrical properties depend on the rotation of its mechanical shaft. We can think of a potentiometer as being made up of two resistors, whose resistances sum to some value R_p, and whose resistances vary with the rotation of the shaft, which we will quantify using a number \alpha: one resistor has resistance \alpha R_p, and the other has resistance (1-\alpha)R_p. Schematically, we can represent pots in the following two ways:
Because you have a single-turn pot (multi-turn pots exist, but aren't relevant here), the quantity \alpha corresponds directly to the angle of the potentiometer's knob, normalized to be in the range [0, 1]. \alpha=0 implies the knob is turned all the way in one direction, and \alpha increases as the angle increases, until reaching \alpha=1 when the knob is turned all the way in the other direction. As the angle of the knob increases, the resistance between the bottom and middle terminals increases and the resistance between the middle and top terminal decreases. These changes in relative resistance do not affect the sum of the top and bottom resistors, which remains constant.
The illustrations below show how these resistors are actually connected inside the potentiometer:

Grab a potentiometer from the front of the room. Measure its total resistance using the multimeter. Then measure the resistance between the middle terminal and one other terminal. Which resistance goes up at you turn the knob counter-clockwise? Which goes down? How big or small can they get? Be prepared to discuss these questions during your checkoff.
Next, hook up the 10V signal from the power supply so that we are dropping 10V across the whole potentiometer (building a circuit like the one at the end of the prelab) and using channel 1 to measure the voltage drop across one side of the potentiometer. What does circuit theory say about how the voltage should change as you turn the knob on the potentiometer? Check that things are working by turning the knob and seeing the voltage on channel 1 change.
4) Let There Be Light?
Now let's try using the variable voltage from the last section to try to light up an incandescent lightbulb. In a schematic diagram, we might draw a lightbulb like:
Grab a lightbulb from the front of the room. We can model this kind of lightbulb as a resistor. Measure its resistance using the multimeter. Then, disconnect the lightbulb from the multimeter and connect it to the power supply. Set the output to be constant 1 Volt to start, and then adjust the voltage between 0V and 10V while observing the bulb.
Hook the power supply up to your potentiometer as before (without the lightbulb connected).
The pot's terminals are spaced out just right so that they fit into the breadboard. Please leave them at that spacing rather than bending the terminals. The pots fit nicely into one side of the breadboard (without jumping the gap in the middle), so plug your pot in on one side of the breadboard and use wires to connect the terminals elsewhere if you want.
We have some little wires in the cabinet under the resistors, which are pre-cut to be just the right length to jump across the gaps in the breadboard. These can be a really useful way to keep things from getting too messy when building these circuits. For example, here is one way we could hook up the pot:

Now, add to your circuit by connecting your lightbulb between the middle terminal of the pot and ground. As you turn the knob, how does the brightness of the bulb change?
Given your previous result with directly adjusting the voltage from the power supply, this result was probably somewhat surprising! Let's try to explain this result using circuit theory.
Use circuit theory along with modeling the light bulb as a resistor to estimate, to within 0.1 volts, the voltage across the bulb, for the values of \alpha given in the table below. Don't use a calculator. Use the resistance you measured earlier for the bulb.
Then find the value of \alpha such that the bulb voltage is 5V (one-half of its maximum value), accurate to within 10^{-3}. Hint: Draw the circuit with approximate resistor values, and look for a combination you can simplify/approximate.
Place these four points approximately on a graph of v_\text{bulb} versus \alpha, and sketch a smooth curve through them.
Discuss the results of your experiments with the pot and the light with a staff member, including:
5) Joystick
One of the components in the gamepad will be a joystick, which consists of two separate potentiometers in a single package (hence our earlier experiments with the pots):

This package contains two potentiometers, which are connected to the pins labeled as follows:
Grab a joystick from the table at the front of the room. Notice that the joystick has two degrees of freedom. Moving the joystick along one of its axes changes \alpha_1, and moving the joystick along the other axis changes \alpha_2.
Plug your joystick in to your breadboard as shown in the picture below:

Note that there should be a couple of holes on one side of the joystick package. Use these to:
- Connect
POWER
to the positive terminal of the power supply - Connect
GND
to the negative terminal of the power supply - Connect channel 1 to measure between
HORIZ
andGND
, and channel 2 to measure betweenVERT
andGND
(note that theVERT
axis is the short edge of the board and theHORIZ
axis is the long edge of the board, so if you orient the board as shown in the photograph above, then moving the stick left and right will change theHORIZ
voltage and moving the stick up and down will change theVERT
voltage)
Right now, the scope is displaying time on its horizontal axis, with each channel as a separate signal on the vertical axis. But that isn't particularly useful for visualizing this kind of device. So we're going to try a different kind of display: X/Y mode. Instead of separate plots of channel 1 and channel 2 versus time, this mode will cause the scope to make a single plot of channel 2 versus channel 1.
Set the scope to X/Y mode by first clicking "Acquire" (near the top middle of the panel of buttons). From the menu that pops up, set "Time Mode" (the top thing) to "XY". You should see the plot change.
Now, move the joystick around. Does the display on the scope change as you expect? Try to set things up so that the dot exactly mirrors the motion of the joystick (moving the joystick right moves the dot to the right, and so on).
It turns out that this is precisely what goes on if you've ever used a real game controller. The analog sticks are connected as voltage dividers like this, and the voltages are read into a computer to determine the player's inputs. Yet another cool example of circuits serving as an interface to the physical world (in this case, enabling a neat kind of human-computer interaction).
For extra fun, under the "Display" menu, change "Persistance" to "Variable Persistance" to cause a trace of the dot to remain for a while after it is originally drawn (or you can set it to remain permanently). Can you use this to draw a little picture or something like that?
Discuss the results of your experiments with a staff member. After your checkoff, clean up by: