Skip to main content

Soil Moisture sensor with Arduino in Tinkercad | how to use soil moisture sensor in Tinkercad

  Soil Moisture sensor with Arduino in Tinkercad | how to use soil moisture sensor in Tinkercad Circuit diagram: Arduino Sketch: // C++ code // int moisture_data = 0; void setup() {   pinMode(A0, INPUT);   Serial.begin(9600);   pinMode(12, OUTPUT);   pinMode(6, OUTPUT); } void loop() {   moisture_data = analogRead(A0);   Serial.println(moisture_data);   if (moisture_data < 21) {     digitalWrite(12, HIGH);     digitalWrite(6, HIGH);   } else {     digitalWrite(12, LOW);     digitalWrite(6, LOW);   }   delay(10); // Delay a little bit to improve simulation performance }

Interfacing of tilt sensor (SW200D) with an Arduino in tinkercad.

Interfacing of tilt sensor (SW200D) with an Arduino in tinkercad. 

Tilt Sensor can detect the inclination of an object and gives its output High or Low. There is a mercury ball inside the tilt sensor which moves when the sensor tilted and completes the circuit. So we can use this feature to turn on and off the circuit.

In this project, we are interfacing Tilt sensor with Arduino board in tinkercad. And controlling a LED output when the tilt sensor tilts. It can be used like an alarm if the sensor tilts then we can turn on the buzzer and LED flasher.

Circuit Diagram:



Components Required:

§  Arduino UNO

§  Tilt sensor (SW200D)

§  Resistor-1

§  LED-01

§  Connecting wires

Connection:

The hardware a part of this project is quite simple and easy to place together. First of all, make the connections for the tilt sensor with the Arduino. The connections for the tilt sensor with the Arduino given in the above circuit diagram.

The tilt sensor we used here is SW200D.tilt sensor has two pins one is connected to the GND pin of an Arduino and another pin is connected to the digital pin of an Arduino.

Connect the one terminal of tilt sensor to the digital pin 2 using resistor.

Connect the other terminal of tilt sensor to the GND pin of an Arduino.

Connect the LEDs anode terminal to digital pin 9 of an Arduino.

Connect the LEDs cathode terminal to GND pin of an Arduino.


Working of Arduino Tilt Sensor

A Tilt sensor is quite similar to a normal on off switch only difference is it conducts current when it inclined at certain angle or in other words, I can say it turned on only when it tilts. Due to this property, we can use tilt sensor to detect the orientation od an object.

Now there are different types of tilt sensor out there here we using a simple one axes inclination, a tilt switch or sensor. There are two kinds of technology is to make the tilt sensor Mercury based and Roller Ball based. The old ones are made of mercury. For more accuracy and results we are having an accelerometer based 3- axis tilt sensor, using this sensor we can detect full motion in three axes.

In SW200D tilt sensor, two metal balls are used to close or open the switch. When we placed the sensor in upright position then metal ball closes the contact with both the terminal and closes the switch.

When the inclination of the sensor is changed or sensor is tilted by certain angle then metal ball are not in contact with terminal then the switch is open.

Working of project:

As per the circuit diagram, the output voltage of the tilt sensor is connected to the digital input pin 2 of an Arduino. Tilt sensor gives the digital output when it tilted. output of the tilt sensor is stored in variable name tilt sensor. Now if the tilt sensor output is high that is 1 then set the digital pin 9 low this will make LED turn off, if the tilt sensor output is low that is 0 then it gives the led flasher effect.

 

Code Explanation (Block Based):

 

First of all, we create a variable named tilt_sensor to store the sensor value . For declare the variable click on the variable block and create a variable, see the below picture..




After declaring the variable drag out the set block and set to the following blocks


Now set the variable that is tilt_sensor to the read digital pin 2.

Take out the serial monitor block to print the sensor value on the screen


Let’s use the main conditional statement of the program that is ‘if’ block




Drag the if block from the control also drag one block that is set pin block from output and place it inside the if block. Select the digital pin 9 drag the comparator operators from operators from math’s block. Here two conditional statements used,

