Category: Advanced Input And Output
-
The Arduino Alphabet
In the preceding chapters, you learned the basics of Arduino and the fundamental building blocks available to you. Let’s go over what makes up the “Arduino Alphabet”: Digital output We used it to control an LED but, with the proper circuit, it can be used to control motors, make sounds, and a lot more. Analogue…
-
Complex Sensors
We define complex sensors as those that provide their information in a way that can’t be read with digitalRead() or analogRead() alone. These sensors usually have a whole circuit inside them, possibly with their own microcontroller. Some examples of complex sensors are digital temperature sensors, ultrasonic rangers, infrared rangers, and accelerometers. One reason for this complexity might be to…
-
Driving Bigger Loads (Motors, Lamps, and the Like)
Each of the pins on an Arduino board can only be used to power devices that use a very small amount of current, such as an LED. If you try to drive something big like a motor or an incandescent lamp, the pin might stop working, and could permanently damage the microcontroller that is the…
-
Serial Communication
The Arduino has a USB connection that is used by the IDE to upload code into the microcontroller. The good news is that after a sketch is uploaded and is running, the sketch can use this same connection to send messages to or receive messages from from your computer. The way we do this from…
-
Try Other Analogue Sensors
The light-dependent resistor is a very useful sensor, but Arduino cannot directly read resistance. The circuit of Figure 5-6 takes the resistance of the LDR and converts it to a voltage that Arduino can read. This same circuit works for any resistive sensor, and there are many different types of resistive sensors, such as sensors that measure force,…
-
Analogue Input
As you learned in the previous section, Arduino is able to detect whether there is a voltage applied to one of its pins and report it through the digitalRead() function. This kind of either/or response is fine in a lot of applications, but the light sensor that we just used is able to tell us not only…
-
Use a Light Sensor Instead of the Pushbutton
Now we’re going to try an interesting experiment using a light sensor2, like the one pictured in Figure 5-5. As its name suggests, the light-dependent resistor (LDR) is some sort of resistor that depends on light. In darkness, the resistance of an LDR is quite high, but when you shine some light at it, the resistance quickly drops and…
-
Controlling Light with PWM
You already know enough to build an interactive lamp, but so far the result is a little boring, because the light is only either on or off. A fancy interactive lamp needs to be dimmable. To solve this problem, we can use a little trick that makes a lot of things possible, such as TV…
-
Homemade (DIY) Switches
You can make your own tilt switch with a metal ball and a few nails, and by wrapping some wire around the nails. When the ball rolls to one side and rests on two of the nails, it will connect those wires. You can make a momentary switch with a clothespin by wrapping a wire…
-
Trying Out Other On/Off Sensors
Now that you’ve learned how to use a pushbutton, you should know that there are many other very basic sensors that work according to the same principle: Toggle switch The pushbutton that you’ve been using is a type of switch called a momentary switch, because once you let it go, it goes back to where it was.…