Latest posts by Ajeng Putri Setyani (see all)
- ADD OWNCLOUD STORAGE CAPACITY - July 20, 2017
- SYNCRONIZATION OF INTER DEVICE WITH OWNCLOUD SERVER - July 20, 2017
- INSTALLATION AND CONFIGURATION OWNCLOUD IN SERVER PART 1 - July 20, 2017
Experiment with magnetic sensors
Magnetic sensors can be used to detect the presence of magnets. An example of a sensor is shown in Fig. 12.1. Figure 12.2 shows a schematic diagram to test it. In principle, this sensor produces a value of 1 if there is no magnet right before the sensor and value 0 if there is a magnet right in front of it (see illustration in figure 12.3). Its application, for example to detect door being open or closed.
To practice this sensor, try these steps:
1. Create a new project called magnet
2. Create the following script:
3. Press ctrl + S to save the project
The script above states that if the digital pin 2 is 1, the pin 13 is set to 0 (Dead LED) for the reverse state pin 13 is made 1 (live LED).
To test it, click on …… then place the magnet in front of the sensor and the LED’s attention is on or off. Then, keep the magnet and watch the LED turn on or not. Figure 12.4 shows the state when the LED is on.
Experiment with Touch Switch
The touch switch is a working switch on the touch. A sample module that acts as a touch switch is shown in Figure 12.5 to practice it, please arrange the circuit as shown in Figure 12.6. first.
Next, you can create a new project called touch. Create the following script:
After, press Ctrl + to save the project
The above script states that if the digital pin 2 is 1, the pin 13 is set to 0 (Dead LED) for the opposite state, pin 13 is set to 1 (live LED).
To test it, click on … if you touch the sensor, the LED will turn on.
You can also create a touch switch as the on / off button, which has been discussed in chapter 9 for that, follow these steps:
1. Create a new project called touchuhonoff
2. Create a variable named 1 edMenyala, previous state, and current state. The result is as follows:
3. Create the script
To understand the script, please read chapter 9
To test it, click on … then, touch the touch switch module. LED will be lit and maintained. Then touch again. LED will die.
Please note, the only difference with the script in Chapter 9 is:
Notice the existence of a block of notes which means “not” the condition states that the digital pin 2 in the keadan is not pressed or is 0.
Experiment with the Soil Humidity Sensor
Want to know soil moisture? You can use the soil moisture sensor as shown in figure 12.7. To experiment, please make a circuit like the one shown in Figure 12.8
Keep in mind, the soil moisture sensor gives the value at D0 as follows:
– 1 (HIGH) if the soil is dry;
– 0 (LOW) if the soil is wet.
The results of pin A0 ranged between 0 and 1023.
An example of the preparation of the two soil moisture measuring devices against the Arduino is shown in Fig. 12.9. The example of mounting the sensor portion to the soil media is shown in Fig. 12.10.
To practice this sensor, perform the following steps:
1. Create a new project called humid
2. Make two variables named ledMaturala and dataPin so the result as follows
3. Click and drag the two variables on the stage so that they are in the following positions:
4. Create a script like this:
5. Press Ctrl + S to save the project
In front of the script, the first variable ledFace filled with “x” through set ledMelaya to x means, no LEDs are lit. Furthermore, this variable will be populated with ‘M’, ‘H’ or ‘K’ each of which respectively states a red LED, green LED, or yellow LED is lit up.
Blocks are used to store values on analog pins 0 to variable dataPin. Next, the values in this variable will be checked with three possibilities:
– Worth less than 250 (to declare a very wet ground);
– Worth between 250 and 699 (to declare a rather wet ground);
– Worth more than or equal to 700 (to declare dry ground).
This is handled by:
If the dataPin 250 condition is met (true value), the following code is executed:
The code is used to turn on the green LED, turn off the yellow and red LEDs and load ‘H’ to the led variableThe LED if the led is not ‘H’. If the green LED is on, the following code does not need to run:
As is known, the green LED is connected to pin 11, the red LED is connected to pin 13 and the yellow LED is connected to the green LED.
If the dataPin condition is met, the following code will be executed.
The code is used to turn on the yellow LED, turning off the green and red LEDs and charging ‘K’ to the led variableIt is altogether ‘K’.
If the dataPin condition is not met, the following code is executed:
The code is used to turn on the red LED, turn off the green and yellow LEDs and load ‘M’ to the led variableTheir if ledFlash is not worth ‘M’
After the above script is compiled, connect the Arduino to the computer. Then you can click on .. to test it. You can pour water into the planting medium to see the lit LED changes.
Experiment with Sound Sensor
Sound sensor is useful for detecting sound. The shape is shown in figure 12.11 the output is D0 (digital) and A0 (analog). To practice this sensor, you need to arrange the circuit as shown in Figure 12.12
To practice this sensor, do the following steps:
1. Create a new project called sound
2. Add a costume to the Arduino sprite in the form … so you’ll see that the Arduino sprite microcontroller turns into:
3. Add three variables named reference, dataPin, and absolute so the result is as follows:
4. Set the look of these three variables on stage as follows to make it easier for you to see each of them.
5. Create a script like the following:
6. Press Ctrl + S to save the project
After the script in front is compiled, connect Arduino to computer, then you can click on .. to test it. Speak in front of the microphone.