Sensors

Now that you have learned how to get inputs from switches and potentiometers, it's a very small step to get inputs from ANY electrical device that can act like a switch or a variable resistor. There are a lot of things that can do this, and many of them you can build for yourself.

Basic Circuit

The basic circuit for all input devices is a connection between the +5V power pin and one of the ground (GND = 0V) pins that includes a resistor and another wire connected back to a digital or analog input pin on the Arduino. As we saw in a previous lesson, if there is a switch, or any kind of temporary break in the circuit, the voltage on the input pin can be changed from 0V to +5V. Try to think of some ways that you could make a switch using things like paperclips or aluminum foil. Do you have any old electronic equipment that you could take apart and reuse real switches or buttons? Whenever you are using a switch circuit, your Arduino code will have to contain "if" statements to check if the input is HIGH or LOW. Keep in mind that the Arduino has many input pins, so multiple switch circuits can be added to one Arduino.

Switch Circuit

Variable Resistors

If the switch is replaced by something that can have a varying amount of resistance, and an analog input pin on the Arduino is used, then the Arduino can sense things that change over a range of values instead of just HIGH and LOW. Think of some ways that you could make a varying amount of resistance. What substances conduct small amounts of electricity? (One example is your own skin!) Often if a substance conducts a small amount of electricity, you can change the amount of electricity (or resistance) by changing the size, shape or amount of that substance. This is easy to do if you use salty play dough. You can find instructions here. When using a variable resistor of any kind, make sure your circuit also contains a fixed resistor (R2 in the diagram below) to make sure the resistance never goes down to zero ohms. That would be a short circuit and could damage your Arduino.

Variable Resistor Circuit

Again, you could take apart old electronic equipment to find other kinds of variable resistors (anything attached to a rotating knob or slider is a possibility.) Talk to the teacher or do some research on-line about other possible sensors. There is a light sensor (a substance that changes resistance based on the amount of light flling on it) in your kit.

Next assignment: Musical Instrument Assignment

Back to the main menu.