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,… Continue reading Try Other Analogue Sensors
Month: November 2022
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… Continue reading Analogue Input
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… Continue reading Use a Light Sensor Instead of the Pushbutton
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… Continue reading Controlling Light with PWM
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… Continue reading Homemade (DIY) Switches
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.… Continue reading Trying Out Other On/Off Sensors
Introduction
Are the most elementary operations we can do in Arduino: controlling digital output and reading digital input. If Arduino were some sort of human language, those would be two letters of its alphabet. Considering that there are just five letters in this alphabet, you can see how much more work we have to do before… Continue reading Introduction
One Circuit, a Thousand Behaviours
The great advantage of programmable electronics over classic electronics now becomes evident: I will show you how to implement many different “behaviours” using the same electronic circuit as in the previous section, just by changing the software. As I’ve mentioned before, it’s not very practical to have to hold your finger on the button to… Continue reading One Circuit, a Thousand Behaviours
How Does This Work?
We have introduced two new concepts with this example program: functions that return the result of their work, and the if statement. The if statement is possibly the most important instruction in a programming language, because it allows a computer (and remember, the Arduino is a small computer) to make decisions. After the if keyword, you have to write a “question”… Continue reading How Does This Work?
Using a Pushbutton to Control the LED
Blinking an LED was easy, but we don’t think you would stay sane if your desk lamp were to continuously blink while you were trying to read a book. Therefore, you need to learn how to control it. In the previous example, the LED was your actuator, and the Arduino was controlling it. What’s missing… Continue reading Using a Pushbutton to Control the LED