Condition1:

 If the tilt sensor value is equal to the 1 then set digital pin 9 low, this will make LED turn off.

That means sensor is not tilted.

 

Condition2:

 If the tilt sensor value is equal to the 0 then set digital pin 9 high for 0.2 sec and low for 0.2 sec this will create the LED flasher effect. Indicate that sensor is tilted.


Watch Working video :





Complete Arduino sketch:

int tilt_sensor = 0;

 

void setup()

{

  pinMode(2, INPUT);

  Serial.begin(9600);

 

  pinMode(9, OUTPUT);

}

 

void loop()

{

  tilt_sensor = digitalRead(2);

  Serial.println(tilt_sensor);

  if (tilt_sensor == 1) {

    digitalWrite(9, LOW);

  }

  if (tilt_sensor == 0) {

    digitalWrite(9, HIGH);

    delay(200); // Wait for 200 millisecond(s)

    digitalWrite(9, LOW);

    delay(200); // Wait for 200 millisecond(s)

  }

}



Like share and comment :

                                                     Our FaceBook Page                                                           







For Any queries please contact:

impulseTech101@gmail.com

Comments

Popular posts from this blog

Water level monitoring system using IoT | IoT based water level using Nodemcu ESP8266 & ESP32

Water level monitoring system using IoT | IoT based water level using Nodemcu ESP8266 & ESP32 Hello Everyone! I have come up with new tutorial Water level monitoring system using IoT | IoT based water level using Nodemcu ESP8266 & ESP32 For Code & Circuit Diragram: In this video what you will learn about? 1. How to configure the new Blynk IoT Platform. 2. How to setup web dashboard 3. How to create template in blynk iot 4. How to interface ultrasonic sensor with node mcu esp8266. 5. How to read ultrasonic sensor with esp8266 1.You can Watch Playlist on New Blynk IoT Platfom New Blynk IoT platform with esp32 | how to setup automation in Blynk IoT app https://youtu.be/O2HZuu4KtIc 2.How to create events in blynk IoT platform | events in new Blynk IoT platform 🔥🔥 https://youtu.be/X5zVaGk8QV0 3.IoT Based smart garden monitoring system | Smart plant monitoring using Blynk IoT https://youtu.be/GTdxD5vQwy0 4.Water level monitoring system using IoT | IoT based...

Getting Started with the Arduino IoT Cloud using Esp32 & DHT-11

  Getting Started with the Arduino IoT Cloud using Esp32 Introduction: The Internet of Things has given rise to plenty of exciting new projects for makers. It's both interesting and practical to be able to develop remote sensors and gadgets. Allowing IoT devices from multiple manufacturers to interact with your innovations will open up a lot of possibilities, including some you might not have considered before. In this getting started guide of Arduino IOT cloud we will learn about how to use Arduino IOT cloud with Esp32 board. Arduino IOT cloud What is Arduino IOT cloud? Arduino IoT Cloud is a web-based service that allows users to create connected devices quickly, easily, and securely. Multiple devices can be linked together and data can be exchanged in real-time. Users can also able to monitor the data using a simple user interface from anywhere. one can also use the android application for monitoring and controlling the devices. Because Arduin...

Soil Moisture sensor with Arduino in Tinkercad | how to use soil moisture sensor in Tinkercad

  Soil Moisture sensor with Arduino in Tinkercad | how to use soil moisture sensor in Tinkercad Circuit diagram: Arduino Sketch: // C++ code // int moisture_data = 0; void setup() {   pinMode(A0, INPUT);   Serial.begin(9600);   pinMode(12, OUTPUT);   pinMode(6, OUTPUT); } void loop() {   moisture_data = analogRead(A0);   Serial.println(moisture_data);   if (moisture_data < 21) {     digitalWrite(12, HIGH);     digitalWrite(6, HIGH);   } else {     digitalWrite(12, LOW);     digitalWrite(6, LOW);   }   delay(10); // Delay a little bit to improve simulation performance }