Table of Contents

set digital pin () output as ()

Description

The block sets the digital state of the specified pin to HIGH or LOW / 0V or 3.3V. The block have two inputs:

  1. Quarky Pin:
  2. State of the Pin:
    1. HIGH – 3.3 V
    2. LOW – 0V

Example

Learn about soil moisture sensors and how they work to measure the moisture level in the soil.
introduction

A soil moisture sensor is a valuable tool used to determine the moisture content in the soil, crucial for efficient gardening, farming, and agricultural practices. This analog sensor generates varying output values depending on the moisture level present in the soil. Typically, it operates as a two-pin circuit, with these pins responsible for powering up the sensor module. To obtain soil moisture readings, a voltage divider circuit is employed on the negative pin of the sensor, resulting in a signal pin that provides the moisture level data. Alternatively, some sensor modules come with a controller circuit that automatically converts the 2-pin connection into a 3-pin output, simplifying the process of accessing moisture values.

Below is a simple circuit diagram and code to get you started with monitoring soil moisture using an Arduino board. By following these steps, you can create your own moisture monitoring system with ease. Let’s begin!

 

Soil Moisture Sensor Hookup Guide - SparkFun LearnAuslese™ Detection Module Soil Moisture Sensor (Pack of 1Pcs) : Amazon.in: Industrial & Scientific

circuit diagram

Code

  1. Go to my variables and create a variable and name it “moisture level.” Set its initial value to 0.
  2. Add a “forever” loop from the control palette.
  3. Inside the forever loop, add a “set () to ()” block using the “my variable” category. Set the variable “moisture level” to the output value of the next block.
  4. From the Quarky palette, add the “map () from ()-() to ()-()” block. Replace the placeholder “0” with the map block.
  5. From the Sensors palette of Quarky, insert the “read analog sensor () at ()” block in place of “50”, and change the data range from 0-4095 to 0-100, as shown below. 0 stands for 100 percent moisture and 100 means completely dry
  6. Add an “if-else” block from the controls palette. Use it to check whether the value of the sensor is greater than 50% or not.
  7. If the value is greater than 50%, activate the buzzer connected to pin D2 otherwise the buzzer must remain off.
  8. Finally, add the “when flag clicked” block at the start of the script to initiate the monitoring process.

Script

 

With these steps, your script is complete, and you can now monitor the soil moisture effectively using the soil moisture sensor and Arduino board. Happy gardening and farming!

Output

 

 

 

Read More
Explore the functionality of a raindrop sensor, an analog-type sensor that detects changes in resistance upon contact with water.
introduction

The raindrop sensor is an analog-type sensor that effectively measures changes in resistance when it encounters water. This property makes it an ideal choice for detecting rain and water presence in various applications. While typically designed with two pins, there are also versions available with a controller module, effectively converting it into a three-pin sensor for enhanced functionality.

rain drop sensor

Circuit

 

To set up the raindrop sensor circuit, make the following connections:

  • Sensor:
    • VCC: Connect to the 5V power supply
    • GND: Connect to ground (GND)
    • A0: Connect to analog input pin A2
  • Buzzer:
    • Buzzer+: Connect to digital pin D2
    • Buzzer-: Connect to ground (GND)

Code

  1. Add an “if-else” block from the controls palette.
  2. Insert a comparison operator into the “if” block from the operator palette
  3. Check whether the value of the raindrop sensor is below a certain threshold, let’s say 800. From the sensor palette of Quarky, add “read analog sensor () at pin () ” and place it in the blank space of the operator.
  4. If the value is below the set limit, activate the buzzer (alarm) connected to pin D2. Add set digital pin () output as () from the Quarky palette within the “if” block. In the “else” part, ensure the alarm remains off when the raindrop sensor value is above the set limit.
  5. Add the above set of code inside a “forever” block to continuously monitor the sensor’s readings.
  6. Finally, add a “when flag clicked” block at the start of the code to initiate the raindrop sensor monitoring.

Script

Output

 

 

Read More
All articles loaded
No more articles to load